branch: externals/org
commit 15226075169a6a0fbcc801863637dc6d24ea6bc8
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-agenda-goto: Reuse visible indirect buffer window; try keeping narrowing
    
    * lisp/org-agenda.el (org-agenda-goto): When jumping to agenda item,
    the item's indirect buffer is displayed, reuse it.  If the item's
    buffer is narrowed and the item position is within the narrowing, do
    not widen.
    
    Reusing indirect buffer requires Emacs support for reuse-indirect
    option in the buffer alist (see the link).
    
    Reported-by: Sébastien Gendre <s...@k-7.ch>
    Link: https://yhetil.org/emacs-devel/87msgx7yo5.fsf@localhost/
---
 lisp/org-agenda.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 2a09a6a191..6809d0ef30 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9258,8 +9258,12 @@ When called with a prefix argument, include all archive 
files as well."
                     (org-agenda-error)))
         (buffer (marker-buffer marker))
         (pos (marker-position marker)))
-    (switch-to-buffer-other-window buffer)
-    (widen)
+    (pop-to-buffer
+     buffer
+     `((display-buffer-reuse-window display-buffer-pop-up-window)
+       (reuse-indirect . buffer)))
+    (unless (<= (point-min) pos (point-max))
+      (widen))
     (push-mark)
     (goto-char pos)
     (when (derived-mode-p 'org-mode)

Reply via email to