Skip to content

Commit d445ffc

Browse files
ak-corambbatsov
authored andcommitted
[Fix #2023] Make popup-buffer sexp indentation optional (#2038)
- Add optional inhibit-indent argument to cider-emit-into-popup-buffer. - Inhibit indentation where output is already indented (pprint) or not sexps.
1 parent 2dafa65 commit d445ffc

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

cider-interaction.el

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -806,15 +806,18 @@ COMMENT-PREFIX is the comment prefix to use."
806806
"Make a handler for evaluating and printing stdout/stderr in popup BUFFER.
807807
808808
This is used by pretty-printing commands and intentionally discards their results."
809-
(nrepl-make-response-handler (or buffer (current-buffer))
810-
'()
811-
;; stdout handler
812-
(lambda (buffer str)
813-
(cider-emit-into-popup-buffer buffer (ansi-color-apply str)))
814-
;; stderr handler
815-
(lambda (buffer str)
816-
(cider-emit-into-popup-buffer buffer (ansi-color-apply str)))
817-
'()))
809+
(cl-flet ((popup-output-handler (buffer str)
810+
(cider-emit-into-popup-buffer buffer
811+
(ansi-color-apply str)
812+
nil
813+
t)))
814+
(nrepl-make-response-handler (or buffer (current-buffer))
815+
'()
816+
;; stdout handler
817+
#'popup-output-handler
818+
;; stderr handler
819+
#'popup-output-handler
820+
'())))
818821

819822
(defun cider-visit-error-buffer ()
820823
"Visit the `cider-error-buffer' (usually *cider-error*) if it exists."
@@ -1483,7 +1486,7 @@ Defaults to the current ns. With prefix arg QUERY, prompts for a ns."
14831486
"Refresh LOG-BUFFER with RESPONSE."
14841487
(nrepl-dbind-response response (out err reloading status error error-ns after before)
14851488
(cl-flet* ((log (message &optional face)
1486-
(cider-emit-into-popup-buffer log-buffer message face))
1489+
(cider-emit-into-popup-buffer log-buffer message face t))
14871490

14881491
(log-echo (message &optional face)
14891492
(log message face)
@@ -1577,7 +1580,10 @@ refresh functions (defined in `cider-refresh-before-fn' and
15771580
(when cider-refresh-show-log-buffer
15781581
(cider-popup-buffer-display log-buffer))
15791582
(when inhibit-refresh-fns
1580-
(cider-emit-into-popup-buffer log-buffer "inhibiting refresh functions\n"))
1583+
(cider-emit-into-popup-buffer log-buffer
1584+
"inhibiting refresh functions\n"
1585+
nil
1586+
t))
15811587
(when clear?
15821588
(cider-nrepl-send-sync-request '("op" "refresh-clear") conn))
15831589
(cider-nrepl-send-request

cider-popup.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ and automatically removed when killed."
103103
nil 'local))
104104
(current-buffer)))
105105

106-
(defun cider-emit-into-popup-buffer (buffer value &optional face)
107-
"Emit into BUFFER the provided VALUE optionally using FACE."
106+
(defun cider-emit-into-popup-buffer (buffer value &optional face inhibit-indent)
107+
"Emit into BUFFER the provided VALUE optionally using FACE.
108+
Indents emitted sexp value unless INHIBIT-INDENT is specified and non-nil."
108109
;; Long string output renders Emacs unresponsive and users might intentionally
109110
;; kill the frozen popup buffer. Therefore, we don't re-create the buffer and
110111
;; silently ignore the output.
@@ -121,7 +122,8 @@ and automatically removed when killed."
121122
(add-face-text-property 0 (length value-str) face nil value-str)
122123
(add-text-properties 0 (length value-str) (list 'face face) value-str)))
123124
(insert value-str))
124-
(indent-sexp)
125+
(unless inhibit-indent
126+
(indent-sexp))
125127
(set-marker cider-popup-output-marker (point)))
126128
(when moving (goto-char cider-popup-output-marker))))))
127129

0 commit comments

Comments
 (0)