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))
The comment from @Malabarba explains your problem.
kill-local-variable does get rid of the local variable binding. But since in your case the variable is automatically local in any buffer, when you reassign it a value, that value is local.
AFAIK, there is no way to counter make-variable-buffer-local, except to use unintern on the symbol. (makunbound does ...
The good way
Simply do not use Sh Mode for buffers which do not contain shell scripts. Write your own mode instead. This is the canonical way to handle such situations in Emacs.
Write a custom major mode is easy. You can simply inherit from Sh Mode to get all of its features and commands, while still having an independent mode. Just add the following ...
It sounds like your goal is to have org-mode files always show everything when in ediff. The simplest solution is probably to avoid the local variables approach and just put show-all in the relevant hook, ediff-prepare-buffer-hook which is run after buffers A, B, & C are set up:
(add-hook 'ediff-prepare-buffer-hook #'...
When you call add-dir-local-variable, it assumes you are already in the directory you want to apply the directory-local variable to. When it prompts for a directory, it's asking if you want the variable applied to a subdirectory of your current directory.
So I expect giving it the absolute path to a directory is causing your problem. In your case, I think ...
Emacs should offer (and normally does offer) the option to accept and remember the choice for later sessions. I suggest you M-x report-emacs-bug about this missing choice in your case.
In the mean time, you can add the following to your ~/.emacs:
'(LaTeX-command . "lualatex -shell-escape"))
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 ...
In case someone else runs into this, I had enabled TeX-auto-save, which saves settings to an auto/ directory and loads them when a file is revisited.
You can use backquotes and commas to build functions dynamically:
(insert ,(cdr text)))
Or you can also enable lexical-binding to make function closures.
More information on Backquotes can be found in Emacs manual.
You can easily disable checkers using
(setq flycheck-disabled-checkers '(sh-shellscript sh-bash sh-zsh))
The Flycheck documentation adds more information here.
You can also disable checkers in a lambda for auto-mode-alist to have it only disable on .cfg files.
'("\\.cfg\\'" . (lambda ()
Based on the answer here, we do this by advising hack-dir-local-variables to look one directory up and load check if that .dir-locals.el file is readable. It will keep going up until it finds a directory with no readable .dir-locals.el.
Depending on the value of walk-dir-locals-upward the files can be read from the current directory upward or from the last ...
Directory-local variables were actually designed for this use case as well. Read the docs, especially at the end, where it discusses dir-locals-set-directory-class. The idea here is that you can keep the directory-local settings somewhere other than in the .dir-locals.el file.
Another way to accomplish this same thing is to make settings directory-...
Here's a different way of doing this.
I define a function that produces the list of all the directories in the
current directory hierarchy.
(defun file-name-directory-nesting-helper (name previous-name accumulator)
(if (string= name previous-name)
accumulator ; stop when names stop changing (at the top)
It is probably easier to turn off whitespace mode directly, using
Also, whitespace-style is not a buffer-local variable, so it is modified for all other buffers as well. Try instead
(set (make-local-variable 'whitespace-style) nil)
I think what you might do is to use properties of the variable symbol to store the history.
That is, each symbol can have a property list, which is a list of pairs. The key will be major mode names, and value the history as list you wanted.
But i don't know if that's efficient enough to work out.
Here's one way to do it:
(let ((a 2)) (pcase 2 ((pred (equal a)) 7)))
This snippet uses the fact that (rephrasing (describe-function 'pcase)) a predicate may have the form(FUN ARG1 .. ARGN) in which case it gets called with an N+1'th argument which is the value being matched.
You can use a hook to achieve this. Use the one you need as described in auctex documentation. Here we check the file extension so that we don't do that for eg .sty files. Also, we test the buffer-read-only variable before modifying the buffer.
The goto-char at the end ensures point is set at beginning of buffer.
(defun my/add-auctex-file-variables ()
I don't know how to enable/disable custom-themes for a buffer only. The following works for changing the global custom-theme when you enter a Tramp buffer, or when you leave it.
(if (and (not (window-minibuffer-p))
Another option can be found on the worg page. The basic idea is to use ediff-select-hook to unfold an element whenever given region is selected in ediff and folding them back in the ediff-unselect-hook. I am posting the code here for completeness
;; Check for org mode and existence of buffer
(defun f-ediff-org-showhide (buf command &rest cmdargs)
An alternative to pcase with similar features would also suffice
(let ((a 2))
(cond ((eq a 2)
;; => 7
This isn't a joke - everything that can be done with pcase can
also be done with a combination of let and cond.
And it think it should be - gratuitous branch-introducing macros
aren't helping anyone to either code faster or maintain
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 ...
Save your data as a window-parameter. It will force you to use :eval inside your mode-line, but that's not something to be afraid of.
If you want to discuss changes to the "core" Emacs features (like adding window-local variables), then the emacs-devel mailing-list is the place to do it. In this particular case I don't think there's much chance of success ...
Sounds like my-package-insert turns on a major mode. Doing that calls kill-all-local-variables.
You can give the variable a non-nil permanent-local property to protect it. But we would need more info to be able to suggest whether that is a good idea in your context.
If you don't need the variable to be bound before my-package-insert then consider binding ...
You can disable this "don't remember risky variables" feature by putting the following in your ~/.emacs:
;; allow remembering risky variables
(defun risky-local-variable-p (sym &optional _ignored) nil)
Then it'll only re-confirm when you edit one.
A variable is either buffer-local or not. If it's buffer-local then the value isn't shared with other buffers. There's no built-in feature to directly have a variable that's shared between buffers. So you'll need to do something where accessing the value of the variable isn't just my-variable and setting isn't just (setq my-variable some-value).
If you want to set a buffer-local value for a given mode, do so after the mode has been established. You do that by putting the value-assignment on the mode hook.
For example, if you want to set local variable foo to 42 in lisp-mode then do something like this:
(add-hook 'lisp-mode (lambda () (setq-local fill-paragraph-function 'my-fill-para)))
Or better ...