bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15783: 24.3; posn-at-x-y is relative to the buffer area, posn-at-poi


From: Alex
Subject: bug#15783: 24.3; posn-at-x-y is relative to the buffer area, posn-at-point is relative to the text area.
Date: Fri, 17 Nov 2017 01:46:36 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: 椎野 裕樹
>>      <shiino.yuki@gmail.com>
>> Date: Fri, 1 Nov 2013 23:49:00 +0900
>> 
>> On Emacs 24 with non-nil header-line-format, y offset returned by
>> `posn-at-point' is relative to the text area *not including the header
>> line*.  However, `posn-at-x-y' takes y offset relative to the buffer
>> area *including the header line*.
>> 
>> Is this by design?
>
> Yes.
>
>> When I get the position by `posn-at-point', and then convert the
>> position to the point by `posn-at-x-y', the resulting point does not
>> match the point given to `posn-at-point'.
>
> You should test for non-nil header-line-format, and adjust the value
> accordingly.
>
>> On Emacs 22 and 23, both functions are relative to the buffer area
>> including the header line.  It's fine.
>
> That caused much more grave bugs.

What kind of bugs did it cause?  It's pretty jarring to have the
following return nil when a header-line is present:

  (let ((x-y (posn-x-y (posn-at-point))))
    (equal x-y (posn-x-y (posn-at-x-y (car x-y)
                                      (cdr x-y)))))

I noticed this since an Emacs package uses posn-x-y and posn-at-x-y to
try to preserve the point's screen coordinates before and after a
scroll.  With a header-line, this puts the point one row too high.

It should probably just let-bind `scroll-preserve-screen-position',
right?  Still, the above is pretty counterintuitive. If nothing else, I
think this incompatibility should be highlighted.

P.S. I noticed that the manual for `posn-at-x-y' states that the WHOLE
argument affects both X and Y, but the docstring only states that X is
affected.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]