Subject: Re: bug#21012: 25.0.50; eww: last char of a line sometimes not fully visible

From: Eli Zaretskii <[email-masked]>
Date: Fri, 10 Jul 2015 21:45:17 +0300

> From: Michael Heerdegen <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 10 Jul 2015 20:04:43 +0200
> 
> Can't we find the position of the last completely visible char of a
> line with
> 
> --8<---------------cut here---------------start------------->8---
>   (save-excursion
>     (let ((truncate-lines nil))
>       (when (line-move-visual +1 t)
>         (backward-char 1))
>       (point)))
> --8<---------------cut here---------------end--------------->8---

I'd prefer to exchange ideas rather than code that I need to second
guess.  So what's the idea behind this?

Is the idea to turn off truncate-lines and thus avoid partially
visible characters at end of line?  If so, how do you find the last
visible character?  Doing what you suggest above won't work with
bidirectional text, where (backward-char 1) from the leftmost
character of a visual line doesn't necessarily put you on the last
character of the previous visual line.  I think you need to let-bind
visual-order-cursor-movement to t and invoke left-char instead.

Next, line-move-visual will only move to the leftmost character of the
next line if you are already on the leftmost character of the current
line, so you'd need to make that happen first.  Not hard to do, but
should be part of the code, or maybe I'm missing something.

Finally, portions of line-move-visual and its subroutines only work
when the line is visible in some window, so won't that again hit the
same limitation of posn-at-point?

Thanks.