0

Is it possible to change the face of list bullets dynamically, mimicking the behaviour of WYSIWYG textprocessors like MS Word?

enter image description here

  • 1
    You cannot change them in the buffer (parsing requires that the bullets are fixed), but you can certainly overlay any symbol you want: that just changes the display without changing the text of the buffer. See e.g. this thread in the ML. – NickD Oct 24 '18 at 22:31
  • I think the org-bullets package does something very similar to this. – Omar Nov 4 '18 at 15:12
1

Following NickD's advice, I've changed the look of list bullets using overlays:

(font-lock-add-keywords
 'org-mode
 '(("^[[:space:]]*\\(-\\) "
        (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))

Furthermore, I've increased the indentation offset in order to emphasize the degree of embedding:

(setq-default org-list-indent-offset 4)

I'm happy with the result, even though it's not exactly what I was looking for in my question:

enter image description here

COMMENT:

Of course, with this approach, one could get closer to the intended look with the following:

(setq-default org-list-indent-offset 4)

(font-lock-add-keywords
 'org-mode
 '(("^\\(-\\) "
        (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))

(font-lock-add-keywords
 'org-mode
 `((,(concat "^[[:space:]]\\{" (number-to-string (+ 2 org-list-indent-offset)) "\\}\\(-\\) ")
        (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "◦"))))))

(font-lock-add-keywords
 'org-mode
 `((,(concat "^[[:space:]]\\{" (number-to-string 
                                (* 2 (+ 2 org-list-indent-offset))) "\\}\\(-\\) ")
        (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "▸"))))))

(font-lock-add-keywords
 'org-mode
 `((,(concat "^[[:space:]]\\{" (number-to-string 
                                (* 3 (+ 2 org-list-indent-offset))) "\\}\\(-\\) ")
        (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "▹"))))))

enter image description here

But this presupposes that the indentation is accurate in terms of the number of spaces. The best solution would be to make the font-lock depend on the logical embedding level using something like (org-list--depth (org-element-at-point)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.