unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* save-restriction doesn't restore scroll
@ 2024-03-24 11:20 Psionic K
  2024-03-25 12:55 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 2+ messages in thread
From: Psionic K @ 2024-03-24 11:20 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: Ihor Radchenko

I came across a case where `save-restriction' can leave the window scrolled
to a new location.

To reproduce the behavior, try `org-babel-execute-subtree'.  The ending
scroll state will leave the subtree at the window start.

I believe this is due to babel writing results but didn't dig deeper for
this simple reasoning:

`save-restriction' is very, very likely to result in some kind of scrolling
either before or after the narrowing, so this macro's behavior should just
assume that it always needs to restore the scroll state in addition to the
narrowing state.  I can't think of a use case where the window's scroll
state would be intentionally modified in the body of `save-restriction`.
Whatever scrolling occurs during the temporary restriction state is likely
to be invalid and not what the user intended via their auto-scrolling
configuration.

The workaround for interactive cases is easy enough, using
`set-window-start', but this is likely incorrect for cases where the buffer
is not currently displayed?

Unless I'm missing something, consider this a bug report.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: save-restriction doesn't restore scroll
  2024-03-24 11:20 save-restriction doesn't restore scroll Psionic K
@ 2024-03-25 12:55 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-03-25 12:55 UTC (permalink / raw)
  To: help-gnu-emacs

> I came across a case where `save-restriction' can leave the window
> scrolled to a new location.

It's not the responsability of `save-restriction` to "restore
scrolling" of some window.  It doesn't pay attention to any windows
at all.

IOW, the bug you're apparently seeing is elsewhere.


        Stefan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-25 12:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-24 11:20 save-restriction doesn't restore scroll Psionic K
2024-03-25 12:55 ` Stefan Monnier via Users list for the GNU Emacs text editor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).