ui/nav-flash: refactor

+ Avoid generating unneeded markers (relatively expensive in the long
  run).
+ Extract excluded major modes into a variable.
This commit is contained in:
Henrik Lissner 2021-03-07 14:30:42 -05:00
parent ff58823d48
commit f0d601d2ac
2 changed files with 10 additions and 5 deletions

View file

@ -19,12 +19,13 @@ jumping to another part of the file)."
vterm-mode, or triggered from one of `+nav-flash-exclude-commands'." vterm-mode, or triggered from one of `+nav-flash-exclude-commands'."
(unless (or (memq this-command +nav-flash-exclude-commands) (unless (or (memq this-command +nav-flash-exclude-commands)
(bound-and-true-p so-long-minor-mode) (bound-and-true-p so-long-minor-mode)
(derived-mode-p 'so-long-mode 'special-mode 'term-mode (apply #'derived-mode-p +nav-flash-exclude-modes)
'vterm-mode) (equal +nav-flash--last-point
(and (equal (point-marker) (car +nav-flash--last-point)) (list (selected-window)
(equal (selected-window) (cdr +nav-flash--last-point)))) (current-buffer)
(point))))
(+nav-flash-blink-cursor) (+nav-flash-blink-cursor)
(setq +nav-flash--last-point (cons (point-marker) (selected-window))))) (setq +nav-flash--last-point (list (selected-window) (current-buffer) (point)))))
;;;###autoload ;;;###autoload
(defun +nav-flash-delayed-blink-cursor-h (&rest _) (defun +nav-flash-delayed-blink-cursor-h (&rest _)

View file

@ -5,6 +5,10 @@
org-find-file org-find-file-at-mouse) org-find-file org-find-file-at-mouse)
"A list of commands that should not trigger nav-flash.") "A list of commands that should not trigger nav-flash.")
(defvar +nav-flash-exclude-modes
'(so-long-mode special-mode comint-mode term-mode vterm-mode)
"List of major modes where nav-flash won't automatically trigger.")
;; ;;
;;; Packages ;;; Packages