Backup decisions seem to pass through the function normal-backup-enable-predicate
, via the variable backup-enable-predicate
which is set to this by default. You can provide your own function to return nil
if no backup is to be done.
For example,
(defun my-backup-enable-predicate (name)
(let (found)
(dolist (specialdir '("/somedir/" "/some/other/") found)
(if (string-prefix-p specialdir name)
(setq found t)))
(if found
nil
(normal-backup-enable-predicate name))))
(setq backup-enable-predicate #'my-backup-enable-predicate)
This tests if the provided full pathname begins with one of the listed directories (/somedir/
or /some/other/
in this example) and if so returns nil, otherwise calls the usual backup test function. The final line make emacs use your function. To go back to the real function use
(setq backup-enable-predicate #'normal-backup-enable-predicate)
I reread your question and realised I hadn't answered it. To allow you to set make-backup-files
in your .dir-locals.el
I think all you need is to make it buffer local in your startup file:
(make-variable-buffer-local 'make-backup-files)
The documentation says "Buffer-local bindings are normally cleared
while setting up a new major mode, unless they have a 'permanent-local'
property.". You can set this property with
(put 'make-backup-files 'permanent-local 't)