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 '(("." . "~/MyEmacsBackups")))
For the truly paranoid (like myself), there's also backup-each-save, which (as the name suggests) backs up your files each time they're saved in a ...
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.
;; Put backup files neatly away
(let ((backup-dir "~/tmp/emacs/backups")
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 directory as the original. The order matters: the first match is used.
(setq backup-directory-alist '(("-autoloads\\.el\\'")
I'm afraid this is not straightforward to do considering F1 v create-lockfiles takes you to filelock.c which only exposes this variable and temporary-file-directory. So, to have this behaviour you'd either need to replace nearly all functions exposed in that file with your own Emacs Lisp functions or hand in a bug via M-x report-emacs-bug and hope for the ...
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 recommend that.
Making backups for only some projects is not easy: you'll have to flip that variable in various hooks.
Finally, asking for bulk deletion is exactly ...
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" files (only). Files that already have numbered backups will continue to get them. Other files will not get numbered backups.
"[S]et version-control locally ...
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 should look like:
First line tells git to ignore everything, second line tells git that init.el shouldn't be ignored. Third line prevents ...
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 backup-directory is relative, it should be relative to the
;; file's directory. By expanding explicitly here, we avoid
;; depending on default-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 meant to be an all inclusive solution -- it is just an idea put on paper so to speak:
(defvar backup-repo (directory-file-name "/private/tmp")
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 backup-directory-alist (list '("." . "/path/to/backups")))
backup-directory-alist is a list of pairs (PATTERN . PATH) where PATTERN is a regexp matching the file ...
Le Wang's backup-walker library facilitates this:
traverse incremental diffs between backup versions
open backup in traversal mode if the diff seems interesting
Once a backup is opened, traversing amongst backups is easy using the same keys.
the point kept the same as much as possible while traversing backups as ...
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.
(defun my-backup-enable-predicate (name)
(dolist (specialdir '("/somedir/" "/some/other/") ...
You can customize the variable backup-directory-alist to specify that
files matching certain patterns should be backed up in specific
directories. This variable applies to both single and numbered
backups. A typical use is to add an element ("." . dir) to ...
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 files automatically, so if you have it open at the same time as Emacs, you may run into conflicts, as well as these duplicate files.
Note that Emacs has its ...
How about this:
(defun revert-to-backup ()
"Reverts to the latest backup file associated with the current buffer."
(let ((file (buffer-file-name)))
(let ((bak (file-newest-backup (buffer-file-name))))
(delete-region (point-min) (point-max))
@xuchunyang solved this (see the comments section):
"When the global minor mode helm-mode is off (it is by default), the behavior of completion-at-point will not be changed by helm at all. If you want to turn on helm-mode and don't want it to change completion-at-point, customize user option helm-completing-read-handlers-alist."
I had success when ...
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) ;; Number of oldest versions to keep.
(setq delete-old-versions t) ;; Don't ask to delete excess backup versions.
(setq backup-by-copying t) ;; Copy all files, don't ...
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 ~ backup. (I use Version Control Always and SRC - Simple Revision Control
If you really want the ~ backups as well, then M-: (setq-local backup-inhibited nil).
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 requires write access to the containing dir,
;; which is why we don't try it if we don't have that access.
;; Create temp files with strict access ...
Did you clobber your original ~/.emacs.d/ directory? You may have lost all manner of things if you've done that.
Assuming you backed it up first, just grab the ~/.emacs.d/bookmarks file from your backup.
If there's no such file, check C-hv bookmark-default-file to see what it was actually called.
The Emacs manual (C-h r) is your friend for such a question. Use i in the manual to look something up in the index. For example, i auto save lets you get to node Auto Save, and the first item in the menu there takes you to node Auto-Save Files.
There you get a complete description of what these files are, what they are for, how to recognize them, how to ...
As mentioned by Drew, the files in question are auto-save files, which are distinct from backup files. Unfortunately for some reason, there is no index entry for # pointing to Auto Save Files in the emacs manual, hence my confusion.
My solution was simply to also change the location auto-save files are saved to, namely a hidden directory in my home ...
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 on their names (use different names). See the Emacs manual, node Backup Names.
And if you're talking about auto-save files, then see node Auto Save Files.
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/SchoolServer/UserID/Projects/char_tst/charscript/define_transistors.tcl"
Your regex is: ".*" ie. "zero or more characters"
That regex will match the start of the ...
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 backup files that is outside the places you usually search. You can do this by setting backup-directory-alist.
(setq backup-directory-alist `(("." . "~/.saves")))