Simplify "lst:flash-line-around-point"

This commit is contained in:
Gerard Vermeulen 2024-06-12 16:43:12 +02:00
parent 9722833400
commit cbfab437b1

View File

@ -5968,23 +5968,19 @@ point movements visually.
#+caption: Implement =flash-line-around-point=. #+caption: Implement =flash-line-around-point=.
#+name: lst:flash-line-around-point #+name: lst:flash-line-around-point
#+begin_src emacs-lisp -n :results silent #+begin_src emacs-lisp -n :results silent
;; Ensure loading `pulse' with the dynamic variables `pulse-delay' and ;; https://karthinks.com/software/batteries-included-with-emacs/
;; `pulse-iterations' before masking them lexically instead of after ;; https://github.com/karthink/.emacs.d/blob/master/init.el#L2077
;; to prevent the warning triggered by lazy loading. (defun flash-line-around-point (&rest _)
(when (require 'pulse nil 'noerror)
;; https://karthinks.com/software/batteries-included-with-emacs/
;; https://github.com/karthink/.emacs.d/blob/master/init.el#L2077
(defun flash-line-around-point (&rest _)
"Flash the line around point." "Flash the line around point."
(let ((pulse-iterations 16) (let ((pulse-iterations 16)
(pulse-delay 0.1)) (pulse-delay 0.1))
(pulse-momentary-highlight-one-line (point)))) (pulse-momentary-highlight-one-line (point))))
(dolist (command '(scroll-up-command (dolist (command '(scroll-up-command
scroll-down-command scroll-down-command
recenter-top-bottom recenter-top-bottom
other-window)) other-window))
(advice-add command :after #'flash-line-around-point))) (advice-add command :after #'flash-line-around-point))
#+end_src #+end_src
* Applications * Applications