tools/eval: fix eval-and-replace not first clearing selection
This commit is contained in:
parent
ec240d0bfa
commit
31ed6fdf2b
1 changed files with 16 additions and 0 deletions
|
@ -23,6 +23,22 @@
|
||||||
(advice-add #'quickrun :before #'+eval*quickrun-auto-close)
|
(advice-add #'quickrun :before #'+eval*quickrun-auto-close)
|
||||||
(advice-add #'quickrun-region :before #'+eval*quickrun-auto-close)
|
(advice-add #'quickrun-region :before #'+eval*quickrun-auto-close)
|
||||||
|
|
||||||
|
(defun +eval*quickrun--outputter-replace-region ()
|
||||||
|
"Make `quickrun-replace-region' recognize evil visual selections."
|
||||||
|
(let ((output (buffer-substring-no-properties (point-min) (point-max))))
|
||||||
|
(with-current-buffer quickrun--original-buffer
|
||||||
|
(cl-destructuring-bind (beg . end)
|
||||||
|
;; Because `deactivate-mark', the function, was used in
|
||||||
|
;; `quickrun--region-command-common' instead of `deactivate-mark',
|
||||||
|
;; the variable, the selection is disabled by this point.
|
||||||
|
(if (bound-and-true-p evil-local-mode)
|
||||||
|
(cons evil-visual-beginning evil-visual-end)
|
||||||
|
(cons (region-beginning) (region-end)))
|
||||||
|
(delete-region beg end)
|
||||||
|
(insert output))
|
||||||
|
(setq quickrun-option-outputter quickrun--original-outputter))))
|
||||||
|
(advice-add #'quickrun--outputter-replace-region :override #'+eval*quickrun--outputter-replace-region)
|
||||||
|
|
||||||
(defun +eval|quickrun-shrink-window ()
|
(defun +eval|quickrun-shrink-window ()
|
||||||
"Shrink the quickrun output window once code evaluation is complete."
|
"Shrink the quickrun output window once code evaluation is complete."
|
||||||
(when-let* ((win (get-buffer-window quickrun--buffer-name)))
|
(when-let* ((win (get-buffer-window quickrun--buffer-name)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue