emacs-devel
[Top][All Lists]
Advanced

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

Re: Getting column position accounting for overlays


From: Eli Zaretskii
Subject: Re: Getting column position accounting for overlays
Date: Wed, 05 Aug 2015 18:21:05 +0300

> From: Yuri D'Elia <address@hidden>
> Date: Wed, 5 Aug 2015 11:10:59 +0200
> 
> I'd like the equivalent of (current-column), or character length between
> (beginning-of-line) and cursor position [modulus tabs], but using the
> actual displayed overlays.

I think you want this:

  (/ (car (window-text-pixel-size nil (line-beginning-position) (point)))
     (default-font-width))

But that's a guess.  Please tell more about your use case, because I
don't quite understand why would you need this.  Also note that
default-font-width didn't exist before Emacs 25.

> I would almost have expected something to extract the visualized string
> between two points, like `buffer-substring' but iterating through
> overlays; but couldn't find any (did I miss it?)

The overlay strings are directly accessible via 'overlay-get', so why
would anyone need the feature you expected to exist?

> (posn-col-row (posn-at-point)) "would" work, but 1) seems inefficient,
> especially considering I don't care about variable-pitch fonts and 2)
> doesn't work if the point is not visible.

If you don't care about variable-pitch fonts, how come you do care
about overlay and display strings?  They are conceptually the same:
they extend the width of the text by using data that is not directly
available from buffer text.



reply via email to

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