More posts about: emacs, org, tips Tags: tips, tweak // 7 Comments »
org-html-checkbox-typevariable, which you can set to
unicode. Use M-x customize-variable org-html-checkbox-type to see if you have it.
This snippet turns
- [X] into ☑ and
- [ ] into ☐.
(defun sacha/org-html-checkbox (checkbox) "Format CHECKBOX into HTML." (case checkbox (on "<span class=\"check\">☑</span>") ; checkbox (checked) (off "<span class=\"checkbox\">☐</span>") (trans "<code>[-]</code>") (t ""))) (defadvice org-html-checkbox (around sacha activate) (setq ad-return-value (sacha/org-html-checkbox (ad-get-arg 0))))
To find this code, I searched
[. Eventually I found
org-html-checkbox, which is directly called by
org-html-format-list-item instead of being a function variable that you can change. So that meant I needed to override the behaviour of
defadvice. You can see above how I wrap advice around
org-html-checkbox and replace the return value with my own function. For more about advice, read the Emacs Lisp Intro manual.
To find the hex codes for the UTF-8 characters, I searched Google for UTF-8 checkbox and found BALLOT BOX WITH CHECK. I used the hex code so that I didn’t have to worry about encoding issues. I tested it by updating one of my weekly reviews. Tada!
Inspired by Grant from Wisdom and Wonder.