unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 18618@debbugs.gnu.org
Subject: bug#18618: 25.0.50; `window-end win t` produces erroenous result with `window-scroll-functions` hook.
Date: Fri, 28 May 2021 23:16:41 -0700	[thread overview]
Message-ID: <m2zgwe12uu.wl%esq@lawlist.com> (raw)
In-Reply-To: <m2lhoy3qsa.wl%esq@lawlist.com>

Lars:

I haven't played in depth with the Emacs internals for a couple of years or so.  In working on my own feature requests (back in the day), I learned that window-start/end cannot be accurately ascertained with 100% certainty until the tail end of redisplay ...  If a user were to add/remove something with Lisp, then redisplay would need to recalculate to take that modification into consideration -- necessitating further recalculation, which may alter window-start/end.

In terms of my own feature requests, I opted to use `update_window` in dispnew.c to add visual modifications to the glass that did not alter any text or points in the buffer.  That way, no further calculation was needed as to window-start/end points -- as said points were "final" calculations at that late stage of redisplay.  The `window-scroll-functions` hook only operates under certain criteria, but not all the time.  As of my last look a couple of years ago, there was no hook that operated towards the latter part of redisplay with 100% certainty.  For a few years before using `update_window`, I used a combination of the `post-command-hook` and the `window-scroll-functions` hook to try and catch the majority of situations to ascertain window-start/end, but there were always several situa
 tions where the two hooks where insufficient ...  An example of what users were required to do back in the day can be seen by examining libraries such as the deprecated linum-mode, which used both o
 f the aforementioned hooks because there is/was no sole hook that could accurately predict window-start/end with 100% certainty.

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> Date: [05-28-2021 20:37:18] <29 May 2021 05:37:18 +0200>
> From: Lars Ingebrigtsen <larsi@gnus.org>
> To: Keith David Bershatsky <esq@lawlist.com>
> Cc: 18618@debbugs.gnu.org
> Subject: Re: bug#18618: 25.0.50; `window-end win t` produces erroenous result with `window-scroll-functions` hook.
> 
> Keith David Bershatsky <esq@lawlist.com> writes:
> 
> > Steps to reproduce the issue.
> >
> > 1.  Create a function that reports (e.g., a message) the value of `(window-end win t)` and attach that function to the `window-scroll-functions` hook.
> >
> > 2.  Open a long file in either fundamental-mode or text-mode.
> >
> > 3.  M-x end-of-buffer
> >
> > 4.  M-x beginning-of-buffer
> >
> > The result of step 4 reports an erroneous window-end value that is at
> > the very end of the buffer, instead of the correct window-end (i.e.,
> > which is much closer to the beginning of the buffer).
> 
> (I'm going through old bug reports that unfortunately got no response at
> the time.)
> 
> This problem is still present in Emacs 28.  Here's an easier test case:
> 
> (defun foo (win _)
>   (message "End: %s" (window-end win t))
>   nil)
> (push 'foo window-scroll-functions)
> 
> This reports the same number in both 3) and 4) when transient-mark-mode
> is switched on, but not when it's off.  It's also correct if that mode
> is on, and the region is active.
> 
> I haven't tried to debug further -- perhaps it's immediately obvious to
> somebody what could be causing this glitch?
> 
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no





      parent reply	other threads:[~2021-05-29  6:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03  1:06 bug#18618: 25.0.50; `window-end win t` produces erroenous result with `window-scroll-functions` hook Keith David Bershatsky
2014-10-03  2:11 ` bug#18618: " Keith David Bershatsky
2021-05-29  3:37 ` bug#18618: 25.0.50; " Lars Ingebrigtsen
2021-05-29  6:24   ` Eli Zaretskii
2021-05-29  6:16 ` Keith David Bershatsky [this message]

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=m2zgwe12uu.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=18618@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /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).