unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Psionic K <psionik@positron.solutions>
To: help-gnu-emacs@gnu.org
Cc: Ihor Radchenko <yantar92@posteo.net>
Subject: save-restriction doesn't restore scroll
Date: Sun, 24 Mar 2024 20:20:06 +0900	[thread overview]
Message-ID: <CADQMGATXUFijuaV9+sLPGShwPYJumbsijhAv8HG5RF9b+Ogr_w@mail.gmail.com> (raw)

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.


             reply	other threads:[~2024-03-24 11:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 11:20 Psionic K [this message]
2024-03-25 12:55 ` save-restriction doesn't restore scroll Stefan Monnier via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADQMGATXUFijuaV9+sLPGShwPYJumbsijhAv8HG5RF9b+Ogr_w@mail.gmail.com \
    --to=psionik@positron.solutions \
    --cc=help-gnu-emacs@gnu.org \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).