Hot answers tagged

17

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 ...


14

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") (auto-saves-dir "~/tmp/emacs/...


14

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\\'") ("."...


13

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 ...


8

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 ...


7

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 ...


7

Emacs provide lgrep and rgrep as convenient interfaces for grep. These commands may invoke grep on the command line with grep options systematically (see also the GNU Emacs Reference Manual). More specifically, the user option grep-find-ignored-files (discovered after searching in the source code and in the integrated documentation) may be set to ignore some ...


4

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: /* !init.el !.gitignore First line tells git to ignore everything, second line tells git that init.el shouldn't be ignored. Third line prevents ...


4

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. (if ...


4

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

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") "NOTE: `directory-...


4

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 ...


4

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 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 ...


3

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/") ...


3

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 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 ...


2

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


2

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 ...


2

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 (file-newest-backup (buffer-file-name)))) (if bak (progn (delete-region (point-min) (point-max)) (insert-file-...


2

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


2

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 ...


2

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).


2

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 ...


2

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.


1

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/*[^~]


1

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 ...


1

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"))) ...


1

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-file-name (file) "docstring" (if (file-executable-p file) (let ((backup-directory-alist '(("." . "~/.emacs.d/executable-backup")))) (make-...


1

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. Choose completion candidate backup file. That takes you to node Backup of the manual, where this option (and more) is described.


1

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-transforms `(("\\([^/]*/\\)*\\([^/]*\\)\\'" ,(concat dir "/\\2"))) backup-directory-alist `((".*" . ,dir)))) Note that for backup files you can just specify ...


1

@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 ...


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