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: Juri Linkov
Subject: bug#74361: [PATCH] New option xref-navigation-display-window-action
Date: Wed, 04 Dec 2024 19:14:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)

>> I see no problems with this patch.  Even better would be if Martin agrees
>> to modify 'display-buffer-use-some-window' to accept a window in
>> '(some-window . WINDOW)'.
>
> He obviously agrees (provided WINDOW is a live window).

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)))
    (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.

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)
                 (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)))))

  (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))





reply via email to

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