unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Bastien <bzg@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: line-start?
Date: Fri, 07 Feb 2020 15:43:58 +0200	[thread overview]
Message-ID: <83wo8yecm9.fsf@gnu.org> (raw)
In-Reply-To: <878sle7jx9.fsf@gnu.org> (message from Bastien on Fri, 07 Feb 2020 11:48:02 +0100)

> From: Bastien <bzg@gnu.org>
> Cc: emacs-devel@gnu.org
> Date: Fri, 07 Feb 2020 11:48:02 +0100
> 
> Eli Zaretskii <eliz@gnu.org> 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.



  reply	other threads:[~2020-02-07 13:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 10:24 line-start? Bastien
2020-02-06 13:00 ` line-start? Bastien
2020-02-06 18:25   ` line-start? Eli Zaretskii
2020-02-07  6:42     ` line-start? Bastien
2020-02-07  9:20       ` line-start? Eli Zaretskii
2020-02-07 10:11         ` line-start? Bastien
2020-02-07 10:24           ` line-start? Eli Zaretskii
2020-02-07 10:48             ` line-start? Bastien
2020-02-07 13:43               ` Eli Zaretskii [this message]
2020-02-07 14:46                 ` line-start? Bastien
2020-02-07 15:56                   ` line-start? Eli Zaretskii
2020-02-07 17:42                     ` line-start? Bastien

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=83wo8yecm9.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=bzg@gnu.org \
    --cc=emacs-devel@gnu.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).