January 21, 2005 5:53 PM
It makes sense to disable creation of backup files and auto-save
when editing sensitive files in Emacs. Especially on a remote system
where resources are limited.
Put this in your .emacs
to permanently disable backups and
auto-save:
;disable backup (setq backup-inhibited t) ;disable auto save (setq auto-save-default nil)
If you prefer disabling these features only when editing certain types of files, this minor mode ought to help:
(define-minor-mode sensitive-mode "For sensitive files like password lists. It disables backup creation and auto saving. With no argument, this command toggles the mode. Non-null prefix argument turns on the mode. Null prefix argument turns off the mode." ;; The initial value. nil ;; The indicator for the mode line. " Sensitive" ;; The minor mode bindings. nil (if (symbol-value sensitive-mode) (progn ;; disable backups (set (make-local-variable 'backup-inhibited) t) ;; disable auto-save (if auto-save-default (auto-save-mode -1))) ;resort to default value of backup-inhibited (kill-local-variable 'backup-inhibited) ;resort to default auto save setting (if auto-save-default (auto-save-mode 1))))
Once the above snippet has been evaluated in Emacs, M-x sensitive
will disable backups and auto-save in the current buffer. All
other buffers will continue to have these features.
I usually set sensitive mode to turn on by default for files having
the gpg
extension. The following code when put in your .emacs
does
exactly that:
(setq auto-mode-alist
(append '(("\\.gpg$" . sensitive-mode))
auto-mode-alist))