From: Dmitry Gutov <dmitry@gutov.dev>
To: 74361@debbugs.gnu.org
Cc: juri linkov <juri@linkov.net>
Subject: bug#74361: [PATCH] New option xref-navigation-display-window-action
Date: Fri, 15 Nov 2024 02:50:50 +0200 [thread overview]
Message-ID: <9e79299a-0afb-462c-9362-987f4bb12e34@gutov.dev> (raw)
In-Reply-To: <dfc132c1-2b1c-4c82-a996-098d83b31e8d@gutov.dev>
[-- Attachment #1: Type: text/plain, Size: 232 bytes --]
On 15/11/2024 00:29, Dmitry Gutov wrote:
> Comments welcome.
Here's a small revision in xref--show-pos-in-buf that allows including
ALIST elements as well - just because those are allowed in the structure
of ACTION as documented.
[-- Attachment #2: xref-navigation-display-window-action-v2.diff --]
[-- Type: text/x-patch, Size: 4007 bytes --]
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index cc06e06ef78..7d296191da8 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -431,6 +431,21 @@ xref-auto-jump-to-first-xref
:version "28.1"
:package-version '(xref . "1.2.0"))
+(defcustom xref-navigation-display-window-action nil
+ "When non-nil, the display action to use for navigation commands.
+
+The value should be nil or a buffer display action like described in
+docstring for `display-buffer'.
+
+This does not affect commands that specify the action explicitly,
+such as `xref-find-definitions-other-window'."
+ :type '(choice (const :tag "Use selected window" nil)
+ (const :tag "Reuse window showing destination or use another"
+ (display-buffer-reuse-window))
+ display-buffer--action-custom-type)
+ :version "31.1"
+ :package-version '(xref . "1.8.0"))
+
(defcustom xref-history-storage #'xref-global-history
"Function that returns xref history.
@@ -513,6 +528,11 @@ xref-push-marker-stack
;;;###autoload
(define-obsolete-function-alias 'xref-pop-marker-stack #'xref-go-back "29.1")
+(defun xref--switch-to-buffer (buf)
+ (if xref-navigation-display-window-action
+ (pop-to-buffer buf xref-navigation-display-window-action)
+ (switch-to-buffer buf)))
+
;;;###autoload
(defun xref-go-back ()
"Go back to the previous position in xref history.
@@ -523,8 +543,8 @@ xref-go-back
(user-error "At start of xref history")
(let ((marker (pop (car history))))
(xref--push-forward (point-marker))
- (switch-to-buffer (or (marker-buffer marker)
- (user-error "The marked buffer has been deleted")))
+ (xref--switch-to-buffer (or (marker-buffer marker)
+ (user-error "The marked buffer has been deleted")))
(goto-char (marker-position marker))
(set-marker marker nil nil)
(run-hooks 'xref-after-return-hook)))))
@@ -538,8 +558,8 @@ xref-go-forward
(user-error "At end of xref history")
(let ((marker (pop (cdr history))))
(xref--push-backward (point-marker))
- (switch-to-buffer (or (marker-buffer marker)
- (user-error "The marked buffer has been deleted")))
+ (xref--switch-to-buffer (or (marker-buffer marker)
+ (user-error "The marked buffer has been deleted")))
(goto-char (marker-position marker))
(set-marker marker nil nil)
(run-hooks 'xref-after-return-hook)))))
@@ -612,7 +632,7 @@ xref-pop-to-location
(xref-location-marker (xref-item-location item))))
(buf (marker-buffer marker)))
(cl-ecase action
- ((nil) (switch-to-buffer buf))
+ ((nil) (xref--switch-to-buffer buf))
(window (pop-to-buffer buf t))
(frame (let ((pop-up-frames t)) (pop-to-buffer buf t))))
(xref--goto-char marker))
@@ -683,6 +703,10 @@ xref--show-pos-in-buf
((eq xref--original-window-intent 'window)
`((xref--display-buffer-in-other-window)
(window . ,xref--original-window)))
+ (xref-navigation-display-window-action
+ (append
+ xref-navigation-display-window-action
+ `((window . ,xref--original-window))))
((and
(window-live-p xref--original-window)
(or (not (window-dedicated-p xref--original-window))
@@ -1628,6 +1652,9 @@ xref-find-definitions
Otherwise, display the list of the possible definitions in a
buffer where the user can select from the list.
+See also `xref-navigation-display-window-action' which can change
+the destination window.
+
Use \\[xref-go-back] to return back to where you invoked this command."
(interactive (list (xref--read-identifier "Find definitions of: ")))
(xref--find-definitions identifier nil))
next prev parent reply other threads:[~2024-11-15 0:50 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-14 22:29 bug#74361: [PATCH] New option xref-navigation-display-window-action Dmitry Gutov
2024-11-15 0:50 ` Dmitry Gutov [this message]
2024-11-15 7:49 ` Juri Linkov
2024-11-15 19:05 ` Dmitry Gutov
2024-11-16 19:12 ` Juri Linkov
2024-11-18 1:28 ` Dmitry Gutov
2024-11-19 18:33 ` Juri Linkov
2024-11-19 19:43 ` Dmitry Gutov
2024-11-20 7:11 ` Juri Linkov
2024-11-20 19:12 ` Dmitry Gutov
2024-11-21 7:34 ` Juri Linkov
2024-11-25 1:58 ` Dmitry Gutov
2024-11-27 1:45 ` Dmitry Gutov
2024-11-20 8:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-20 17:31 ` Juri Linkov
2024-11-20 19:10 ` Dmitry Gutov
2024-11-21 7:29 ` Juri Linkov
2024-11-20 19:08 ` Dmitry Gutov
2024-11-22 9:22 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-23 9:35 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-23 18:45 ` Juri Linkov
2024-11-23 19:16 ` Juri Linkov
2024-11-24 8:59 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-24 17:40 ` Juri Linkov
2024-11-25 9:18 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-25 17:49 ` Juri Linkov
2024-11-26 9:15 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-27 1:52 ` Dmitry Gutov
2024-11-27 8:58 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-27 13:07 ` Dmitry Gutov
2024-11-28 9:27 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-28 17:15 ` Dmitry Gutov
2024-11-28 18:32 ` Juri Linkov
2024-11-28 20:27 ` Dmitry Gutov
2024-12-04 7:35 ` Juri Linkov
2024-12-04 8:00 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-04 17:14 ` Juri Linkov
2024-12-05 9:23 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-05 17:52 ` Juri Linkov
2024-12-06 8:31 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-07 17:18 ` Juri Linkov
2024-12-08 16:55 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-05 18:08 ` Dmitry Gutov
2024-11-27 7:30 ` Juri Linkov
2024-11-27 9:00 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-20 8:36 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 12:13 ` Eli Zaretskii
2024-11-15 17:20 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 19:10 ` Dmitry Gutov
2024-11-16 8:43 ` Eli Zaretskii
2024-11-18 1:42 ` Dmitry Gutov
2024-11-18 12:25 ` Eli Zaretskii
2024-11-18 16:10 ` Dmitry Gutov
2024-11-18 17:03 ` Eli Zaretskii
2024-11-19 1:21 ` Dmitry Gutov
2024-11-19 15:33 ` Eli Zaretskii
2024-11-19 19:51 ` Dmitry Gutov
2024-11-20 12:54 ` Eli Zaretskii
2024-11-21 10:37 ` Eli Zaretskii
2024-11-21 18:01 ` Juri Linkov
2024-11-21 19:16 ` Eli Zaretskii
2024-11-21 19:39 ` Juri Linkov
2024-11-21 19:56 ` Eli Zaretskii
2024-11-22 7:29 ` Juri Linkov
2024-11-22 8:20 ` Eli Zaretskii
2024-11-23 18:25 ` Juri Linkov
2024-11-23 18:53 ` Eli Zaretskii
2024-11-23 19:14 ` Juri Linkov
2024-11-23 19:36 ` Eli Zaretskii
2024-11-24 7:34 ` Juri Linkov
2024-11-24 9:42 ` Eli Zaretskii
2024-11-25 7:28 ` Juri Linkov
2024-12-04 7:41 ` Juri Linkov
2024-11-19 18:36 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e79299a-0afb-462c-9362-987f4bb12e34@gutov.dev \
--to=dmitry@gutov.dev \
--cc=74361@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.