emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Tags right alignment with font-lock
@ 2023-12-02 11:28 Nicolas P. Rougier (inria)
  2023-12-08 15:45 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas P. Rougier (inria) @ 2023-12-02 11:28 UTC (permalink / raw)
  To: emacs-orgmode


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-08 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-02 11:28 Tags right alignment with font-lock Nicolas P. Rougier (inria)
2023-12-08 15:45 ` Ihor Radchenko
2023-12-08 16:21   ` Nicolas P. Rougier (inria)

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).