From: Eli Zaretskii <eliz@gnu.org>
To: Yuri D'Elia <wavexx@thregr.org>
Cc: emacs-devel@gnu.org
Subject: Re: Getting column position accounting for overlays
Date: Sat, 08 Aug 2015 18:43:31 +0300 [thread overview]
Message-ID: <831tfdrdjw.fsf@gnu.org> (raw)
In-Reply-To: <55C61DE6.7050706@thregr.org>
> From: Yuri D'Elia <wavexx@thregr.org>
> Date: Sat, 8 Aug 2015 17:19:02 +0200
>
> On 08/08/15 16:45, Eli Zaretskii wrote:
> >> Ah yes, but that's precisely the problem: I need to calculate POS
> >> beforehand.
> >
> > Yes, of course. But you will have the same problem if you do get the
> > text dimensions: you need to compare that with something to do useful
> > things with the value. Right?
>
> Getting text dimensions was/is sort of a work-around.
> If I could get displayed text easily, the iteration over overlays
> wouldn't be needed: I could just take the string length.
Take the string length and do what with it?
And please don't assume that given a string you can compute its
visual length easily: you can't, not with variable-pitch fonts. And
then you have images, stretches, etc.
> Again, it would have problems on its own as we discussed, so far none of
> the solutions work perfectly.
Solutions to what problem(s)?
> To be more concrete, what about a (visual-column) function, that just
> gives what's currently needed?
I've already shown you a way to compute that, several message ago.
Let me repeat:
(/ (car (window-text-pixel-size nil (line-beginning-position) (point)))
(default-font-width))
> (visual-column &optional logical)
>
> Return the horizontal position of point. Beginning of the *visual* line
> is column 0. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^
This is contrary to current-column conventions: it counts from the
beginning of the physical line, not visual line. If you want to count
from the beginning of the visual line, replace line-beginning-position
above with something like
(save-excursion (beginning-of-visual-line) (point))
next prev parent reply other threads:[~2015-08-08 15:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 20:01 Getting column position accounting for overlays Yuri D'Elia
2015-08-05 2:51 ` Eli Zaretskii
2015-08-05 9:10 ` Yuri D'Elia
2015-08-05 15:21 ` Eli Zaretskii
2015-08-05 18:44 ` Yuri D'Elia
2015-08-05 19:01 ` Eli Zaretskii
2015-08-07 17:13 ` Yuri D'Elia
2015-08-07 18:19 ` Eli Zaretskii
2015-08-08 14:31 ` Yuri D'Elia
2015-08-08 14:45 ` Eli Zaretskii
2015-08-08 15:19 ` Yuri D'Elia
2015-08-08 15:43 ` Eli Zaretskii [this message]
2015-08-08 16:29 ` Yuri D'Elia
2015-08-08 16:48 ` Eli Zaretskii
2015-08-08 17:22 ` Yuri D'Elia
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=831tfdrdjw.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=wavexx@thregr.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.