diff --git a/modules/tools/eval/config.el b/modules/tools/eval/config.el index 5f07e9545..4f91ce013 100644 --- a/modules/tools/eval/config.el +++ b/modules/tools/eval/config.el @@ -23,6 +23,22 @@ (advice-add #'quickrun :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 () "Shrink the quickrun output window once code evaluation is complete." (when-let* ((win (get-buffer-window quickrun--buffer-name)))