summaryrefslogtreecommitdiff
path: root/cider-interaction.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.com>2018-06-21 23:44:56 +0300
committerBozhidar Batsov <bozhidar@batsov.com>2018-06-21 23:44:56 +0300
commit28bdc1f2897d351f8a1761e4cf121a1dd353a667 (patch)
tree47e9b52111e764cd1ab229719e59ffe769c43720 /cider-interaction.el
parent4fd637f5640fa13bf87daaaff6c96d2b64cc3bda (diff)
Add support for printing to the current buffer to `cider-eval-defun-to-point`
This makes the command consistent with other interactive eval commands.
Diffstat (limited to 'cider-interaction.el')
-rw-r--r--cider-interaction.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/cider-interaction.el b/cider-interaction.el
index bef708cb..45953e66 100644
--- a/cider-interaction.el
+++ b/cider-interaction.el
@@ -1427,18 +1427,21 @@ incomplete expression complete."
"Compute the list of closing delimiters to make the defun before point valid."
(mapcar #'cider--matching-delimiter (cider--calculate-opening-delimiters)))
-(defun cider-eval-defun-to-point ()
+(defun cider-eval-defun-to-point (&optional output-to-current-buffer)
"Evaluate the current toplevel form up to point.
+If invoked with OUTPUT-TO-CURRENT-BUFFER, print the result in the current buffer.
It constructs an expression to eval in the following manner:
- It find the code between the point and the start of the toplevel expression;
- It balances this bit of code by closing all open expressions;
- It evaluates the resulting code using `cider-interactive-eval'."
- (interactive)
+ (interactive "P")
(let* ((beg-of-defun (save-excursion (beginning-of-defun) (point)))
(code (buffer-substring-no-properties beg-of-defun (point)))
(code (concat code (cider--calculate-closing-delimiters))))
- (cider-interactive-eval code)))
+ (cider-interactive-eval
+ code
+ (when output-to-current-buffer (cider-eval-print-handler))))
(defun cider-pprint-eval-defun-at-point (&optional output-to-current-buffer)
"Evaluate the \"top-level\" form at point and pprint its value.