[Top][All Lists]

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

master 17bd039: New command xref-quit-and-pop-marker-stack

From: Dmitry Gutov
Subject: master 17bd039: New command xref-quit-and-pop-marker-stack
Date: Sun, 10 Jan 2021 17:45:32 -0500 (EST)

branch: master
commit 17bd039539d22a0a2da792d3921f2c603cc2d460
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    New command xref-quit-and-pop-marker-stack
    * lisp/progmodes/xref.el (xref-quit-and-pop-marker-stack):
    New command.
    (xref--xref-buffer-mode-map): Binding for it.
 etc/NEWS               | 5 +++++
 lisp/progmodes/xref.el | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index a7a872d..7e84d69 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1343,6 +1343,11 @@ have been renamed to have "proper" public names and 
 ('xref-show-definitions-buffer' and
+*** New command 'xref-quit-and-pop-marker-stack' and a binding for it
+in Xref buffers ('M-,'). This combination is easy to press
+semi-accidentally if the user wants to go back in the middle of
+choosing the exact definition to go to, and this should do TRT.
 *** New value 'project-relative' for 'xref-file-name-display'
 If chosen, file names in *xref* buffers will be displayed relative
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index d3b6ae7..b6778de 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -663,6 +663,12 @@ means to first quit the *xref* buffer."
   (xref-goto-xref t))
+(defun xref-quit-and-pop-marker-stack ()
+  "Quit *xref* buffer, then pop the xref marker stack."
+  (interactive)
+  (quit-window)
+  (xref-pop-marker-stack))
 (defun xref-query-replace-in-results (from to)
   "Perform interactive replacement of FROM with TO in all displayed xrefs.
@@ -793,6 +799,7 @@ references displayed in the current *xref* buffer."
     (define-key map (kbd ".") #'xref-next-line)
     (define-key map (kbd ",") #'xref-prev-line)
     (define-key map (kbd "g") #'xref-revert-buffer)
+    (define-key map (kbd "M-,") #'xref-quit-and-pop-marker-stack)
 (define-derived-mode xref--xref-buffer-mode special-mode "XREF"

reply via email to

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