emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f62fe2ebde 2/4: Implement context-menu-mode support for hi-lock


From: Lars Ingebrigtsen
Subject: master f62fe2ebde 2/4: Implement context-menu-mode support for hi-lock
Date: Fri, 14 Jan 2022 03:53:02 -0500 (EST)

branch: master
commit f62fe2ebde840da0bcef4899840c594b7b7d9169
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 fbd698e234..d7d98c78f8 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]