all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Markus Triska <triska@metalevel.at>
Cc: 34038@debbugs.gnu.org
Subject: bug#34038: 26.1; set-window-start sometimes fails to set window start
Date: Fri, 11 Jan 2019 21:23:57 +0000	[thread overview]
Message-ID: <20190111212357.GA5201@ACM> (raw)
In-Reply-To: <87ef9je67i.fsf@metalevel.at>

Hello, Markus.

Your original form:

    (progn
      (goto-char (point-max))
      (insert "\n")
      (dotimes (x (window-height))
        (insert (format "%s\n" x)))
      (redisplay)
      (let ((b (buffer-string))
            (p (point)))
        (set-window-start nil p t)
        (read-key "Please press a key to continue.")
        (erase-buffer)
        (insert b)
        (set-window-start nil p t)))

On Fri, Jan 11, 2019 at 13:20:33 +0100, Markus Triska wrote:
> Eli Zaretskii <eliz@gnu.org> writes:

> > I think this happens because you call set-window-start with last
> > argument non-nil.  Doing that tells the display engine that the
> > window-start point is just a suggestion, not a hard requirement.

> In the documentation of set-window-start, the last argument is described
> as:

>     Optional third arg NOFORCE non-nil inhibits next redisplay from
>     overriding motion of point in order to display at this exact start.

> >From this text, this seems to be precisely what I need: I want to retain
> point at this exact place, and I only want to change the window start,
> not the point. In my use case, if I set this argument to "nil", then I
> get unexpected point motion. Is there a way to reliably set window point
> while at the same time preventing motion of point? I tried adding
> (redisplay) at strategic places in my code, and this seems to work
> somewhat better then, though at the cost of causing display flickering.

> Thank you and all the best!
> Markus

I've played with this for several hours, and my feeling, like yours, is
that there's a bug in there, somewhere.

If you set scroll-conservatively to a non-zero value, your form behaves
properly.  This suggests that the problem is in redisplay rather than
set-window-start itself.

If you remove the erase-buffer and insert forms from the form,
(replacing them with an (end-of-buffer)), again you get the desired
behaviour.

M-: (set-window-start nil (point-max) t) appears to behave correctly.

A bit of debugging output shows that after (erase-buffer), window-start
is already at 1, not the former point-max.  After (insert b),
window-start continues to be at 1.

erase-buffer and insert are doing something strange with internal
display variables.  I tried seeing if this was the w->force_start field
of the window structure (that's the field which gets set to true when
one calls set-window-start _without_ a non-nil NOFORCE, but doesn't get
cleared when NOFORCE is non-nil; I think only redisplay clears it).  But
this isn't it.

There might be a clue in the entry for set-window-start in the manual,
which says:

     If NOFORCE is non-`nil', and POSITION would place point off screen
     at the next redisplay, then redisplay computes a new window-start
     position that works well with point, and thus POSITION is not used.
 
.  This is pure speculation, but perhaps because the entire buffer is
currently off the screen, with point being on the empty last line,
redisplay is somehow thinking that point is off screen too.  If this is
the case, it would explain why redisplay scrolls the buffer to put point
on the middle window line.

-- 
Alan Mackenzie (Nuremberg, Germany).





  parent reply	other threads:[~2019-01-11 21:23 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 19:57 bug#34038: 26.1; set-window-start sometimes fails to set window start Markus Triska
2019-01-11  7:03 ` Eli Zaretskii
2019-01-11 12:20   ` Markus Triska
2019-01-11 13:36     ` Eli Zaretskii
2019-01-11 14:31       ` Markus Triska
2019-01-11 15:10         ` martin rudalics
2019-01-11 17:45           ` Markus Triska
2019-01-11 19:07             ` Eli Zaretskii
2019-01-12  8:12             ` martin rudalics
2019-01-12 13:25               ` Markus Triska
2019-01-12 13:53                 ` Eli Zaretskii
2019-01-12 14:12                 ` martin rudalics
2019-01-12 19:08                   ` Markus Triska
2019-01-12 20:28                     ` Eli Zaretskii
2019-01-11 21:23     ` Alan Mackenzie [this message]
2019-01-12  8:13       ` martin rudalics
2019-01-12 18:22         ` Alan Mackenzie
2019-01-12 20:29           ` Eli Zaretskii
2019-01-12 20:42             ` Alan Mackenzie
2019-01-13  3:30               ` Eli Zaretskii
2019-01-13  7:32       ` Markus Triska
2019-01-13  8:40         ` martin rudalics
2019-01-13 11:32           ` Eli Zaretskii
2019-01-13 13:40             ` martin rudalics
2019-01-13 15:21               ` Eli Zaretskii
2019-03-24 10:35                 ` Markus Triska
2019-03-24 17:28                   ` Eli Zaretskii
2019-03-24 19:56                     ` Markus Triska
2019-03-28 16:21                       ` Eli Zaretskii
2019-03-29  7:16                         ` Markus Triska
2019-03-29  8:29                           ` Eli Zaretskii
2019-04-06  8:23                             ` Eli Zaretskii
     [not found] <<m2ftu05lqv.fsf@metalevel.at>
     [not found] ` <<83sgxzhe04.fsf@gnu.org>
2019-01-11 16:37   ` Drew Adams
2019-01-11 16:49     ` Eli Zaretskii

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

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

  git send-email \
    --in-reply-to=20190111212357.GA5201@ACM \
    --to=acm@muc.de \
    --cc=34038@debbugs.gnu.org \
    --cc=triska@metalevel.at \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.