@@ -1244,11 +1244,11 @@ otherwise fall back to \"user\"."
1244
1244
1245
1245
; ;; Evaluation
1246
1246
1247
- (defun cider-interactive-eval (form &optional start-pos callback )
1247
+ (defun cider-interactive-source-tracking- eval (form &optional start-pos callback )
1248
1248
" Evaluate FORM and dispatch the response to CALLBACK.
1249
- START-POS is a starting position of the form in the original context. This
1250
- function is the main entry point in CIDER's interactive evaluation API. All
1251
- other interactive eval functions should rely on this function . If CALLBACK
1249
+ START-POS is a starting position of the form in the original context.
1250
+ Unlike `cider-interactive-eval' this command will set proper metadata for var
1251
+ definitions . If CALLBACK
1252
1252
is nil use `cider-interactive-eval-handler' ."
1253
1253
(cider--clear-compilation-highlights)
1254
1254
(-when-let (error-win (get-buffer-window cider-error-buffer))
@@ -1261,6 +1261,19 @@ is nil use `cider-interactive-eval-handler'."
1261
1261
(file-name-nondirectory filename)
1262
1262
(or callback (cider-interactive-eval-handler)))))
1263
1263
1264
+ (defun cider-interactive-eval (form &optional callback )
1265
+ " Evaluate FORM and dispatch the response to CALLBACK.
1266
+ This function is the main entry point in CIDER's interactive evaluation
1267
+ API. Most other interactive eval functions should rely on this function.
1268
+ If CALLBACK is nil use `cider-interactive-eval-handler' ."
1269
+ (cider--clear-compilation-highlights)
1270
+ (-when-let (error-win (get-buffer-window cider-error-buffer))
1271
+ (quit-window nil error-win))
1272
+ (nrepl-request:eval
1273
+ form
1274
+ (or callback (cider-interactive-eval-handler))
1275
+ (cider-current-ns)))
1276
+
1264
1277
(defun cider--dummy-file-contents (form start-pos )
1265
1278
" Wrap FORM to make it suitable for `cider-request:load-file' .
1266
1279
START-POS is a starting position of the form in the original context."
@@ -1283,7 +1296,7 @@ START-POS is a starting position of the form in the original context."
1283
1296
" Evaluate the region between START and END."
1284
1297
(interactive " r" )
1285
1298
(let ((code (buffer-substring-no-properties start end)))
1286
- (cider-interactive-eval code start)))
1299
+ (cider-interactive-source-tracking- eval code start)))
1287
1300
1288
1301
(defun cider-eval-buffer ()
1289
1302
" Evaluate the current buffer."
@@ -1294,7 +1307,7 @@ START-POS is a starting position of the form in the original context."
1294
1307
" Evaluate the expression preceding point.
1295
1308
If invoked with a PREFIX argument, print the result in the current buffer."
1296
1309
(interactive " P" )
1297
- (cider-interactive-eval (cider-last-sexp) (cider-last-sexp-start-pos)
1310
+ (cider-interactive-eval (cider-last-sexp)
1298
1311
(when prefix (cider-eval-print-handler))))
1299
1312
1300
1313
(defun cider-eval-last-sexp-and-replace ()
@@ -1306,13 +1319,13 @@ If invoked with a PREFIX argument, print the result in the current buffer."
1306
1319
(nrepl-sync-request:eval last-sexp)
1307
1320
; ; seems like the sexp is valid, so we can safely kill it
1308
1321
(backward-kill-sexp )
1309
- (cider-interactive-eval last-sexp start-pos (cider-eval-print-handler))))
1322
+ (cider-interactive-eval last-sexp (cider-eval-print-handler))))
1310
1323
1311
1324
(defun cider-eval-last-sexp-to-repl (&optional prefix )
1312
1325
" Evaluate the expression preceding point and insert its result in the REPL.
1313
1326
If invoked with a PREFIX argument, switch to the REPL buffer."
1314
1327
(interactive " P" )
1315
- (cider-interactive-eval (cider-last-sexp) (cider-last-sexp-start-pos)
1328
+ (cider-interactive-eval (cider-last-sexp)
1316
1329
(cider-insert-eval-handler (cider-current-repl-buffer)))
1317
1330
(when prefix
1318
1331
(cider-switch-to-repl-buffer)))
@@ -1321,33 +1334,35 @@ If invoked with a PREFIX argument, switch to the REPL buffer."
1321
1334
" Evaluate the expression preceding point.
1322
1335
Print its value into the current buffer."
1323
1336
(interactive )
1324
- (cider-interactive-eval (cider-last-sexp) (cider-last-sexp-start-pos)
1337
+ (cider-interactive-eval (cider-last-sexp)
1325
1338
(cider-eval-print-handler)))
1326
1339
1327
- (defun cider--pprint-eval-form (form start-pos )
1328
- " Pretty print FORM starting at START-POS in popup buffer."
1340
+ (defun cider--pprint-eval-form (form )
1341
+ " Pretty print FORM in popup buffer."
1329
1342
(let* ((result-buffer (cider-popup-buffer cider-result-buffer nil 'clojure-mode ))
1330
1343
(right-margin (max fill-column
1331
1344
(1- (window-width (get-buffer-window result-buffer))))))
1332
- (cider-interactive-eval (cider-format-pprint-eval form right-margin) start-pos
1345
+ (cider-interactive-eval (cider-format-pprint-eval form right-margin)
1333
1346
(cider-popup-eval-out-handler result-buffer))))
1334
1347
1335
1348
(defun cider-pprint-eval-last-sexp ()
1336
1349
" Evaluate the sexp preceding point and pprint its value in a popup buffer."
1337
1350
(interactive )
1338
- (cider--pprint-eval-form (cider-last-sexp) (cider-last-sexp-start-pos) ))
1351
+ (cider--pprint-eval-form (cider-last-sexp)))
1339
1352
1340
1353
(defun cider-eval-defun-at-point (&optional prefix )
1341
1354
" Evaluate the current toplevel form, and print result in the minibuffer.
1342
1355
With a PREFIX argument, print the result in the current buffer."
1343
1356
(interactive " P" )
1344
- (cider-interactive-eval (cider-defun-at-point) (cider-defun-at-point-start-pos)
1345
- (when prefix (cider-eval-print-handler))))
1357
+ (cider-interactive-source-tracking-eval
1358
+ (cider-defun-at-point)
1359
+ (cider-defun-at-point-start-pos)
1360
+ (when prefix (cider-eval-print-handler))))
1346
1361
1347
1362
(defun cider-pprint-eval-defun-at-point ()
1348
1363
" Evaluate the top-level form at point and pprint its value in a popup buffer."
1349
1364
(interactive )
1350
- (cider--pprint-eval-form (cider-defun-at-point) (cider-defun-at-point-start-pos) ))
1365
+ (cider--pprint-eval-form (cider-defun-at-point)))
1351
1366
1352
1367
(defun cider-eval-ns-form ()
1353
1368
" Evaluate the current buffer's namespace form."
@@ -1367,9 +1382,8 @@ With a PREFIX argument, print the result in the current buffer."
1367
1382
(clojure-mode)
1368
1383
(unless (string= " " ns-form)
1369
1384
(insert ns-form " \n\n " ))
1370
- (let ((start-pos (point )))
1371
- (insert form)
1372
- (cider-interactive-eval form start-pos)))))
1385
+ (insert form)
1386
+ (cider-interactive-eval form))))
1373
1387
1374
1388
1375
1389
; ; Connection and REPL
0 commit comments