File Local Variables in an Org File

A nice tip from Artur Malabarba: It’s often convenient to use file local variables in your Emacs files. It provides a way of setting certain Emacs variables—mode, fill-column, comment-column, etc.—on a per file basis.

There’s a problem, though, when using them in an Org file. Org considers anything after a heading to be part of that heading’s subtree. Thus, if you move the node that the file local variables are in, they get dragged along with the node. The answer, Malabarba says, is to put the file local variables in their own COMMENT subtree. Those subtrees don’t get exported so it’s a perfect solution when using Org to write text intended for export to HTML, LaTeX, Word, and so forth.

Malabarba also gives us a bit of Elisp to make navigating such a buffer easier. If you often use file local variables in Org files, you will probably want to add his code to your Emacs configuration.

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