UP | HOME

Use unicode symbol to display org-mode checkboxes

With the help of prettify-symbols-mode, you can make your Emacs displaying org-mode checkboxes as a real Unicode symbols, instead of a boring text, put this to your org-mode-hook:

(add-hook 'org-mode-hook (lambda ()
  "Beautify Org Checkbox Symbol"
  (push '("[ ]" .  "☐") prettify-symbols-alist)
  (push '("[X]" . "☑" ) prettify-symbols-alist)
  (push '("[-]" . "❍" ) prettify-symbols-alist)
  (prettify-symbols-mode)))

You can also use font-lock-add-keywords to add a different style for checked boxes, like what I did below, adding a strike-through style:

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

Here's the result:

custom-org-checkboxes.png

Date: 2019-05-22 Wed 00:00

Author: Huy Tran

Created: 2019-05-22 Wed 12:23