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

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

bug#74361: [PATCH] New option xref-navigation-display-window-action


From: martin rudalics
Subject: bug#74361: [PATCH] New option xref-navigation-display-window-action
Date: Thu, 5 Dec 2024 10:23:15 +0100
User-agent: Mozilla Thunderbird

> Ok.  This reminds me adding '(previous-window . WINDOW)'
> to 'display-buffer-in-previous-window' with:
>
>      (when (and previous-window (symbolp previous-window)
>                 (boundp previous-window))
>        (setq previous-window (symbol-value previous-window)))

Where and how is or would this be used?  In the sources all I see is

                          `((previous-window . ,debugger-previous-window))))))

so I suppose the symbol value would be used in customizations only.

>      (when (and (setq window previous-window)
>           (window-live-p window)
>
> Probably we should support both a symbol and a value for 'some-window'
> as well.

Where and how would this be used?

> BTW, here is an example of using 'previous-window' with an advice on
> 'window--display-buffer' that could be combined with 'some-window':
>
>    (defvar-local display-buffer-previous-window nil)
>
>    (add-to-list 'display-buffer-alist
>                 '((category . xref-jump)
>                   display-buffer-in-previous-window
>                   (previous-window . display-buffer-previous-window)

So here 'display-buffer' would retrieve the symbol-value of whatever is
in the buffer-local value of 'display-buffer-previous-window'.  Right?

>                   (inhibit-same-window . nil))
>                 ;; Append to not override display-buffer-same-window
>                 'append)
>
>    (define-advice xref-goto-xref (:around (ofun &rest args) previous-window)
>      (let ((buffer (current-buffer)))
>        (apply ofun args)
>        (with-current-buffer buffer
>          (setq-local display-buffer-previous-window (selected-window)))))

This relies on 'ofun' selecting a window and would not work for plain
'display-buffer'.  Right?

>    (define-advice window--display-buffer (:around (ofun &rest args) 
previous-window)
>      (let ((buffer (current-buffer))
>            (window (apply ofun args)))
>        (with-current-buffer buffer
>          (setq-local display-buffer-previous-window window))
>        window))

And this assumes that the current buffer is the one where to set the
variable.  Would this work with a function calling 'xref-goto-xref',
bound to a key and called interactively with an arbitrary window
selected?

martin





reply via email to

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