GNU bug report logs -
#45688
28.0.50; New action for display-buffer?
Previous Next
Reported by: Lars Ingebrigtsen <larsi <at> gnus.org>
Date: Wed, 6 Jan 2021 12:03:02 UTC
Severity: normal
Found in version 28.0.50
Fixed in version 28.1
Done: martin rudalics <rudalics <at> gmx.at>
Bug is archived. No further changes may be made.
Full log
Message #116 received at 45688 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> One problem is that other display-buffer actions don't set
> 'display-buffer-previous-window'. It would be nice to do
> this in some low-level function in window.el.
If this is impossible to add this to window.el then a workaround is
to use such advice that helps to visit grep/xref hits in the window
where all previous hits were visited:
#+begin_src emacs-lisp
(advice-add 'window--display-buffer :around
(lambda (orig-fun &rest args)
(let ((buffer (current-buffer))
(window (apply orig-fun args)))
(with-current-buffer buffer
(setq-local display-buffer-previous-window window))
window))
'((name . window--display-buffer-set-previous-window)))
(defvar-local display-buffer-previous-window nil)
(defun display-buffer-from-grep-p (_buffer-name _action)
(with-current-buffer (window-buffer)
(derived-mode-p 'compilation-mode)))
(add-to-list 'display-buffer-alist
'(display-buffer-from-grep-p
nil (previous-window . display-buffer-previous-window)))
#+end_src
The only problem is that display-buffer-in-previous-window
doesn't support 'previous-window' as a variable, only as a value,
i.e. currently it only supports:
`(previous-window . ,display-buffer-previous-window)
maybe the following patch could be installed to support also
'(previous-window . display-buffer-previous-window)
[previous-window.patch (text/x-diff, inline)]
diff --git a/lisp/window.el b/lisp/window.el
index 0a37d16273..d6b3d69b3d 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8239,6 +8239,7 @@ display-buffer-in-previous-window
0)
(display-buffer-reuse-frames 0)
(t (last-nonminibuffer-frame))))
+ (previous-window (cdr (assq 'previous-window alist)))
best-window second-best-window window)
;; Scan windows whether they have shown the buffer recently.
(catch 'best
@@ -8252,7 +8253,9 @@ display-buffer-in-previous-window
(throw 'best t)))))
;; When ALIST has a `previous-window' entry, that entry may override
;; anything we found so far.
- (when (and (setq window (cdr (assq 'previous-window alist)))
+ (when (and previous-window (boundp previous-window))
+ (setq previous-window (symbol-value previous-window)))
+ (when (and (setq window previous-window)
(window-live-p window)
(or (eq buffer (window-buffer window))
(not (window-dedicated-p window))))
This bug report was last modified 3 years and 283 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.