From a345b5a72d86aa26da0a7dd90919627ea77cf237 Mon Sep 17 00:00:00 2001 From: Madeleine Sydney Date: Sun, 2 Feb 2025 14:51:04 -0700 Subject: [PATCH] feat(emacs): Run `:nohl` on ESC --- users/crumb/programs/emacs/modules/syd-evil.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/users/crumb/programs/emacs/modules/syd-evil.el b/users/crumb/programs/emacs/modules/syd-evil.el index 509a3d6..8b9d5e8 100755 --- a/users/crumb/programs/emacs/modules/syd-evil.el +++ b/users/crumb/programs/emacs/modules/syd-evil.el @@ -49,6 +49,17 @@ ;; the echo area. (evil-ex-define-cmd "mes[sages]" #'view-echo-area-messages) + ;; On ESC, remove highlighted search results. + (defun syd-evil-nohl-h () + "If any Evil Ex search highlightings are active, remove them and return t. +Otherwise, nil." + (let ((names '(evil-ex-substitute evil-ex-search))) + (if (-any #'evil-ex-hl-active-p names) + (progn (evil-ex-nohighlight) + t) + nil))) + (add-hook 'syd-escape-hook #'syd-evil-nohl-h) + (evil-mode 1)) (defvar evil-collection-key-blacklist)