GNU bug report logs -
#33870
27.0.50; xref-goto-xref not configurable
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Tue, 25 Dec 2018 20:53:01 UTC
Severity: minor
Found in version 27.0.50
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
Message #59 received at 33870 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi João
> Any simplification to the implementation that keeps the
> "keep original window intent" behavior across xref
> intermediate buffers is very welcome.
Thanks for the explanation. Now I understand better the intent in
xref--show-pos-in-buf. Generally, I'd like to see the “keep original
window intent” behavior in more places, e.g. in *Occur*, *grep*, etc.
Based on your explanation, I've been able to write the patch that does
the following:
1. simplifies ‘xref--show-pos-in-buf’ while at the same time
preserves the current behavior and respects user's customization
of display actions;
2. makes the xref buffer non-obtrusive like *Completions*
in xref--show-xref-buffer;
3. turns the existing arg QUIT of xref-goto-xref into a prefix arg,
so a natural key sequence ‘C-u RET’ will quit the window.
This is similar to the prefix arg of quit-window.
[xref.el.patch (text/x-diff, inline)]
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 87ce2299c5..a166f8299c 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -482,19 +482,9 @@ xref--show-pos-in-buf
(window-live-p xref--original-window)
(or (not (window-dedicated-p xref--original-window))
(eq (window-buffer xref--original-window) buf)))
- `(,(lambda (buf _alist)
- (set-window-buffer xref--original-window buf)
- xref--original-window))))))
- (with-selected-window
- (with-selected-window
- ;; Just before `display-buffer', place ourselves in the
- ;; original window to suggest preserving it. Of course, if
- ;; user has deleted the original window, all bets are off,
- ;; just use the selected one.
- (or (and (window-live-p xref--original-window)
- xref--original-window)
- (selected-window))
- (display-buffer buf action))
+ `(,(lambda (buf alist)
+ (window--display-buffer buf xref--original-window 'reuse alist)))))))
+ (with-selected-window (display-buffer buf action)
(xref--goto-char pos)
(run-hooks 'xref-after-jump-hook)
(let ((buf (current-buffer)))
@@ -548,9 +538,8 @@ xref--item-at-point
(defun xref-goto-xref (&optional quit)
"Jump to the xref on the current line and select its window.
-Non-interactively, non-nil QUIT means to first quit the *xref*
-buffer."
- (interactive)
+A prefix arg QUIT means to first quit the *xref* buffer."
+ (interactive "P")
(let* ((buffer (current-buffer))
(xref (or (xref--item-at-point)
(user-error "No reference at point")))
@@ -782,7 +771,17 @@ xref--show-xref-buffer
(erase-buffer)
(xref--insert-xrefs xref-alist)
(xref--xref-buffer-mode)
- (pop-to-buffer (current-buffer))
+ (pop-to-buffer
+ (current-buffer)
+ `((display-buffer--maybe-same-window
+ display-buffer-reuse-window
+ display-buffer--maybe-pop-up-frame
+ display-buffer-below-selected)
+ ,(if temp-buffer-resize-mode
+ '(window-height . resize-temp-buffer-window)
+ '(window-height . fit-window-to-buffer))
+ ,(when temp-buffer-resize-mode
+ '(preserve-size . (nil . t)))))
(goto-char (point-min))
(setq xref--original-window (assoc-default 'window alist)
xref--original-window-intent (assoc-default 'display-action alist))
This bug report was last modified 6 years and 35 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.