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 at 13:50
  • @Drew Thanks! There was no effect. See my answer below. – Timm Oct 12 at 9:12
up vote 2 down vote accepted

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

(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.")

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

(defface org-checkbox-done-text
    '((t (:inherit org-done)))
    "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)

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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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