In a particular org-mode file, I do not want tags to be inherited. I thought putting -*- org-use-tag-inheritance: nil
for the first line would do the trick, but that doesn't seem to be working. Short of manually executing a setq
statement, how can I make this happen?
Asked
Active
Viewed 1.3k times
27

Brian Z
- 875
- 1
- 13
- 20
3 Answers
33
You're missing a trailing -*-
in the header comment.
Try this:
# -*- org-use-tag-inheritance: nil; -*-
n.b. It's easy to check whether local variables were actually set the way you expected -- just use C-h v VAR
for the VAR in question, and Emacs tells you if it has a buffer-local value.

phils
- 71,335
- 11
- 153
- 198
-
1In case, the above solution doesn't work for you. You might try this: https://stackoverflow.com/a/47779538/126164 – Yu Shen Dec 12 '17 at 18:51
-
7I recommend using a built-in function (`M-x add-file-local-variable-prop-line`) for automatically adding a line that defines buffer-local variables. Easy to use and worked for me. – Guilherme Salomé Jun 18 '20 at 18:48
-
2Also, notice that according to [this docs page](https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html), the variables defined with `-*-` need to be specified in the **1st line** of the file. If you move the definition of the buffer-local variables to the 2nd line, it may not work. – Guilherme Salomé Jun 18 '20 at 18:56
-
1Usually true; but if the first line is a shebang (e.g. `#!/bin/sh`) then the file-locals are looked for on the second line as well, because the first line is reserved for the interpreter command. – phils Jun 18 '20 at 21:07
15
I prefer the setting in-buffer lisp variables at the file end, like this:
* Local variables
# local variables:
# org-attach-directory: "./data"
# org-id-method: uuid
# end:

vfclists
- 19,193
- 21
- 73
- 92

Dieter.Wilhelm
- 485
- 6
- 9
-
12You could use `* COMMENT Local variables` to make sure this heading will not be exported. – mpm Nov 06 '17 at 12:23
11
A further alternative is a section Local Variables
with the :noexport:
tag at the end of the orgmode file:
* Local Variables :noexport:
Local Variables:
org-use-tag-inheritance: nil
End:
The advantage of this method is that the local variables are not part of the last regular section of the orgmode document but are logically separated from the rest of the document by a special section.

Tobias
- 5,038
- 1
- 18
- 39
-
I use this method and prefer it. However, when refiling to a file with such a heading the refiled item will end up at the bottom which might inactivate the file local variables. Just something to keep in mind. – JohanT Aug 24 '21 at 08:55