Fix incorrect newline placement on send-to-REPL

Sending this form to a REPL (like ielm):

  (defun test (n)
    ...)

Will yield:

  (defun test (n
                 ...))

Because our RET emulation doesn't take evil's off-by-one cursor
placement into account.
This commit is contained in:
Henrik Lissner 2021-03-28 00:32:27 -04:00
parent 699e18b7f1
commit c9eb00a217

View File

@ -132,9 +132,11 @@ immediately after."
(insert line)
(if inhibit-auto-execute-p
(insert "\n")
;; `comint-send-input' isn't enough because some REPLs may not use
;; comint, so just emulate the keypress.
(execute-kbd-macro (kbd "RET")))
;; Can't use `comint-send-input' b/c there's no guarantee the
;; current REPL uses comint. Even if it did, no telling if they
;; have their own `comint-send-input' wrapper, so to be safe, I
;; simply emulate the keypress.
(call-interactively (doom-lookup-key (kbd "RET"))))
(sit-for 0.001)
(redisplay 'force)))
(when (and (eq origin-window (selected-window))