[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 15:43:58 +0200 |
> From: Bastien <address@hidden>
> Cc: address@hidden
> Date: Fri, 07 Feb 2020 11:48:02 +0100
>
> Eli Zaretskii <address@hidden> writes:
>
> > Then (nth 1) of what posn-at-x-y returns is not what you want. You
> > should use the (car (nth 6)) instead.
>
> FWIW I just tried this:
>
> (car (nth 6 (posn-at-x-y
> 0 (+ (cdr (posn-x-y (posn-at-point pos window)))
> (- (nth 1 (window-edges nil t nil t))
> (nth 1 (window-edges nil nil nil t)))))))
>
> but it always returns 0.
Ah, yes: you will have to add (window-hscroll) to that.
> The version with (nth 1 ...) works fine, though.
But that gives a buffer position, not column number.
> >> The use case was this one: given a line, display the content of this
> >> line in the header line. When horizontally scrolled, the header has
> >> to display a substring of the line under the cursor, something like
> >> (substring (current-line-string) offset-in-columns).
> >
> > But using the buffer position, you could use buffer-substring instead,
> > right?
>
> Yes, sure, but I still need to know the window line start to get the
> offset.
No, buffer position is absolute.
- line-start?, Bastien, 2020/02/06
- Re: line-start?, Bastien, 2020/02/06
- Re: line-start?, Eli Zaretskii, 2020/02/06
- Re: line-start?, Bastien, 2020/02/07
- Re: line-start?, Eli Zaretskii, 2020/02/07
- Re: line-start?, Bastien, 2020/02/07
- Re: line-start?, Eli Zaretskii, 2020/02/07
- Re: line-start?, Bastien, 2020/02/07
- Re: line-start?,
Eli Zaretskii <=
- Re: line-start?, Bastien, 2020/02/07
- Re: line-start?, Eli Zaretskii, 2020/02/07
- Re: line-start?, Bastien, 2020/02/07