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
View this message in rfc822 format
>> We're asking too much from 'display-buffer' here. It can't second-guess
>> a user's intentions in particular with the interpretation of grep and
>> xref hits. I see three basic patterns here:
>
> I'm wondering whether there should be a separate
> `display-buffer-command' that's bound to `C-x 4 C-o' with its own
> display rules. :-) That is, when the user is using this command
> explicitly, then it's not obvious that the user wants the same rules as
> with the "automatic" display-buffer stuff (popping from *grep* buffers
> and the like).
Currently I'm using windmove-display-* group of commands to
instruct display-buffer where I want to display the buffer, e.g.:
's-<down> C-o' to open a grep/xref hit in the bottom window,
's-<left> C-o' to open a grep/xref hit in the left window, etc.
It's quite tedious to type that prefix before every key that
visits a grep hit. What is still missing is some kind of DWIM
to make display-buffer smarter.
Here is what seems to work to visit grep/xref hits in the same window
where all previous hits were visited:
#+begin_src emacs-lisp
(defun display-buffer-from-grep-p (_buffer-name _action)
(with-current-buffer (window-buffer)
(derived-mode-p 'compilation-mode)))
(push '(display-buffer-from-grep-p display-buffer-reuse-previous-window)
display-buffer-alist)
(defvar-local display-buffer-previous-window nil)
(defun display-buffer-reuse-previous-window (buffer alist)
"Display BUFFER in the same window that was already used as destination."
(let ((window display-buffer-previous-window))
(if (window-live-p window)
(window--display-buffer buffer window 'reuse alist)
(setq window (display-buffer-use-some-window
buffer (cons (cons 'inhibit-same-window t) alist)))
(setq-local display-buffer-previous-window window)
window)))
#+end_src
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.
This bug report was last modified 3 years and 300 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.