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

Emacs

311 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
 

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
[–] [email protected] 1 points 11 months ago (4 children)

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

[–] [email protected] 1 points 11 months ago (3 children)

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

[–] [email protected] 1 points 11 months ago (1 children)

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

[–] [email protected] 1 points 11 months 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)