13

It is sometimes convenient to define file local variables with comments such as the following, which must be at the end of a file.

# Local Variables:
# fill-column: 80
# End:

However, in org-mode buffers, this comments are considered to be “inside” the very last headline. For instance, in the following buffer, the comments will be hidden whenever subtrees C or B are hidden.

* A
* B
** C

# Local Variables:
# fill-column: 80
# End:

I don’t really mind this hiding.
The real problem is that the comments will get carried along whenever I move the C subtree somewhere else. For instance, if I call org-refile on C, or if I move it around with org-metaup (and the likes), the comments are moved along with the subtree, and then they obviously stop working.

Is there a way to tell org-mode to stop doing this?

0

3 Answers 3

12

Based on a quick skim through the documentation on Org Syntax, I don't think there is a built-in way for doing this.

One possible workaround would be to add a top-level headline such as

* File-local variables

above the local variables section and tag it with :noexport:. Of course, the tag is only necessary if you are planning on exporting the parent document.


If you want to look into implementing a custom solution, looking at how org-mode uses the org-list-empty-line-terminates-plain-lists variable might be helpful. As the name suggests, when this variable is set to a non-nil value, a single empty line is enough to end a plain list, so it might be possible to get something similar working for subtrees.

3
  • 1
    I've been putting * The End (or ;;;* The End or similar) at the end of my Outline mode buffers. Nice to know about :noexport: for Org mode. Commented Oct 16, 2014 at 11:00
  • 8
    * COMMENT Local Variables also works for me.
    – rvf0068
    Commented Oct 16, 2014 at 13:29
  • 1
    I'ld recommend using COMMENT, as suggested by @rvf0068. That way, the whole headline with it's contents is treated as a true comment.
    – suvayu
    Commented Oct 16, 2014 at 16:13
9

I keep a top level headline at the end of my Org files called * Configuration.

I ensure it is tagged :NOEXPORT:ARCHIVE:

With this it does not get exported (thanks to the :noexport: tag) and additionally the content does not get revealed when cycling globally (thanks to the :ARCHIVE: tag).

I also put the various Org relation configuration options (#+TITLE:, #+AUTHOR, #+OPTIONS, etc) under this headline so they do not take up visual space unless I want to edit them.

7

I have averted this problem inadvertently as I always use some footnote in my documents. Doing C-c C-x f will insert a footnote and that will auto create * Footnotes section at the end of the buffer.

This is a special buffer and it is never exported as a section by org-mode. So you would never need to move this section around in the hierarchy.

Even if you don't use footnotes, it won't hurt to keep an empty * Footnotes section at the end as it would never export as a section.

Here is what I would do:

  • Do C-c C-x f
  • Give the footnote some text like "This is a dummy footnote.".
  • Delete the auto created reference [fn:1] from the main area (not the Footnotes section).

I suggested doing this as I am not sure if org-mode detects the presence of valid footnote descriptions in the Footnotes section to count it as a special section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.