Subject: bug#42307: bug#42347: Feature request: Visual block attribute for overlays

From: Gregory Heytings <[email-masked]>
Date: Tue, 14 Jul 2020 15:45:01 +0000

>>>> 2. remove all pixel columns on the right *and on the left* of the 
>>>> overlay which have no "content" (that is, no characters on the right, 
>>>> and whitespace characters on the left).
>>>
>>> What would be the definition of "whitespace" for this purpose?
>>>
>>
>> I think the regexp "[ \t\r\n]*" would be appropriate.
>
> Are you sure?
>
> First, \r doesn't happen in Emacs buffers,
>

I wasn't sure about \r, but included it just in case.

>
> and \n is the newline, so it isn't on the same line.
>

It is, but it's the last character of the line.  With the current default 
behavior it is displayed, there is one more blank character after each 
line, just type C-x = on that character.

In the two pictures (visualblock.png and visualblock-2.png) I sent (see 
bug #42307), the \n is removed on the right.  Otherwise there would be one 
more column on the right.

>
> Next, what about \f, and more generally about any other sequence of 
> characters that match [:blank:]?
>

Good question.  As far as I know \f is displayed by default as '^L' by 
Emacs, so it's a visible character, and I'm fine with this.  I think it 
should not count as a blank character, which means that an overlay with a 
'\f' in a column would extend at least to that column.

>
> And finally, what about stretches of whitespace generated by the 'space' 
> display properties?
>

I don't know, and I'm not sure I fully understand the question.  The 
"algorithm" I proposed is, I think, clear and simple: draw the overlay 
with :extend t, and trim whitespace on the left and on the right.

That being said, on a second thought I think a better name for the 
proposed attribute would be ":trim" (or perhaps ":trimleft" and 
"trimright" to give as much possible freedom to Emacs users).  It could 
have, for example, three values:

- default value = nil, gives the default behavior (with and without 
:extend)

- value = t, gives the behavior of "visiblechars.png"

- value = column, gives the behavior of "visualblock.png" and 
"visualblock-2.png"

Gregory