From 1b527b10ad44ee4863e87700fb50dcfda14c72f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 23 Oct 2017 20:51:54 +0100 Subject: [PATCH 4/4] Don't quit *xref* window on RET, only on C-u RET * lisp/progmodes/xref.el (xref--show-location): Handle new 'quit value for SELECT. (xref-goto-xref): Allow prefix argument. --- lisp/progmodes/xref.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index cf9e027ba0..9dc78397eb 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -493,12 +493,15 @@ xref--show-pos-in-buf (selected-window)))) (defun xref--show-location (location &optional select) + "Helper for `xref-show-xref' and `xref-goto-xref'. +Go to LOCATION and if SELECT is non-nil select its window. If +SELECT is `quit', also quit the *xref* window." (condition-case err (let* ((marker (xref-location-marker location)) (buf (marker-buffer marker)) (xref-buffer (current-buffer))) (cond (select - (quit-window nil nil) + (if (eq select 'quit) (quit-window nil nil)) (with-current-buffer xref-buffer (select-window (xref--show-pos-in-buf marker buf)))) (t @@ -532,12 +535,13 @@ xref--item-at-point (back-to-indentation) (get-text-property (point) 'xref-item))) -(defun xref-goto-xref () - "Jump to the xref on the current line and select its window." - (interactive) +(defun xref-goto-xref (&optional quit) + "Jump to the xref on the current line and select its window. +With QUIT (the prefix argument) also quit the *xref* window." + (interactive "P") (let ((xref (or (xref--item-at-point) (user-error "No reference at point")))) - (xref--show-location (xref-item-location xref) t))) + (xref--show-location (xref-item-location xref) (if quit 'quit t)))) (defun xref-query-replace-in-results (from to) "Perform interactive replacement of FROM with TO in all displayed xrefs. -- 2.14.2