Michael Heerdegen <michael_heerde...@web.de> writes: > Ihor Radchenko <yanta...@posteo.net> writes: > >> + (unless (< (point) wstart) ; do no scroll past the point >> + (set-window-start nil wstart)))) > > Thanks. > > Hmmm - don't we have the same problem when (point) > (window-end)? And > this case is nastier, since exact window-end calculation needs a > redisplay. We might introduce a flicker when trying to fix it.
Right. What about the attached patch? > Since line lengths differ, we are currently setting window-start to a > random line, to some degree. (And I think window-start should better be > set to the beginning of line). I believe that Emacs redisplay should take care about this automatically. > One step back: What problem does this hack solve? Org already remembers > the unit number of the time period point is in, and restores that: with > point in a Wednesday, the new view will have point set to the beginning > of the next Wednesday. The display engine ensures that point is > made visible. https://orgmode.org/list/87lfh2hk4k....@gmail.com/ > How about something like this? > > - If point is at bob, we ensure that point is restored at bob - and > likewise for eob. > > - When bob was visible in the prior view, we use window-start = 1 > for the new view, too > > - But when bob was not visible in the last view, we try to restore the > visible line number containing the window point, so that hitting f > will show the cursor at the same vertical position as in the last > view. Or maybe better: restore the vertical position of the > beginning of the weekday point was in. I hope that my idea in the patch is good enough and that we do not need to go into redisplay complications.
>From 3a4eb4837aecd924a355645473d8d335dfec6caa Mon Sep 17 00:00:00 2001 Message-ID: <3a4eb4837aecd924a355645473d8d335dfec6caa.1736668180.git.yanta...@posteo.net> From: Ihor Radchenko <yanta...@posteo.net> Date: Sat, 11 Jan 2025 15:33:31 +0100 Subject: [PATCH v2] 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 puts point outside the screen, 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 884b9de782..8143fd97a7 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -8789,7 +8789,7 @@ (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))) + (set-window-start nil wstart 'noforce))) (defun org-agenda-earlier (arg) "Go backward in time by the current span in the agenda buffer. -- 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>