unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: luangruo@yahoo.com, 70386@debbugs.gnu.org
Subject: bug#70386: 30.0.50; (recenter 0 t) does not put point on top of the window
Date: Sun, 12 May 2024 06:58:32 +0000	[thread overview]
Message-ID: <87a5kvtt2f.fsf@localhost> (raw)
In-Reply-To: <86a5kv1qlc.fsf@gnu.org>

Eli Zaretskii <eliz@gnu.org> writes:

>> Why does it need to matter? Right before calling recenter, the point is
>> at 757, as you can see from point-list in my test.
>
> That's not what I see in my testing.  Point usually is there, but not
> always.  The whole recipe is not deterministic, as I told many
> messages ago.

I do not consider the case when scrolling "overshoots" the window
boundary and moves point as a bug. I only consider the other case, when
the point does not move as a bug.

Try the following - it should not overshoot and should be more deterministic:

(setq point-list nil)
(setq current-line-list nil)
(progn
  (push (point) point-list)
  (push (count-lines 1 (point)) current-line-list)
  (require 'pixel-scroll)
  (push (point) point-list)
  (push (count-lines 1 (point)) current-line-list)
  (pixel-scroll-precision-interpolate
   (* -1 (line-pixel-height)
      (max 0 (- (count-screen-lines (window-start) (point)) 4)))
   nil 1)
  (push (point) point-list)
  (push (count-lines 1 (point)) current-line-list)
  ;; Call original recenter for final adjustment.
  (recenter 0 t)
  (push (point) point-list)
  (push (count-lines 1 (point)) current-line-list))

>> May you please explain how I am supposed to know this from reading the
>> docstring?
>
> Would knowing that convince you that your snippet is based on shaky
> grounds?

That would at least make me aware that there are shaky grounds to worry
about.

>> And even then, when scrolling current line to be on the top (which is
>> what (recenter 0 t) supposed to do), as a user, I will be surprised that
>> the current line remains at line 21! - what kind of "best effort" is
>> that when the result if off by 21 lines? surely, Emacs can do better.
>
> You again assume that you know what is the "current line" when
> 'recenter' is called.  Given that the code immediately before that
> scrolls the window, what is the "current line" is not well defined.

By current line, I mean "line containing point". Again, I am not worried
about the case when scrolling changes point position and that new
position gets recentered. I am only worried about the case when the
rencentering does not alter the final window scroll, despite the point
not being on the requested visual line.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





  reply	other threads:[~2024-05-12  6:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-14 16:33 bug#70386: 30.0.50; (recenter 0 t) does not put point on top of the window Ihor Radchenko
2024-04-14 19:00 ` Eli Zaretskii
2024-04-14 19:36   ` Ihor Radchenko
2024-04-15 16:11     ` Eli Zaretskii
2024-04-15 17:13       ` Ihor Radchenko
2024-04-15 18:29         ` Eli Zaretskii
     [not found]           ` <87cyqq5usj.fsf@localhost>
2024-04-15 19:14             ` Eli Zaretskii
2024-04-27  8:29       ` Eli Zaretskii
2024-04-27 10:56         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-27 11:51           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 18:31             ` Ihor Radchenko
2024-05-09  7:37               ` Eli Zaretskii
2024-05-09  7:54                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 17:48                   ` Ihor Radchenko
2024-05-11 17:56                     ` Eli Zaretskii
2024-05-11 18:00                       ` Ihor Radchenko
2024-05-11 18:26                         ` Eli Zaretskii
2024-05-11 18:42                           ` Ihor Radchenko
2024-05-11 18:53                             ` Eli Zaretskii
2024-05-11 19:09                               ` Ihor Radchenko
2024-05-12  6:00                                 ` Eli Zaretskii
2024-05-12  6:17                                   ` Ihor Radchenko
2024-05-12  6:39                                     ` Eli Zaretskii
2024-05-12  6:58                                       ` Ihor Radchenko [this message]
2024-05-12  7:02                                         ` Eli Zaretskii
2024-05-12  7:17                                           ` Ihor Radchenko
2024-05-12  9:17                                             ` Eli Zaretskii
2024-05-12  9:23                                               ` Ihor Radchenko
2024-05-12 10:15                                                 ` Eli Zaretskii
2024-05-12  7:19                                           ` Ihor Radchenko
2024-05-12  9:19                                             ` Eli Zaretskii
2024-05-19 13:49                                               ` Ihor Radchenko
2024-05-19 15:29                                                 ` Eli Zaretskii
2024-05-23 13:27                                                   ` Eli Zaretskii
2024-05-23 13:52                                                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=87a5kvtt2f.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=70386@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=luangruo@yahoo.com \
    /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).