From d08f6ef980b1e6464af112f692cfdaed1a6d7256 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 31 Dec 2021 12:45:52 +0100 Subject: [PATCH 2/3] Implement context-menu-mode support for hi-lock * hi-lock.el (hi-lock-symbol-at-mouse): Add new command (hi-lock-context-menu): Add new function --- lisp/hi-lock.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index 7d126cb558..5d99fb5288 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -854,6 +854,25 @@ hi-lock-unload-function ;; continue standard unloading nil) +;;; Mouse support +(defun hi-lock-symbol-at-mouse (event) + "Highlight symbol at mouse click EVENT." + (interactive "e") + (save-excursion + (mouse-set-point event) + (highlight-symbol-at-point))) + +(defun hi-lock-context-menu (menu click) + "Populate MENU with a menu item to highlight symbol at CLICK." + (save-excursion + (mouse-set-point click) + (when (symbol-at-point) + (define-key-after menu [highlight-search-separator] menu-bar-separator) + (define-key-after menu [highlight-search-mouse] + '(menu-item "Highlight Symbol" highlight-symbol-at-mouse + :help "Highlight symbol at point")))) + menu) + (provide 'hi-lock) ;;; hi-lock.el ends here -- 2.34.0