Skip to content

Commit 780b448

Browse files
pyridinebbatsov
authored andcommitted
Make cider-repl-closing-return complete { and [ (#1799)
It already did this for (, now we're extending this feature to all similar parenthesized expressions.
1 parent e265fc2 commit 780b448

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* Rebind `cider-eval-region` to `C-c C-v r`.
3737
* Rebind `cider-eval-ns-form` to `C-c C-v n`.
3838
* [#1577](https://github.com/clojure-emacs/cider/issues/1577): Show first line of docstring in ns browser.
39+
* `cider-repl-closing-return` (`C-<Return>`) now also completes brackets (`[]`) and curly braces (`{}`) in an expression.
3940

4041
### Bugs fixed
4142

cider-repl.el

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,13 +760,16 @@ text property `cider-old-input'."
760760
(forward-char offset))))
761761

762762
(defun cider-repl-closing-return ()
763-
"Evaluate the current input string after closing all open lists."
763+
"Evaluate the current input string after closing all open parenthesized or bracketed expressions."
764764
(interactive)
765765
(goto-char (point-max))
766766
(save-restriction
767767
(narrow-to-region cider-repl-input-start-mark (point))
768-
(while (ignore-errors (save-excursion (backward-up-list 1)) t)
769-
(insert ")")))
768+
(let ((matching-delimiter nil))
769+
(while (ignore-errors (save-excursion
770+
(backward-up-list 1)
771+
(setq matching-delimiter (cdr (syntax-after (point))))) t)
772+
(insert-char matching-delimiter))))
770773
(cider-repl-return))
771774

772775
(defun cider-repl-toggle-pretty-printing ()

0 commit comments

Comments
 (0)