On Wed, Sep 16, 2020 at 11:55:53PM +0100, Adam Spiers wrote:
I've actually managed it get it working now! See the attached patch.
However unfortunately it is not ready to be merged yet. Firstly, it
breaks `test-org/tag-align'. Secondly, since this changes the method
of alignment from simply using raw spaces to using a single space with
a display text property, when the file is saved and reloaded, it just
displays a single space and the alignment is lost. Another
unfortunate side-effect is that if the file is simultaneously
displayed in a graphical window and a text window via the same emacs
server (e.g. via emacsclient -t), then one of the two windows will
have incorrect alignment.
So I think the correct fix will be to keep the original number of
spaces, but use a display text property to redisplay those spaces as a
single space with the given width. I'm guessing that the display text
property will be ignored on text-only (tty) windows, fixing both
problems in one go.
So I'll take another stab at this soon, if Bastien or some other Org
guru can confirm I'm on the right track.
Hrm, no this isn't good enough. For graphical windows we still need
to set the display text properties to align all tags when the buffer
initially loads. AFAICS there's currently no code to trigger this, so
it would need to be added, and for large files this might actually
cause problems with file loading time unless it was done in the
background (a bit like fontification can be done).
Advice on how to handle this best is very welcome.