Set the safe-local-variable property to a function that validates the value. For example, fill-column has a safe-local-variable property set to integerp. Use (lambda (x) t) as the validation function if any value is valid.
(defvar my-variable-with-any-safe-value …)
(put 'my-variable-with-any-safe-value 'safe-local-variable
(lambda (x) t))
For closure, here is an answer that expands upon my comment. I define a minor mode with the required keybinding and toggle it in the required buffer using file local variables.
"Minor mode to simulate buffer local keybindings."
(define-key my-org-buffer-local-mode-map (kbd "<f10>...
18 years ago, you were right to be worried. But time has marched on. Since Emacs 22, there is a decent built-in mechanism to whitelist safe local variables. The details are documented in the Emacs Lisp manual. The most important aspects are:
Lisp authors can declare safe values for each variable. This is a whitelist: if the Lisp programmer hasn't done ...
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 ...
What you're looking for are File Variables, specifically you want to look at Specifying File Variables in the Emacs Manual.
There are two ways to specify File Variables. The more "modeline magic like" of the two requires you to surround your variable list with with -*- characters. An example combining emacs and vim functionality could look like:
/* -*- ...
Emacs is pretty safe when it comes to local variables. It does not actually evaluate anything for file- or directory-local variables, it only parses Lisp syntax. Also, a variable has to be declared "safe" before it will be set by Emacs, and that declaration also includes a predicate. So a variable can say "a file may set this, but only if it is a string".
You can do this for a specific buffer with M-x auto-revert-mode (manual). For file buffers, this will check every auto-revert-interval seconds (defaults to 5) for changes and update the buffer from disk automatically.
Your title says "a particular file" while your question's body mentions a file type (org files). Depending on your circumstances, here are a ...
I've grepped my ~/.emacs.d/elpa for mangle-whitespace and noticed it's used in a few packages which are all written by Roland Walker. Then I proceeded downloading the tarballs for Emacs 22.1 to Emacs 24.4 (because these are the Emacs version Roland Walker supports with his packages) and grepped them for this variable, but without any luck.
That's why I've ...
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:,...
You can customize safe-local-variable-values in your init file. This will require you to also specify which values you consider safe.
(add-to-list 'safe-local-variable-values '(var . value))
This is OK if you know the set of possible values, as your question implies you do.
If you want to make a variable safe for all values that satisfy a predicate, you ...
Based on a quick check of C-hig (emacs) Specifying File Variables, I'm reasonably sure that you can't.
I think your options are:
Move the comment outside of the local variables block.
Change the variable (e.g. give it a prefix like DISABLED:) such that the value is simply assigned to a variable which nothing uses.
If you don't want to have to ...
I think you need to put the local variables in two places, which is the org file and the bib file. The issue is that the notes functions are called while the bibtex buffer is active, so the local variables in the org file do not affect them.
In my org file I put something like
* File Local Variables
# Local Variables:
# org-ref-bibliography-notes: "/Users/...
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 need to define the variable org-time-stamp-custom-formats, not to call a function. What you type after the variable name and colon is a value (what you might type after ').
-*- org-time-stamp-custom-formats: ("<%Y-%m>" . "<%Y-%m-%d %H:%M>") -*-
# Local Variables:
# org-time-stamp-custom-formats: ("<%Y-%m>" . "<%Y-%m-%d %H:%M>...
Take a look at the variables enable-local-eval and enable-local-variables. If you've changed one or both of these from their default values it could explain the behavior you are seeing.
For example if enable-local-eval is nil then that eval line in your file would be ignored.
The equivalent of Vi modelines in Emacs is file variables. As is often the case, the purpose of the feature is the same, but there are differences in the implementation details.
The basic syntax of Emacs file variables is a block delimited by -*- characters which must be on the first line of the file. Within this block, assignments of the ...
If the format of your file allows it, you can use a new page character (insert it with C-q C-l on its own line). Why it works is explained in the manual (info "(emacs) Specifying File Variables"). The relevant bit is quoted here:
Apart from using a ‘-*-’ line, you can define file local variables
using a “local variables list” near the end of the file. ...
A section with a COMMENT keyword is just that, a comment, not to be evaluated. So speaks the manual
Finally, a ‘COMMENT’ keyword at the beginning of an entry, but after
any other keyword or priority cookie, comments out the entire subtree.
In this case, the subtree is not exported and no code block within it
is executed either. [emphasis mine]
Firstly, all file-local and directory-local variables are (necessarily) buffer-local.
Here, Emacs is telling you that sh-indentation is buffer-local (with a value of 2) in that buffer.
You can trust that Emacs isn't lying to you, and that it's not ignoring the local value.
This should suggest to you that maybe the behaviour you're looking for is not ...
The following will work:
# Local Variables:
# org-time-stamp-custom-formats: ("<%Y-%m>" . "<%Y-%m %H:%M>")
# eval: (org-toggle-time-stamp-overlays)
Using (org-toggle-time-stamp-overlays) (C-cC-xC-t) to ensure they are properly displayed.
You will need to confirm that these are safe local variables for them to apply however once they are ...
Here is a generic way to set buffer-specific key bindings.
Create a temporary minor mode (save the below snippet to temp-mode.el and require it in your init.el.
Enable that temp-mode minor mode and define that minor-mode's keymap only in the buffer(s) you need.
Put the below Local Variables snippet in the buffer where you want the custom key binding. Below ...
Yes. Put this at the end of your file.
* COMMENT Config
eval: (auto-revert-mode 1)
This assumes Org-mode, for other modes use comments in the language used as explained in the link given below.
Note: see Local Variables in Files in the manual for the background, safety information and a caveat that this might not always be a good ...
I wouldn't be surprised if there's already a package out there that does it, but I couldn't find one. You should be able to cover most of it with something along the lines of the untested code below:
(defun my-hack-local-vim-props (&optional ...
The syntax for file-local variables requires -*- on both ends (OP is missing the closing one); the following works correctly:
# -*- mode: Python; python-indent-offset: 4; python-guess-indent: nil -*-
for i in range(0, 10):
def f( i ):
Also of interest may be the commands add-file-local-variable (adds the variable settings to the end ...
Looking at the source code in bytecomp.el, one can see that only safe file-local variables are read (see the relevant part of the file below).
This means that if you declare your variable as safe for file-local use, it should be read when you compile your file. You can for example evaluate the following piece of code before you byte-compile the file:
I usually do it by adding a commented heading to a file:
# -*- truncate-lines:1 -*-
But this can also be done as file-name specific hook:
(defun really-long-lines.org_file_hook ()
(when (string= (file-name-nondirectory (buffer-file-name)) "really-long-lines.org")
(add-hook 'find-file-hook 'really-long-lines....