Embedded Notes in Text

The other day, I ran across this 2009 Norwescon interview with Vernor Vinge. Irreal readers will be happy to know that he’s an Emacs user and writes his novels with it. The interview includes a screen shot of his work on The Children of the Sky.

One of the things that struck me was that Vinge embeds copious notes in the manuscript. His scheme looks homegrown to me. The story text is indented while each line of the notes starts with a ^. It’s easy to imagine a script or some elisp that extracts the story text from the manuscript. Vinge is, after all, a computer scientist.

That got me thinking. I use Org mode for all my writing and sometimes want to embed notes in the file along with the final text. How can I do the same thing that Vinge does? I sometimes embed a line or two of comments by starting them with a #. When the blog post, say, gets exported the lines beginning with # are not exported. For longer form writing with copious notes that’s not convenient. Click on that screen shot in the Vinge interview and you’ll notice that there are more notes than story text. I was looking for a way of doing what Vinge does with his system.

At first I thought I could use the tangle function but that works only with source code for one of the supported Babel languages. After a bit of research I discovered that you could include comments between BEGIN_COMMENT and END_COMMENT tags like this

#+BEGIN_COMMENT
Some notes
and other
comments
#+END_COMMENT

Sadly, there’s no Easy Template shortcut for it. No problem, I thought, I’ll take a look at the code and maybe advice it or do my own version. Happily, as soon as I started looking I found the answer. You can define your own Easy Templates by adding an entry to the org-structure-template-alist variable:

(add-to-list 'org-structure-template-alist
             '("n" "#+BEGIN_COMMENT\n?\n#+END_COMMENT"
               "<comment>\n?\n</comment>"))

Now I just type

<n

and 【Tab】 to be put in the middle of a comment region. This is a nice solution because, like reproducible research, you have everything in a single file and can export it to any of a number of formats including HTML, plane text, LaTex, and even ODT1. As usual, Emacs provides an environment that makes it easy to solve editing and workflow problems.

Footnotes:

1

I haven’t used the ODT export function yet but it could be useful to authors whose publishers require the manuscript be delivered as a Word document.

This entry was posted in General and tagged . Bookmark the permalink.