I'd like to change the color of unchecked checkboxes in org-mode. To be exact, I want them to be displayed in the color of TODO keywords.

So I've tried to tackle this using custom-set-faces and :inherit, but this didn't have any effect:

(custom-set-faces '(org-checkbox ((t (:inherit org-todo)))))

Any idea how to do this properly?

  • 2
    Dunno. That looks OK to me. Maybe someone else has better eyesight. Have you started Emacs using emacs -Q? Maybe something else changes it later (?). What's the effect - no effect? Better question: Why not just use M-x customize-face? – Drew Oct 11 '18 at 13:50
  • @Drew Thanks! There was no effect. See my answer below. – Timm Oct 12 '18 at 9:12

@Drew was right: in some other part of my init.el, I had overwritten org-todo with custom-set-faces:

 '(org-todo ((t (:overline t))))) 

This seems to reset the :foreground property. Instead, I should have used:

(face-spec-set 'org-todo '((t (:overline t))))

See http://ergoemacs.org/emacs/elisp_define_face.html.

Eventually, however, I found an even better way, in my view, to highlight and discern checked and unchecked checkboxes. Based on the proposal here, the checkbox text is colorized rather than the brackets:

enter image description here

(defface org-checkbox-todo-text
    '((t (:inherit org-todo)))
    "Face for the text part of an unchecked org-mode checkbox.")

 `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?: \\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)" 1 'org-checkbox-todo-text prepend))

(defface org-checkbox-done-text
    '((t (:inherit org-done)))
    "Face for the text part of a checked org-mode checkbox.")

 `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)" 1 'org-checkbox-done-text prepend))

you missed the :foreground nil, corrected code snippet according to the requirement

(custom-set-faces '(org-checkbox ((t (:foreground nil :inherit org-todo)))))

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.