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?

Malabarba
  • 22,878
  • 6
  • 78
  • 163

3 Answers3

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.

itsjeyd
  • 14,586
  • 3
  • 58
  • 87
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.

Jonathan Leech-Pepin
  • 4,307
  • 1
  • 19
  • 32
6

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.

Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179