emacs-devel
[Top][All Lists]
Advanced

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

Re: line-start?


From: Eli Zaretskii
Subject: Re: line-start?
Date: Fri, 07 Feb 2020 11:20:53 +0200

> From: Bastien <address@hidden>
> Cc: address@hidden
> Date: Fri, 07 Feb 2020 07:42:28 +0100
> 
> >   (nth 1 (posn-at-x-y 0 (cdr (posn-x-y (posn-at-point)))))
> 
> Thanks a lot -- this is indeed more precise.  (window-hscroll)
> does not handle rescaled text very well, whereas this solution
> does.

Once again, window-hscroll just returns the number of columns by which
the window is hscrolled, it doesn't return the buffer position.  For
example, window-hscroll will return the same value for each line in
the window, although the buffer position of the beginning of each line
is different.  Are you looking for columns or for buffer positions?

> However, when the cursor is right under the header-line, the
> expression above returns 'header-line, so I could not use it
> for my purpose.
> 
> Also, the same expression returns 'header-line when the cursor
> is on the _second_ line below the 'header-line -- I haven't
> looked for why it does so, but if it is reproducible, maybe
> there is something inconsistent here.

Yes, you need to correct the Y coordinate returned by posn-at-point
when the window has a header line.  The correction can be calculated
like this:

  (- (nth 1 (window-edges nil t nil t))
     (nth 1 (window-edges nil nil nil t)))



reply via email to

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