3

Q: how can I get a different face for checked-off items in org plain lists?

I use org-mode's plain lists a lot:

- [X] item 1
- [ ] item 2
- [ ] item 3
- [ ] item 4, with a whole lot of text that makes this item
  span more than one line

The problem is that I find that the checkboxes do not give enough visual cues that I have or have not completed an item.

Is there a way to apply a different face to checked-off list items (in the example, "item 1") while leaving the face alone for non-checked items?

A built-into-org way to do so would be ideal, but if I need to roll my own functionality, a complicating feature is that my items often span more than one line (as with "item 4..."). How can I do this?

2
  • You can add an appropriate checked-off statement in org-set-font-lock-defaults, just beneath the existing statement relating to checkboxes at the section with the comment ;; Checkboxes; and, perhaps modify the existing checkbox statement so that it only operates on unchecked items. While modifying org-set-font-lock-defaults probably seems sacrilege, that is actually the proper way to do it (in my opinion, of course).
    – lawlist
    Commented Dec 3, 2019 at 17:47
  • In addition to the above comment, you may also need to have a look at the section of code in org-mouse.el where it states (when (memq 'activate-checkboxes org-mouse-features) ... Modifications at that location may be appropriate ...
    – lawlist
    Commented Dec 3, 2019 at 17:55

1 Answer 1

0

From https://fuco1.github.io/2017-05-25-Fontify-done-checkbox-items-in-org-mode.html :

(defface org-checkbox-done-text
    '((t (:foreground "#71696A" :strike-through t)))
    "Face for the text part of a checked org-mode checkbox.")
  (font-lock-add-keywords
   'org-mode
   `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)"
      1 'org-checkbox-done-text prepend))
   'append)

unfortunately it only matches the first line, patches welcome ;)

But at least you can collapse list items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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