bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#70949: display-buffer-choose-some-window


From: Juri Linkov
Subject: bug#70949: display-buffer-choose-some-window
Date: Wed, 05 Jun 2024 19:48:52 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

>> The most reliable way to identify a series of related buffers
>> is to set a buffer-local variable in the origin buffer
>> to the window where outgoing buffers are displayed.
>
> How would this work in the case of 'vc-dir'?  There you have a status
> buffer whose buffer-local variable you probably want to set.  You call
> 'vc-diff' which calls 'vc-diff-internal' which eventually calls
> 'pop-to-buffer' which chooses the window of the outgoing buffer.  How
> would you set up the variable in this scenario?

The same way as the condition function allows to check
the original buffer, e.g. customization to show
outgoing 'vc-diff' buffers in the same window
where the 'vc-dir' was displayed:

  (defun display-buffer-from-vc-dir-p (_buffer-name _action)
    (with-current-buffer (window-buffer)
      (derived-mode-p '(vc-dir-mode))))

  (add-to-list 'display-buffer-alist
               '(display-buffer-from-vc-dir-p
                 display-buffer-same-window
                 (inhibit-same-window . nil)))

This means using

  (with-current-buffer (window-buffer)
    (setq-local display-buffer-previous-window (selected-window)))

after every buffer display from the original buffer.

>> Ideally, the users need to express their preference by a single alist entry.
>> For example:
>>
>>    (use-previous-window . t) -- then all outgoing buffers will be displayed
>>                                 in the same window
>>
>>    (use-mru-window . t) -- then all outgoing buffers will be displayed
>>                            in the most recently used window
>>                            instead of the default lru
>>
>> Or maybe a unified alist entry:
>>
>>    (prefer . previous-window)
>>    (prefer . mru-window)
>
> It's trivial to set up such an association for "*vc-diff*".  But what
> would you do when calling 'vc-diff' with a different BUFFER argument?
> Which kind of association would you set up for showing the next error
> buffer in compilation output?

The displayed buffer has no significance.  The buffer-local variable
will be set in the original buffer to the value of the displayed window.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]