all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#35737: xref--original-command
@ 2019-05-14 20:53 Juri Linkov
  2019-05-15  1:07 ` Dmitry Gutov
  0 siblings, 1 reply; 17+ messages in thread
From: Juri Linkov @ 2019-05-14 20:53 UTC (permalink / raw)
  To: 35737

Remembering the command that created the *xref* buffer
will allow such customization to treat RET differently,
i.e. it makes sense for RET to quit the transient xref buffer
displayed momentarily while navigating code with xref-find-definitions,
whereas leaving the xref buffer visible while navigating matches
in the xref buffer created by e.g. project-find-regexp:

(define-key xref--button-map [(control ?m)]
  (lambda ()
    (interactive)
    (if (memq xref--original-command '(xref-find-definitions))
        (call-interactively 'xref-quit-and-goto-xref)
      (call-interactively 'xref-goto-xref))))

Better ideas?

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index bf999aeb0d..5c38cac164 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -477,6 +477,9 @@ xref--original-window-intent
 (defvar-local xref--original-window nil
   "The original window this xref buffer was created from.")
 
+(defvar-local xref--original-command nil
+  "The original command that created this xref buffer.")
+
 (defun xref--show-pos-in-buf (pos buf)
   "Goto and display position POS of buffer BUF in a window.
 Honor `xref--original-window-intent', run `xref-after-jump-hook'
@@ -777,7 +788,8 @@ xref--analyze
         (pop-to-buffer (current-buffer))
         (goto-char (point-min))
         (setq xref--original-window (assoc-default 'window alist)
-              xref--original-window-intent (assoc-default 'display-action alist))
+              xref--original-window-intent (assoc-default 'display-action alist)
+              xref--original-command this-command)
         (current-buffer)))))
 





^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-06-09 23:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-14 20:53 bug#35737: xref--original-command Juri Linkov
2019-05-15  1:07 ` Dmitry Gutov
2019-05-15 21:04   ` Juri Linkov
2019-05-15 22:30     ` Dmitry Gutov
2019-05-16 19:58       ` Juri Linkov
2019-05-24  1:59         ` Dmitry Gutov
2019-05-24 18:40           ` Juri Linkov
2019-05-24 22:48             ` Dmitry Gutov
2019-05-27 19:59               ` Juri Linkov
2019-05-27 21:13                 ` Dmitry Gutov
2019-05-27 23:21                   ` Dmitry Gutov
2019-05-28  2:41                   ` Eli Zaretskii
2019-05-28  7:46                     ` Dmitry Gutov
2019-05-28 15:01                       ` Eli Zaretskii
2019-05-28 20:30                   ` Juri Linkov
2019-05-30 17:33                     ` Dmitry Gutov
2019-06-09 23:44                     ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.