diff --git a/init.example.el b/init.example.el index 7d9ae798d..dd413afc6 100644 --- a/init.example.el +++ b/init.example.el @@ -53,6 +53,7 @@ doom-modeline ; a snazzy Atom-inspired mode-line doom-quit ; DOOM quit-message prompts when you quit Emacs hl-todo ; highlight TODO/FIXME/NOTE tags + nav-flash ; blink the current line after jumping :tools dired ; making dired pretty [functional] diff --git a/modules/ui/doom/README.org b/modules/ui/doom/README.org index d6eb2dca1..bc5077361 100644 --- a/modules/ui/doom/README.org +++ b/modules/ui/doom/README.org @@ -8,7 +8,6 @@ By default, this module uses: + [[https://github.com/mozilla/Fira][Fira Mono and Fira Sans]] (fonts) + [[https://dejavu-fonts.github.io/][DejaVu Sans Mono]] (font, for displaying unicode characters) -+ [[https://github.com/rolandwalker/nav-flash][nav-flash]]: blinks the current line when jumping large distances, to help keep track of the cursor. + ~hideshow~, modified to use a nicer folded-region indicator. + Custom fringe bitmaps for ~git-gutter-fringe~ (thin bars) diff --git a/modules/ui/doom/config.el b/modules/ui/doom/config.el index 21daf64f9..04045e7c3 100644 --- a/modules/ui/doom/config.el +++ b/modules/ui/doom/config.el @@ -96,44 +96,6 @@ (add-hook 'doom-popup-mode-hook #'+doom|neotree-fix-popup nil t))) -;; Flashes the line around the cursor after any motion command that might -;; reasonably send the cursor somewhere the eyes can't follow. Tremendously -;; helpful on a 30" 2560x1600 display. -(def-package! nav-flash - :commands nav-flash-show - :init - (defun +doom*blink-cursor-maybe (orig-fn &rest args) - "Blink current line if the window has moved." - (interactive) - (let ((point (save-excursion (goto-char (window-start)) - (point-marker)))) - (apply orig-fn args) - (unless (equal point - (save-excursion (goto-char (window-start)) - (point-marker))) - (+doom/blink-cursor)))) - - (defun +doom/blink-cursor (&rest _) - "Blink current line using `nav-flash'." - (interactive) - (unless (minibufferp) - (nav-flash-show) - ;; only show in the current window - (overlay-put compilation-highlight-overlay 'window (selected-window)))) - - ;; NOTE In :feature jump `recenter' is hooked to a bunch of jumping commands, - ;; which will trigger nav-flash. - - (add-hook 'focus-in-hook #'+doom/blink-cursor) - (advice-add #'windmove-do-window-select :around #'+doom*blink-cursor-maybe) - (advice-add #'recenter :around #'+doom*blink-cursor-maybe) - - (after! evil - (advice-add #'evil-window-top :after #'+doom/blink-cursor) - (advice-add #'evil-window-middle :after #'+doom/blink-cursor) - (advice-add #'evil-window-bottom :after #'+doom/blink-cursor))) - - (after! hideshow (defface +doom-folded-face `((((background dark)) diff --git a/modules/ui/doom/packages.el b/modules/ui/doom/packages.el index 3ef1f6717..1fb43ac09 100644 --- a/modules/ui/doom/packages.el +++ b/modules/ui/doom/packages.el @@ -2,5 +2,4 @@ ;;; ui/doom/packages.el (package! doom-themes) -(package! nav-flash) diff --git a/modules/ui/nav-flash/README.org b/modules/ui/nav-flash/README.org new file mode 100644 index 000000000..416098161 --- /dev/null +++ b/modules/ui/nav-flash/README.org @@ -0,0 +1,21 @@ +* :ui nav-flash + +This module uses ~nav-flash~ to flash the line around the cursor after any motion command that might reasonably send the cursor somewhere the eyes can't follow. + +#+begin_quote +Tremendously helpful on a 30" 2560x1600 display. +#+end_quote + +** Install +This module has no other dependencies. + +** Configure +By default, ~nav-flash~ will be triggered whenever ~recenter~ is called. =:feature jump= attaches ~recenter~ to various hooks: + +#+BEGIN_SRC emacs-lisp +(add-hook! + '(imenu-after-jump-hook evil-jumps-post-jump-hook + counsel-grep-post-action-hook dumb-jump-after-jump-hook) + #'recenter) +#+END_SRC + diff --git a/modules/ui/nav-flash/config.el b/modules/ui/nav-flash/config.el new file mode 100644 index 000000000..beda38557 --- /dev/null +++ b/modules/ui/nav-flash/config.el @@ -0,0 +1,35 @@ +;;; ui/nav-flash/config.el + +(def-package! nav-flash + :commands nav-flash-show + :init + (defun +doom*blink-cursor-maybe (orig-fn &rest args) + "Blink current line if the window has moved." + (let ((point (save-excursion (goto-char (window-start)) + (point-marker)))) + (apply orig-fn args) + (unless (equal point + (save-excursion (goto-char (window-start)) + (point-marker))) + (+doom/blink-cursor)))) + + (defun +doom/blink-cursor (&rest _) + "Blink current line using `nav-flash'." + (interactive) + (unless (minibufferp) + (nav-flash-show) + ;; only show in the current window + (overlay-put compilation-highlight-overlay 'window (selected-window)))) + + ;; NOTE In :feature jump `recenter' is hooked to a bunch of jumping commands, + ;; which will trigger nav-flash. + + (advice-add #'windmove-do-window-select :around #'+doom*blink-cursor-maybe) + (advice-add #'recenter :around #'+doom*blink-cursor-maybe) + + (after! evil + (advice-add #'evil-window-top :after #'+doom/blink-cursor) + (advice-add #'evil-window-middle :after #'+doom/blink-cursor) + (advice-add #'evil-window-bottom :after #'+doom/blink-cursor))) + + diff --git a/modules/ui/nav-flash/packages.el b/modules/ui/nav-flash/packages.el new file mode 100644 index 000000000..5dfdcaf5b --- /dev/null +++ b/modules/ui/nav-flash/packages.el @@ -0,0 +1,4 @@ +;; -*- no-byte-compile: t; -*- +;;; ui/nav-flash/packages.el + +(package! nav-flash)