Sébastien Gendre <s...@k-7.ch> writes:

> Ihor Radchenko <yanta...@posteo.net> writes:
>
>> Sebastien, would you be interested to test this? I can add a
>> complementary patch for Org that will work in tandem with this patch for
>> Emacs.
>
> I can make a test. 

Thanks!
Please
1. use the latest diff from Martin for Emacs git sources
2. Re-compile Emacs
3. Apply the attached patch to Org mode git

>From df57e6e25f843c94102ceba7c992d6bf775acb8d Mon Sep 17 00:00:00 2001
Message-ID: <df57e6e25f843c94102ceba7c992d6bf775acb8d.1739628844.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Sat, 15 Feb 2025 15:10:51 +0100
Subject: [PATCH] org-agenda-goto: Reuse visible indirect buffer window; try
 keeping narrowing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* 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 8143fd97a7..9872382c4d 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -9258,8 +9258,12 @@ (defun org-agenda-goto (&optional highlight)
 		     (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)
-- 
2.47.1

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to