bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#24633: highlight-region func using (window-hscroll) in :align-to spe


From: Eli Zaretskii
Subject: bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop
Date: Sat, 08 Oct 2016 21:01:46 +0300

> From: npostavs@users.sourceforge.net
> Cc: 24633@debbugs.gnu.org
> Date: Sat, 08 Oct 2016 13:17:37 -0400
> 
> The high-level idea is to have a line from going from the left to the
> right edge of the window.  Most of the line is composed of an overlay
> specifying the :underline text property.  The last bit of it, from the
> end of the text to the right edge of the screen, is created by an
> underlined after-string space which uses :align-to to reach the right
> edge of the screen.
> 
> Using :align-to 'right or :align-to `((,(window-body-width nil t))) does
> not account for horizontal scrolling (i.e., the line ends at 80 columns,
> even when the 80th column is scrolled to the left).  So I tried
> 
>     `(+ ,(window-hscroll) (0 . right))
>     `(+ ,(window-hscroll) (,(window-body-width nil t))) ; initially this
> 
> to make up for it, which turns out to cause this strange looping.

Automatic hscrolling is based on length of point's line at the end of
redisplaying a window.  Here, "line length" means the horizontal space
required for displaying all the glyphs of the line, which includes the
glyphs that come from the after-string.  Since you extend your
after-string each time the window is hscrolled, you in effect enlarge
the line each time the display engine hscrolls the window, which
causes an endless loop.

Can you restrict the after-string's length so it always ends at the
last character of the line, or some fixed number of columns afterward?

> >  In particular, I don't
> > understand the align-to expression: e.g., window-hscroll returns its
> > value in columns, while align-to needs pixels, AFAIU.
> 
> According to `(elisp) Pixel Specification',
> 
>        The form NUM specifies a fraction of the default frame font height
>     or width.  The form `(NUM)' specifies an absolute number of pixels.

I admire your courage in reading that documentation and then writing
stuff like the above, which the documentation doesn't mention even
remotely.





reply via email to

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