summaryrefslogtreecommitdiff
path: root/lisp/hi-lock.el
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2021-12-31 12:45:52 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2022-01-14 09:46:59 +0100
commitf62fe2ebde840da0bcef4899840c594b7b7d9169 (patch)
tree8961a429b6dba6a80765fee876c1c7685dc27964 /lisp/hi-lock.el
parentdf44b2d956d1a658c51c558857cdc6d0b2e30572 (diff)
downloademacs-f62fe2ebde840da0bcef4899840c594b7b7d9169.tar.gz
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
Diffstat (limited to 'lisp/hi-lock.el')
-rw-r--r--lisp/hi-lock.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index fbd698e234a..d7d98c78f86 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -854,6 +854,25 @@ SPACES-REGEXP is a regexp to substitute spaces in font-lock search."
;; 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