[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tags right alignment with font-lock
From: |
Nicolas P. Rougier (inria) |
Subject: |
Tags right alignment with font-lock |
Date: |
Sat, 02 Dec 2023 12:28:28 +0100 |
User-agent: |
mu4e 1.10.8; emacs 29.1 |
Hello,
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)
;; Right alignment (pixel wise)
;;(font-lock-add-keywords 'org-mode
;; `(("^\\*+.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
;; (1 `(face nil
;; display (space :align-to (- right 3
;; (,(org-string-width
(match-string 2)
t)))))
;; 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?)
Nicolas
--
Nicolas P. Rougier —— www.labri.fr/perso/nrougier
Institute of Neurodegenerative Diseases, Bordeaux
- Tags right alignment with font-lock,
Nicolas P. Rougier (inria) <=