[Top][All Lists]

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

Re: Tags right alignment with font-lock

From: Ihor Radchenko
Subject: Re: Tags right alignment with font-lock
Date: Fri, 08 Dec 2023 15:45:09 +0000

"Nicolas P. Rougier (inria)" <nicolas.rougier@inria.fr> writes:

> I'm using font lock to have tags right aligned with the following 
> code:
> ;; Right alignment (char wise)
> (add-to-list 'font-lock-extra-managed-props 'display)
> (font-lock-add-keywords 'org-mode
>   `(("^\\*+.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
>      (1 `(face nil
>                display (space :align-to (- right 3
>                                            ,(org-string-width 
>                                            (match-string 2)))))
>         prepend))) t)
> ...
> I've not tested it thoroughly but it seems to be working 
> reasonably well on my machine. It is pretty similar to the code 
> posted by Ihor Radchenko (thread on "variable-pitch-mode misaligns 
> org-mode heading tags") and I wonder if there are any drawback 
> with such techniques (too slow? does not work on all situations?)

The above code has problems when you try editing the heading near the
end of the title (before the :align-to space). Especially when the
window is narrow. Also, when `org-auto-align-tags' is nil.

Not that they cannot be solved, but it is not just as trivial as the
above code.

Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

reply via email to

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