Hot answers tagged

24 votes
Accepted

Put all backups into one backup folder

Check out backup-directory-alist, which allows you to set backup locations by file regexp. To have everything go to one directory, try something like: (setq backup-directory-alist '(("." . "~/...
  • 4,998
16 votes

Put all backups into one backup folder

The following is a quick code from my .emacs. It does not only put backups into a specific directory, but also auto-saves, and does the same for tramp files so those are not put onto the remote system....
15 votes
Accepted

Turn off automatic backups for specific files

You can customize the location through backup-directory-alist. Each entry in the list says where to put the backups of files matching a pattern; if the location is nil, the backup will be in the same ...
8 votes
Accepted

Automatic deletion of backup files

You can make all backup files to go a directory with (setq backup-directory-alist `(("." . "~/.emacs.bak"))) and turn it off completely with (setq make-backup-files nil) although nobody will ...
  • 2,167
7 votes
Accepted

version control using the usual backup system of Emacs

Here are two alternative answers, which both come from reading the Emacs manual, node Backup Names: Set variable version-control to nil, and then create a numbered backup for each of your "important" ...
  • 70.9k
5 votes

Backup saved buffers to Dropbox (or other specific directory)

Emacs has a built-in backup mechanism, which is what makes all the "~" files Emacs likes to leave around anywhere. You can tell Emacs to put all the backup files in a single directory with (setq ...
  • 12.3k
5 votes

Emacs backups - why backup all files to a single directory?

There is no accounting for taste.
  • 12.5k
4 votes
Accepted

How can I back up my init file with Git?

There is no need to to turn your whole home into a repo. .emacs.d will be enough, and cloning it whatever you go will do it too. Supposing that your .emacs.d is a repo, to do that your .gitignore ...
  • 2,406
4 votes
Accepted

How can backup-directory-alist be set to save in the files directory?

Just use relative directory name (setq backup-directory-alist '(("." . "editorbackups"))) Function make-backup-file-name-1 will make directory name relative to file's directory and create it: ;; If ...
  • 2,195
4 votes
Accepted

recover backup files

Le Wang's backup-walker library facilitates this: traverse incremental diffs between backup versions open backup in traversal mode if the diff seems interesting traverse backups ...
  • 44.2k
4 votes
Accepted

Backup saved buffers to Dropbox (or other specific directory)

Here is a very rudimentary example (tested on OSX, and may work on other Unix flavor systems). It is possible to write an entire library surrounding this concept, and this example is certainly not ...
  • 17.9k
4 votes

Automatic deletion of backup files

dired makes it easy to delete all the backup files in a directory--from dired, just type ~ to mark backup files for deletion and x to execute the deletion.
  • 4,998
4 votes

Put all backups into one backup folder

;; put all backup files into ~/MyEmacsBackups (setq backup-directory-alist '(("." . "~/MyEmacsBackups"))) (setq backup-by-copying t)
  • 141
3 votes

Automatic deletion of backup files

From https://www.gnu.org/software/emacs/manual/html_node/emacs/Backup-Names.html#Backup-Names You can customize the variable backup-directory-alist to specify that files matching certain patterns ...
  • 279
3 votes
Accepted

How to stop auto backup in some directory in Emacs

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 ...
  • 160
2 votes
Accepted

Spacemacs/org-mode with nvAlt: disabling numbered backups

Those numbered files are created by nvALT when Emacs and nvALT both attempt to write to the same file. When there's a conflict, nvALT creates those files to prevent data loss. Remember, nvALT saves ...
2 votes

recover backup files

How about this: (defun revert-to-backup () "Reverts to the latest backup file associated with the current buffer." (interactive) (let ((file (buffer-file-name))) (when file (let ((bak ...
  • 19.5k
2 votes
Accepted

Disable auto-backup only for certain files

According to my test, simply set make-backup-files to nil locally, for example, M-x add-file-local-variable-prop-line make-backup-files nil
  • 13.8k
2 votes
Accepted

Set variable not been read from .emacs

To set variables in Emacs use: (setq version-control t) ;; Use version numbers for backups. (setq kept-new-versions 10) ;; Number of newest versions to keep. (setq kept-old-versions 0) ;; ...
  • 3,413
2 votes

I can't backup some orgmode files

If your org files are under version control (which I would recommend) then vc-checkin sets backup-inhibited to t. This makes sense as my .org files are all under version control and don't need the ~ ...
  • 422
2 votes
Accepted

Creating backup and auto-save files that are not hidden

What do you mean by the files being "hidden"? Hidden where, how? You can specify the file names you want for backup files, if something is causing them to be somehow "hidden" based ...
  • 70.9k
2 votes

How does emacs write files?

As an answer I cite here mostly the comments of the normal execution path in basic-save-buffer-2 which is the working horse of save-buffer: ;; Write temp name, then rename it. ;; This ...
  • 30.7k
1 vote

How to ignore backup files (~) when running grep?

You can modify the pattern match to exclude file with names ending in ~ via [^~]. When M-x grep prompts you for the grep command, use something like: grep match-text ./path/*[^~]
  • 20.7k
1 vote
Accepted

change auto-save directory

You should probably have a more explicit regex in auto-save-file-name-transforms. The regex matches against the buffer file name. So what's happening in your case is Your buffer filename is: "/home/...
  • 2,368
1 vote

How to ignore backup files (~) when running grep?

You could put your backup files somewhere else. When you do a grep emacs will ask for the root directory for the search, defaulting to the current directory. You could specify a directory for the ...
  • 184
1 vote
Accepted

How do I prevent backups of scripts from being made executable?

The variable backup-directory-alist tells emacs where to save the backups. Adding the following to your init file will set its value only if the executable bit is set. (defun make-executable-backup-...
  • 1,713
1 vote

Prevent creation of backup org file

Customize option make-backup-files to nil. See the Emacs manual, node Backup. You could find this information yourself by asking Emacs: Open the Emacs manual: C-h r Consult the index: i backup TAB. ...
  • 70.9k
1 vote
Accepted

How to set auto-save and backup path as subdirectory sibling of a given open file?

This will configure things to save both backup and auto-save files to an emacs-backups directory relative to the file you are visiting. (let ((dir "emacs-backups")) (setq auto-save-file-name-...
  • 19.5k
1 vote

Change naming scheme for backup files

You can customize themake-backup-filename-function variable to do this, using the existing make-backup-file-name and make-backup-file-name-1 as examples. If you don't need to support msdos etc then ...
  • 1,859

Only top scored, non community-wiki answers of a minimum length are eligible