emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c477f20: Add mouse interaction to xref


From: Dmitry Gutov
Subject: [Emacs-diffs] master c477f20: Add mouse interaction to xref
Date: Sun, 04 Jan 2015 23:45:43 +0000

branch: master
commit c477f2073018ed4deb3810059c1032c1709164fa
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Add mouse interaction to xref
    
    * lisp/progmodes/xref.el (xref--button-map): New variable.
    (xref--mouse-2): New command.
    (xref--insert-xrefs): Add `mouse-face' and `keymap' properties to
    the inserted references.
---
 lisp/ChangeLog         |    9 +++++++++
 lisp/progmodes/xref.el |   19 ++++++++++++++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f62dc07..f413526 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2015-01-04  Dmitry Gutov  <address@hidden>
+
+       Add mouse interaction to xref.
+
+       * progmodes/xref.el (xref--button-map): New variable.
+       (xref--mouse-2): New command.
+       (xref--insert-xrefs): Add `mouse-face' and `keymap' properties to
+       the inserted references.
+
 2015-01-04  Paul Eggert  <address@hidden>
 
        Less 'make' chatter for lisp dir
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 7bc6500..41b70c7 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -405,6 +405,21 @@ WINDOW controls how the buffer is displayed:
 (defconst xref-buffer-name "*xref*"
   "The name of the buffer to show xrefs.")
 
+(defvar xref--button-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [(control ?m)] #'xref-goto-xref)
+    (define-key map [mouse-1] #'xref-goto-xref)
+    (define-key map [mouse-2] #'xref--mouse-2)
+    map))
+
+(defun xref--mouse-2 (event)
+  "Move point to the button and show the xref definition."
+  (interactive "e")
+  (mouse-set-point event)
+  (forward-line 0)
+  (xref--search-property 'xref-location)
+  (xref-show-location-at-point))
+
 (defun xref--insert-xrefs (xref-alist)
   "Insert XREF-ALIST in the current-buffer.
 XREF-ALIST is of the form ((GROUP . (XREF ...)) ...).  Where
@@ -417,7 +432,9 @@ GROUP is a string for decoration purposes and XREF is an
                     (with-slots (description location) xref
                       (xref--insert-propertized
                        (list 'xref-location location
-                             'face 'font-lock-keyword-face)
+                             'face 'font-lock-keyword-face
+                             'mouse-face 'highlight
+                             'keymap xref--button-map)
                        description))
                     (when (or more1 more2)
                       (insert "\n")))))



reply via email to

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