tools/eval: send to repl (via gr) by line #2056
This commit is contained in:
parent
4dc3f0956a
commit
f54d7a15cd
1 changed files with 24 additions and 8 deletions
|
@ -115,11 +115,27 @@ immediately after."
|
||||||
(buffer (+eval--ensure-in-repl-buffer)))
|
(buffer (+eval--ensure-in-repl-buffer)))
|
||||||
(unless buffer
|
(unless buffer
|
||||||
(error "No REPL open"))
|
(error "No REPL open"))
|
||||||
(with-selected-window (get-buffer-window buffer)
|
(let ((origin-window (selected-window))
|
||||||
(when (bound-and-true-p evil-local-mode)
|
(selection
|
||||||
(call-interactively #'evil-append-line))
|
(with-temp-buffer
|
||||||
(insert (string-trim selection))
|
(insert selection)
|
||||||
(unless inhibit-auto-execute-p
|
(goto-char (point-min))
|
||||||
;; `comint-send-input' isn't enough because some REPLs may not use
|
(when (> (skip-chars-forward "\n") 0)
|
||||||
;; comint, so just emulate the keypress.
|
(delete-region (point-min) (point)))
|
||||||
(execute-kbd-macro (kbd "RET"))))))
|
(indent-rigidly (point) (point-max)
|
||||||
|
(- (skip-chars-forward " \t")))
|
||||||
|
(string-trim-right (buffer-string)))))
|
||||||
|
(with-selected-window (get-buffer-window buffer)
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(dolist (line (split-string selection "\n"))
|
||||||
|
(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")))
|
||||||
|
(sit-for 0.001)
|
||||||
|
(redisplay 'force)))
|
||||||
|
(when (and (eq origin-window (selected-window))
|
||||||
|
(bound-and-true-p evil-local-mode))
|
||||||
|
(call-interactively #'evil-append-line))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue