<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/assets/atom.xsl" type="text/xsl"?><feed
	xmlns="http://www.w3.org/2005/Atom"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	xml:lang="en-US"
	><title>Sacha Chua - tag - tweak</title>
	<subtitle>Emacs, sketches, and life</subtitle>
	<link rel="self" type="application/atom+xml" href="https://sachachua.com/blog/tag/tweak/feed/atom/index.xml" />
  <link rel="alternate" type="text/html" href="https://sachachua.com/blog/tag/tweak" />
  <id>https://sachachua.com/blog/tag/tweak/feed/atom/index.xml</id>
  <generator uri="https://11ty.dev">11ty</generator>
	<updated>2014-03-27T12:00:32Z</updated>
<entry>
		<title type="html">Emacs tweaks: Export Org checkboxes using UTF-8 symbols</title>
		<link rel="alternate" type="text/html" href="https://sachachua.com/blog/2014/03/emacs-tweaks-export-org-checkboxes-using-utf-8-symbols/"/>
		<author><name><![CDATA[Sacha Chua]]></name></author>
		<updated>2014-03-29T03:55:47Z</updated>
    <published>2014-03-27T12:00:32Z</published>
    <category term="emacs" />
<category term="org" />
<category term="tips" />
		<id>https://sachachua.com/blog/?p=27119</id>
		<content type="html"><![CDATA[<div class="update">UPDATE 2014-03-28: Newer versions of org have the <code>org-html-checkbox-type</code> variable, which you can set to <code>unicode</code>. Use <kbd>M-x customize-variable org-html-checkbox-type</kbd> to see if you have it.</div>
<p>This snippet turns <code>- [X]</code> into ☑ and <code>- [ ]</code> into ☐.</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span class="org-keyword">defun</span> <span class="org-function-name">sacha/org-html-checkbox</span> (checkbox)
  <span class="org-doc">"Format CHECKBOX into HTML."</span>
  (<span class="org-keyword">case</span> checkbox (on <span class="org-string">"&lt;span class=\"check\"&gt;&amp;#x2611;&lt;/span&gt;"</span>) <span class="org-comment-delimiter">; </span><span class="org-comment">checkbox (checked)</span>
        (off <span class="org-string">"&lt;span class=\"checkbox\"&gt;&amp;#x2610;&lt;/span&gt;"</span>)
        (trans <span class="org-string">"&lt;code&gt;[-]&lt;/code&gt;"</span>)
        (t <span class="org-string">""</span>)))
(<span class="org-keyword">defadvice</span> <span class="org-function-name">org-html-checkbox</span> (around sacha activate)
  (setq ad-return-value (sacha/org-html-checkbox (ad-get-arg 0))))</pre>
</div>
<p>To find this code, I searched <code>ox-html.el</code> for <code>[</code>. Eventually I found <code>org-html-checkbox</code>, which is directly called by <code>org-html-format-list-item</code> instead of being a function variable that you can change. So that meant I needed to override the behaviour of <code>org-html-checkbox</code> through <code>defadvice</code>. You can see above how I wrap advice around <code>org-html-checkbox</code> and replace the return value with my own function. For more about advice, read the Emacs Lisp Intro manual.</p>
<p>To find the hex codes for the UTF-8 characters, I searched Google for <a href="https://www.google.ca/search?q=utf8+checkbox+check">UTF-8 checkbox</a> and found <a href="http://www.fileformat.info/info/unicode/char/2611/index.htm">BALLOT BOX WITH CHECK</a>. 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!</p>
<p>Inspired by Grant from <a href="http://www.wisdomandwonder.com/article/8284/creation-and-conservation-of-computer-files-c3f/comment-page-1#comment-1086101">Wisdom and Wonder</a>.</p>
<p>You can <a href="https://sachachua.com/blog/2014/03/emacs-tweaks-export-org-checkboxes-using-utf-8-symbols/#comment">view 7 comments</a> or <a href="mailto:sacha@sachachua.com?subject=Comment%20on%20https%3A%2F%2Fsachachua.com%2Fblog%2F2014%2F03%2Femacs-tweaks-export-org-checkboxes-using-utf-8-symbols%2F&body=Name%20you%20want%20to%20be%20credited%20by%20(if%20any)%3A%20%0AMessage%3A%20%0ACan%20I%20share%20your%20comment%20so%20other%20people%20can%20learn%20from%20it%3F%20Yes%2FNo%0A">e-mail me at sacha@sachachua.com</a>.</p>]]></content>
		</entry>
</feed>