Is there an Emacs variable to disable backing up files with a specific extension?

For example, when editing various data files, the backup data is useless and actually pull out our tools. Therefore, I would like to disable backing up files containing regexp in the name.

justinhj

+5
source share
3 answers

I don't like just linking to other online resources for such questions, but this seems to be ideal for your needs.

http://anirudhs.chaosnet.org/blog/2005.01.21.html

, , .emacs .emacs.d/init.el emacs:

(setq auto-mode-alist (append '(("\\.ext1$" . sensitive-mode)) auto-mode-alist))
(setq auto-mode-alist (append '(("\\.ext2$" . sensitive-mode)) auto-mode-alist))
(setq auto-mode-alist (append '(("\\.ext3$" . sensitive-mode)) auto-mode-alist))
(setq auto-mode-alist (append '(("\\.ext4$" . sensitive-mode)) auto-mode-alist))

\\.ext1$, \\.ext2$ .. , , .

+9

emacs / .

http://amitp.blogspot.com/2007/03/emacs-move-autosave-and-backup-files.html

(defvar user-temporary-file-directory
  (concat temporary-file-directory user-login-name "/"))
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
      `(("." . ,user-temporary-file-directory)
        (,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
      (concat user-temporary-file-directory ".auto-saves-"))
(setq auto-save-file-name-transforms
      `((".*" ,user-temporary-file-directory t)))
+3

Emacs, :

(defvar my-backup-ignore-regexps (list "foo.*" "\\.bar$")
  "*List of filename regexps to not backup")

(defun my-backup-enable-p (name)
  "Filter certain file backups"
  (when (normal-backup-enable-predicate name)
    (let ((backup t))
      (mapc (lambda (re)
              (setq backup (and backup (not (string-match re name)))))
            my-backup-ignore-regexps)
      backup)))

(setq backup-enable-predicate 'my-backup-enable-p)
+3

All Articles