unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: magnars@gmail.com, emacs-devel@gnu.org
Subject: Re: set-window-start moves point without scrolling
Date: Tue, 19 Mar 2013 19:40:16 +0200	[thread overview]
Message-ID: <83boaf1e67.fsf@gnu.org> (raw)
In-Reply-To: <878v5juzi5.fsf@web.de>

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Tue, 19 Mar 2013 17:26:42 +0100
> Cc: Magnar Sveen <magnars@gmail.com>
> 
> To avoid performing of automatic window scrolling when the current
> editing command is performed at the positions of the "other" cursors,
> these actions are wrapped in this macro:
> 
> (defmacro mc/save-window-scroll (&rest forms)
>   "Saves and restores the window scroll position"
>   `(let ((p (set-marker (make-marker) (point)))
>          (start (set-marker (make-marker) (window-start)))
>          (hscroll (window-hscroll)))
>      ,@forms
>      (goto-char p)
>      (set-window-start nil start)
>      (set-window-hscroll nil hscroll)
>      (set-marker p nil)
>      (set-marker start nil)))
> 
> (the local vars should become uninterned symbols, but that's not related)
> 
> This code triggers the effect in my example above: point (i.e., the
> "real" cursor) is moved as a side effect if point was in the first
> visible window line and scroll-margin > 0.
> 
> How would a better implementation of this macro look like?  Would it be
> sufficient to use a non-nil third argument for `set-window-start', or
> would this not reverse automatic scrolling reliably?

I think using a non-nil 3rd argument to set-window-start should do
what you want.  At least it does that in your recipe that started this
thread.  My reading of the code which deals with the effect of the
optional arg to set-window-start is that passing a non-nil value there
inhibits the code which forces point outside the scroll margin in this
case.

> BTW, I already tried to wrap the `set-window-hscroll' inside
> `save-excursion' or (let ((scroll-margin 0)) ...), but this doesn't help
> (I guess because scrolling is performed afterwards while redisplaying.)

Yes.



  reply	other threads:[~2013-03-19 17:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 22:44 set-window-start moves point without scrolling Michael Heerdegen
2013-03-19  3:42 ` Eli Zaretskii
2013-03-19 16:26   ` Michael Heerdegen
2013-03-19 17:40     ` Eli Zaretskii [this message]
2013-03-19 18:38       ` Michael Heerdegen

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=83boaf1e67.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=magnars@gmail.com \
    --cc=michael_heerdegen@web.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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