Subject: Re: bug#16992: feature request: background images

From: Eli Zaretskii <[email-masked]>
Date: Sat, 09 Nov 2024 09:44:39 +0200

> Date: Fri, 8 Nov 2024 20:20:31 +0100
> From: Cecilio Pardo <[email-masked]>
> 
> On 08/11/2024 19:50, Eli Zaretskii wrote:
> > So what is the Lisp API for drawing those "dynamic" things?  AFAIU,
> > you've only shown the API to set a single static background image.
> 
> There is no lisp api yet. In this example the fill-column line is drawn 
> always, in the part that iterates through the windows.
> 
> > Is the background image scrolled or isn't it?
> 
> No. The background image is always fixed at this point.

I could see use cases for optionally scrolling the background image as
well.

> > Those "dynamic" drawings are the most wanted feature that is currently
> > missing.  And the challenge is to implement them in a way that won't
> > make redisplay significantly slower, e.g. due to disabled
> > optimizations (like scrolling_window).
> 
> Then let's drop the image thing for now and focus on this.

We don't have to drop the background image feature.  It has its place,
IMO.  But I think we should not consider it as a candidate for
implementing dynamic drawings such as fill-column indicator.  That
should be a separate feature.

> The two use cases I have right now imply just a series of vertical lines:
> 
> - Lines fixed One to an x coordinate with an infinite height, for 
> fill-column.

It is not fixed because its X coordinate is controlled from Lisp.  In
addition, if a buffer mixes LTR and RTL paragraphs, the indicator is
shown sometimes on the right and sometimes on the left (because
columns are counted right-to-left in an RTL paragraph).

> - Segments distributed through the window for the indent-lines.
> 
> We could have buffer local variables to define these lines.

Yes.

> What other features should we consider?

Anything that needs some image to be drawn which partially or fully
overlaps the usual buffer/string display.

> Should we open a new bug report to discuss this?

Probably.  And I suggest to ask a question on emacs-devel.  Over the
years, there were quite a few requests for something like this, and
there are several optional (mostly 3rd-party) packages which try to do
this in Lisp (which require very complex Lisp code, and IMO look
clunky and even unprofessional), so asking a question might bring
additional interesting ideas for using this kind of functionality.

Btw, all of these will need some way of enabling at least some
redisplay optimizations, and at least for images which scroll together
with the buffer that should be possible.