1

Just found a quick way to have tags always right aligned, taking advantage of font-lock and display property.

(add-to-list 'font-lock-extra-managed-props 'display)
(font-lock-add-keywords 'org-mode
  `(("^.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
     (1 `(face nil
          display (space :align-to (- right ,(length (match-string 2)) 3)))
        prepend))) t)
you are viewing a single comment's thread
view the rest of the comments
[-] whudwl@alien.top 1 points 10 months ago

It seems this affects stuff like :PROPERTIES: as well

[-] llcc_reddit@alien.top 1 points 10 months ago

Also not working well for multiple tags. The tags are wrapped into the second line.

[-] Nicolas-Rougier@alien.top 1 points 10 months ago

Weird since the regex includes a space before the first ":". As for multitag, it is working properly for me.

[-] llcc_reddit@alien.top 1 points 10 months ago

I found out that it's the non-English characters in tags that trigger the bug.

[-] Nicolas-Rougier@alien.top 1 points 10 months ago

Nice. And since org-string-width can return pixel width, it might adapted to proportional font as well.

[-] whudwl@alien.top 1 points 10 months ago

AHH. I see, my :PROPERTIES: is not indented. my org-adapt-indentation is set to nil.

this post was submitted on 27 Nov 2023
1 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS