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

Emacs

313 readers
2 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
 

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
[–] llcc_reddit@alien.top 1 points 1 year ago (4 children)

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

[–] Nicolas-Rougier@alien.top 1 points 1 year ago (3 children)

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 1 year ago (1 children)

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

[–] Nicolas-Rougier@alien.top 1 points 1 year ago

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

load more comments (1 replies)
load more comments (1 replies)