From 7514b598cfbce6f8bc872bd49a7c4ca19d207259 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 28 Apr 2021 15:28:00 -0500 Subject: Advise `eval-region' to pulse Just like SLIME. I also rewrote acdw/eval-region-or-buffer a bit. --- init.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index a064bda..3d47b44 100644 --- a/init.el +++ b/init.el @@ -877,9 +877,10 @@ if ripgrep is installed, otherwise `consult-grep'." (defun acdw/eval-region-or-buffer () (interactive) (if (region-active-p) - (with-message (format "Evaluating %S -> %S" - (region-beginning) (region-end)) - (eval-region (region-beginning) (region-end))) + (let ((begin (region-beginning)) + (end (region-end))) + (with-message (format "Evaluating %S -> %S" begin end) + (eval-region begin end))) (with-message "Evaluating buffer" (eval-buffer)))) @@ -896,7 +897,14 @@ if ripgrep is installed, otherwise `consult-grep'." (define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand)) (setup (:straight eros) - (:hook-into emacs-lisp-mode))) + (:hook-into emacs-lisp-mode)) + + ;; Add advice to pulse evaluated regions + (defun acdw/elisp-eval-region-advice (fn start end &rest args) + (pulse-momentary-highlight-region start end) + (apply fn start end args)) + + (advice-add 'eval-region :around #'acdw/elisp-eval-region-advice)) (setup (:straight geiser)) -- cgit 1.4.1-21-gabe81