Michael Heerdegen <michael_heerde...@web.de> writes:

>> Please, do try to follow
>> https://orgmode.org/manual/Feedback.html#Feedback and provide detailed
>> steps showing how to reproduce the problem you are seeing without your
>> personal config.
>
> This will be a lot of work.  I really hope we can avoid it.

One way or another I need a reproducer to test whether any given fix
makes sense.

Now, I created one.

1. emacs -Q
2. Open the attached org file
3. M-x org-agenda < a RET
4. Move to the week of items
5. Move point to "Sunday"
6. f
7. Observe buffer being scrolled all the way up

> What I am seeing is what one sees for any window showing a sufficiently
> large buffer after evaluating something like
>
>   (setf (window-start) (+ 10 (point-max)))

Thanks! That did help to create a reproducer.

Please try the attached patch.
Let me know if it fixes things on your side.

>From c3bc1954b7b0427b2ab9f7563c960841c1410a55 Mon Sep 17 00:00:00 2001
Message-ID: <c3bc1954b7b0427b2ab9f7563c960841c1410a55.1736606174.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Sat, 11 Jan 2025 15:33:31 +0100
Subject: [PATCH] org-agenda-later: Avoid scrolling the window past point

* lisp/org-agenda.el (org-agenda-later): When previous agenda buffer
is larger and its scroll position is beyond point position in the new
agenda buffer, do not try to restore scroll state.  (Doing otherwise,
scrolls past the point, leading to unpredictable results - depending
on `scroll-conservatively'.

Reported-by: Michael Heerdegen <michael_heerde...@web.de>
Link: https://orgmode.org/list/87ttadqati....@web.de
---
 lisp/org-agenda.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 884b9de782..2bab159795 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -8789,7 +8789,8 @@ (defun org-agenda-later (arg)
 	   (list (car args) sd span)))
       (org-agenda-redo)
       (org-agenda-find-same-or-today-or-agenda cnt))
-    (set-window-start nil wstart)))
+    (unless (< (point) wstart) ; do no scroll past the point
+      (set-window-start nil wstart))))
 
 (defun org-agenda-earlier (arg)
   "Go backward in time by the current span in the agenda buffer.
-- 
2.47.1

Attachment: bug.org
Description: Lotus Organizer

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