Skip to content

Commit 954d568

Browse files
committed
lispy-newline-and-indent-plain: support all comint-derived modes
1 parent 0eb918f commit 954d568

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

lispy.el

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,42 +2104,43 @@ When the region is active, toggle a ~ at the start of the region."
21042104
(defun lispy-newline-and-indent-plain ()
21052105
"When in minibuffer, exit it. Otherwise forward to `newline-and-indent'."
21062106
(interactive)
2107-
(if (minibufferp)
2108-
(exit-minibuffer)
2109-
(cl-case major-mode
2110-
(cider-repl-mode
2111-
(cider-repl-return))
2112-
(slime-repl-mode
2113-
(slime-repl-return))
2114-
(sly-mrepl-mode
2115-
(sly-mrepl-return))
2116-
(comint-mode
2117-
(comint-send-input))
2118-
(python-mode
2119-
(newline-and-indent))
2120-
(inferior-emacs-lisp-mode
2121-
(setq this-command 'ielm-return)
2122-
(ielm-return))
2123-
(racket-repl-mode
2124-
(racket-repl-submit))
2125-
(geiser-repl-mode
2126-
(geiser-repl-maybe-send))
2127-
(t
2128-
(if (and (not (lispy--in-string-or-comment-p))
2129-
(if (memq major-mode lispy-clojure-modes)
2130-
(lispy-looking-back "[^#`'@~][#`'@~]+")
2131-
(lispy-looking-back "[^#`',@|][#`',@]+")))
2132-
(save-excursion
2133-
(goto-char (match-beginning 0))
2134-
(newline-and-indent))
2135-
(newline-and-indent))
2136-
(let ((lispy-ignore-whitespace t))
2137-
(save-excursion
2138-
(lispy--out-backward 1)
2139-
(unless (< 50000
2140-
(- (save-excursion (forward-list 1))
2141-
(point)))
2142-
(indent-sexp))))))))
2107+
(cond ((minibufferp)
2108+
(exit-minibuffer))
2109+
((derived-mode-p 'comint-mode)
2110+
(comint-send-input))
2111+
(t
2112+
(cl-case major-mode
2113+
(cider-repl-mode
2114+
(cider-repl-return))
2115+
(slime-repl-mode
2116+
(slime-repl-return))
2117+
(sly-mrepl-mode
2118+
(sly-mrepl-return))
2119+
(python-mode
2120+
(newline-and-indent))
2121+
(inferior-emacs-lisp-mode
2122+
(setq this-command 'ielm-return)
2123+
(ielm-return))
2124+
(racket-repl-mode
2125+
(racket-repl-submit))
2126+
(geiser-repl-mode
2127+
(geiser-repl-maybe-send))
2128+
(t
2129+
(if (and (not (lispy--in-string-or-comment-p))
2130+
(if (memq major-mode lispy-clojure-modes)
2131+
(lispy-looking-back "[^#`'@~][#`'@~]+")
2132+
(lispy-looking-back "[^#`',@|][#`',@]+")))
2133+
(save-excursion
2134+
(goto-char (match-beginning 0))
2135+
(newline-and-indent))
2136+
(newline-and-indent))
2137+
(let ((lispy-ignore-whitespace t))
2138+
(save-excursion
2139+
(lispy--out-backward 1)
2140+
(unless (< 50000
2141+
(- (save-excursion (forward-list 1))
2142+
(point)))
2143+
(indent-sexp)))))))))
21432144

21442145
(defun lispy-open-line (arg)
21452146
"Add ARG lines after the current expression.

0 commit comments

Comments
 (0)