[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 6993d45 4/6: Add "Find References" to context menu (bug#50067)
From: |
Mattias Engdegård |
Subject: |
master 6993d45 4/6: Add "Find References" to context menu (bug#50067) |
Date: |
Sat, 21 Aug 2021 06:56:44 -0400 (EDT) |
branch: master
commit 6993d45e519ad7504adcf5a00842114ce8b25110
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>
Add "Find References" to context menu (bug#50067)
The new entry appears next to "Find Definition" and like it only
appears when the context menu was invoked on an identifier.
* lisp/progmodes/prog-mode.el (prog-context-menu): New menu entry.
* lisp/progmodes/xref.el (xref-find-references-at-mouse): New
function, analogous to `xref-find-definitions-at-mouse`.
---
lisp/progmodes/prog-mode.el | 12 ++++++++++--
lisp/progmodes/xref.el | 14 ++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 4f000d6..3babbdc 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -52,13 +52,21 @@
(mouse-set-point last-input-event)
(xref-backend-identifier-at-point
(xref-find-backend)))
- :help "Find definition of function or variable")
+ :help "Find definition of identifier")
'prog-separator)
+ (define-key-after menu [xref-find-ref]
+ '(menu-item "Find References" xref-find-references-at-mouse
+ :visible (save-excursion
+ (mouse-set-point last-input-event)
+ (xref-backend-identifier-at-point
+ (xref-find-backend)))
+ :help "Find references to identifier")
+ 'xref-find-def)
(define-key-after menu [xref-pop]
'(menu-item "Back Definition" xref-pop-marker-stack
:visible (not (xref-marker-stack-empty-p))
:help "Back to the position of the last search")
- 'xref-find-def)
+ 'xref-find-ref)
menu)
(defvar prog-mode-map
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 32fe6b6..a8bab47 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1355,6 +1355,20 @@ This command is intended to be bound to a mouse event."
(xref-find-definitions identifier)
(user-error "No identifier here"))))
+;;;###autoload
+(defun xref-find-references-at-mouse (event)
+ "Find references to the identifier at or around mouse click.
+This command is intended to be bound to a mouse event."
+ (interactive "e")
+ (let ((identifier
+ (save-excursion
+ (mouse-set-point event)
+ (xref-backend-identifier-at-point (xref-find-backend)))))
+ (if identifier
+ (let ((xref-prompt-for-identifier nil))
+ (xref-find-references identifier))
+ (user-error "No identifier here"))))
+
(declare-function apropos-parse-pattern "apropos" (pattern))
;;;###autoload
- master updated (20e32f3 -> f415956), Mattias Engdegård, 2021/08/21
- master 4d6e770 2/6: Re-type the :location slot in `xref-match-item` to `xref-location`, Mattias Engdegård, 2021/08/21
- master 6993d45 4/6: Add "Find References" to context menu (bug#50067),
Mattias Engdegård <=
- master b483090 3/6: Indicate progress while searching for references in xref, Mattias Engdegård, 2021/08/21
- master 49435be 1/6: Add xref operations to context menu unconditionally, Mattias Engdegård, 2021/08/21
- master f415956 6/6: Remove default "Select" title from NS popup menus (bug#50067), Mattias Engdegård, 2021/08/21
- master d6ad208 5/6: Use overlay arrow to indicate current *xref* selection, Mattias Engdegård, 2021/08/21