mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-21 06:55:35 +00:00
org-agenda-tree-to-indirect-buffer: Obey `org-indirect-buffer-display'
* lisp/org-macs.el (org-display-buffer-in-window): New helper function
to display buffer in specific window (when it is live).
* lisp/org.el (org-tree-to-indirect-buffer): By default, reuse the
window previously used for an existing indirect buffer, if it is in
the same frame.
* lisp/org-agenda.el (org-agenda-do-tree-to-indirect-buffer): Remove.
(org-agenda-tree-to-indirect-buffer): Merge with
`org-agenda-do-tree-to-indirect-buffer' and remove special handling of
the existing indirect buffer window that overrides
`org-indirect-buffer-display'.
(org-agenda-do-context-action): Force `org-indirect-buffer-display' to
be 'other-window when displaying subtree at point in
org-agenda-follow-mode.
This patch reverts 35d6d9f50
, implementing an alternative fix for
stabilizing indirect buffer window selection. Unlike the existing
fix, it utilizes display buffer action and does not cause clashes with
custom `org-indirect-buffer-display'.
Reported-by: JV <misc@jeffvalk.com>
Link: https://orgmode.org/list/1a4c7a04-8536-40c7-899e-ba433a1252fd@jeffvalk.com
This commit is contained in:
parent
e36a4fe20e
commit
db5478108c
@ -9222,7 +9222,8 @@ When called with a prefix argument, include all archive files as well."
|
||||
(when (and (markerp m) (marker-buffer m))
|
||||
(and org-agenda-follow-mode
|
||||
(if org-agenda-follow-indirect
|
||||
(org-agenda-tree-to-indirect-buffer nil)
|
||||
(let ((org-indirect-buffer-display 'other-window))
|
||||
(org-agenda-tree-to-indirect-buffer nil))
|
||||
(org-agenda-show)))
|
||||
(and org-agenda-show-outline-path
|
||||
(org-with-point-at m (org-display-outline-path org-agenda-show-outline-path))))))
|
||||
@ -9695,27 +9696,6 @@ With a `\\[universal-argument]' prefix, make a separate frame for this tree, \
|
||||
i.e. don't use
|
||||
the dedicated frame."
|
||||
(interactive "P")
|
||||
(if current-prefix-arg
|
||||
(org-agenda-do-tree-to-indirect-buffer arg)
|
||||
(let ((agenda-buffer (buffer-name))
|
||||
(agenda-window (selected-window))
|
||||
(indirect-window
|
||||
(and org-last-indirect-buffer
|
||||
(get-buffer-window org-last-indirect-buffer))))
|
||||
(save-window-excursion (org-agenda-do-tree-to-indirect-buffer arg))
|
||||
(unless (or (eq org-indirect-buffer-display 'new-frame)
|
||||
(eq org-indirect-buffer-display 'dedicated-frame))
|
||||
(unwind-protect
|
||||
(unless (and indirect-window (window-live-p indirect-window))
|
||||
(setq indirect-window (split-window agenda-window)))
|
||||
(and indirect-window (select-window indirect-window))
|
||||
(switch-to-buffer org-last-indirect-buffer :norecord)
|
||||
(fit-window-to-buffer indirect-window)))
|
||||
(select-window (get-buffer-window agenda-buffer))
|
||||
(setq org-agenda-last-indirect-buffer org-last-indirect-buffer))))
|
||||
|
||||
(defun org-agenda-do-tree-to-indirect-buffer (arg)
|
||||
"Same as `org-agenda-tree-to-indirect-buffer' without saving window."
|
||||
(org-agenda-check-no-diary)
|
||||
(let* ((marker (or (org-get-at-bol 'org-marker)
|
||||
(org-agenda-error)))
|
||||
@ -9724,7 +9704,8 @@ the dedicated frame."
|
||||
(with-current-buffer buffer
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(org-tree-to-indirect-buffer arg)))))
|
||||
(org-tree-to-indirect-buffer arg))))
|
||||
(setq org-agenda-last-indirect-buffer org-last-indirect-buffer))
|
||||
|
||||
(defvar org-last-heading-marker (make-marker)
|
||||
"Marker pointing to the headline that last changed its TODO state
|
||||
|
@ -1790,6 +1790,23 @@ indirectly called by the latter."
|
||||
(prog1 nil
|
||||
(set-window-configuration window-configuration)))))
|
||||
|
||||
(defun org-display-buffer-in-window (buffer alist)
|
||||
"Display BUFFER in specific window.
|
||||
The window is defined according to the `window' slot in the ALIST.
|
||||
Then `same-frame' slot in the ALIST is set, only display buffer when
|
||||
window is present in the current frame.
|
||||
|
||||
This is an action function for buffer display, see Info
|
||||
node `(elisp) Buffer Display Action Functions'. It should be
|
||||
called only by `display-buffer' or a function directly or
|
||||
indirectly called by the latter."
|
||||
(let ((window (alist-get 'window alist)))
|
||||
(when (and window
|
||||
(window-live-p window)
|
||||
(or (not (alist-get 'same-frame alist))
|
||||
(eq (window-frame) (window-frame window))))
|
||||
(window--display-buffer buffer window 'reuse alist))))
|
||||
|
||||
(provide 'org-macs)
|
||||
|
||||
;; Local variables:
|
||||
|
10
lisp/org.el
10
lisp/org.el
@ -6276,7 +6276,10 @@ frame is not changed."
|
||||
(let ((cbuf (current-buffer))
|
||||
(cwin (selected-window))
|
||||
(pos (point))
|
||||
beg end level heading ibuf)
|
||||
beg end level heading ibuf
|
||||
(last-indirect-window
|
||||
(and org-last-indirect-buffer
|
||||
(get-buffer-window org-last-indirect-buffer))))
|
||||
(save-excursion
|
||||
(org-back-to-heading t)
|
||||
(when (numberp arg)
|
||||
@ -6312,7 +6315,10 @@ frame is not changed."
|
||||
((eq org-indirect-buffer-display 'current-window)
|
||||
(pop-to-buffer-same-window ibuf))
|
||||
((eq org-indirect-buffer-display 'other-window)
|
||||
(pop-to-buffer ibuf))
|
||||
(pop-to-buffer
|
||||
ibuf
|
||||
`(org-display-buffer-in-window (window . ,last-indirect-window)
|
||||
(same-frame . t))))
|
||||
(t (error "Invalid value")))
|
||||
(narrow-to-region beg end)
|
||||
(org-fold-show-all '(headings drawers blocks))
|
||||
|
Loading…
Reference in New Issue
Block a user