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 ...
Put a slash at the end of your string. It's a directory.
`((".*" "~/.emacs-saves/" t)))
The comma is used in the backquote notation.
(setq x 123)
(setq y `(my-x ,x))
(setq z (list 'my-x x)) ;; same as y
(defun my-instant-save-buffer (eins zwei drei)
"To be hooked into list `after-change-functions'
`after-change-functions' expects functions receiving three arguments.
Arguments are ignored here, but slots needed by add-hook"
(add-hook 'after-change-functions 'my-instant-save-buffer)
Those are lock files.
When two users edit the same file at the same time, they are likely to
interfere with each other. Emacs tries to prevent this situation from
arising by recording a file lock when a file is being modified. Emacs
can then detect the first attempt to modify a buffer visiting a file
that is locked by another Emacs job, and ask ...
I had the same requirement and auto-save feature of emacs hasn't worked well for me because it can't addadvice to c functions. So, I wrote a package real-auto-save for that. It is available on melpa.
You can install it by
M-x package-install RET real-auto-save
and in your config you can add
(add-hook 'prog-mode-hook 'real-...
This does not answer your question as posed, so feel free to ignore or downvote.
I doubt that you really want Emacs to save all buffers to disk, including all of the internal, normally invisible buffers. Why would you want that?
It's not about the disk space. It's about the noise. Do you really want to dig stuff out of a directory where your important ...
So how to make it save a file?
Put this in your init file
(setq auto-save-visited-file-name t)
so the saved file and the buffer file are the same. But this increases the risk of losing the file due to failures in autosave. You negate the redundancy gained from autosave.
Nanny's answer is correct, but I'd like to add that disabling lockfiles is not recommended.
They've been added to Emacs for a reason, the same reason that lockfiles were implemented for vim, LibreOffice, Microsoft Office and a host of other programs. Multiple programs editing the same file can be a real pain, leading to mass confusion and possibly nuclear ...
You'll notice that you're using a variable called auto-save-file-name-transforms. Since *scratch* has no filename, it falls back to autosaving in default-directory.
For the *scratch* buffer, or any other buffers like this with no filename, you can use:
(setq-local default-directory "~/.emacs.d/data/autosave")
Edit: I see that you don't really care about ...
You should read the appropriate section of the Emacs Manual, but here is a quick overview:
Auto-save is a safeguard to prevent you from losing changes that have not yet been saved, should Emacs crash or be killed in some way. As with everything in Emacs, the behavior is configurable.
Emacs will automatically save a copy of the buffer after:
a certain ...
I don't think there is a built-in mechanism for this, so you may need to roll your own.
Don't have a direct answer, but I have something similar in my config: I don't want to be prompted for confirmation when killing a file that matches what is on disk. To check this I'm running diff and then scanning the output -- you can probably do something similar for ...
You probably do not want it to save every N sec but to do that only after Emacs has been idle for N sec.
To do that, customize user option auto-save-timeout to the number of seconds, and turn on auto-save-mode.
See the Emacs manual (C-h r), node Auto Save and its children, especially node Auto Save Control.
See also the Elisp manual, node Auto-Saving, ...
From the Emacs manual:
Auto-saving does not normally save in the files that you visited,
because it can be very undesirable to save a change that you did not
want to make permanent. Instead, auto-saving is done in a different
file called the "auto-save file", and the visited file is changed only
when you request saving explicitly (such as with ‘C-...
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.
When Emacs exits, it saves buffers by calling save-some-buffers. This is the function that does the prompting. You can turn off the prompting in a buffer by setting the buffer-local variable buffer-save-without-query to t.
This will also save the buffer without asking if you press C-x s or when some other code calls save-some-buffers, which is probably ...
Turns out it has something to do with the plugin wakatime. Currently the workaround is to disable global-wakatime-mode when recovering a file and re-enable it afterwards. I've reported the issue but no reply yet.
You can enable auto-save-mode, so Emacs automatically saves your current buffer in a different file. Then, add this function to auto-save-hook to also write it directly on the actual file you are editing:
(defun save-buffer-if-visiting-file (&optional args)
"Save the current buffer only if it is visiting a file"
(if (and (buffer-...
I posted an email to the emacs-devel mailing list and the answer is amazingly simple. Just do M-x auto-save-mode.
I did that and now there is a file called #%2Ashell%2A#38994078EmN# in the directory. Another alternative they suggested is just write the shell buffer out to a file. i.e. C-x C-w /some/path and that will save the buffer to a file. In my ...
org-clock-in and org-clock-out have "hooks" associated with them --- lists of extra functions that run whenever you clock in/out. You can add your own functions (which will be called with no arugment) using add-hook:
(add-hook 'org-clock-in-hook #'save-buffer)
(add-hook 'org-clock-out-hook #'save-buffer)
I'm not actually sure what auto-save-buffers is/was; I can't see a reference to it (nor to it being removed).
However if I understand the question correctly, you could do this by ditching the require, and then replacing 'auto-save-buffers with (lambda () (save-some-buffers t)) in the timer call:
(run-with-idle-timer 5 t (lambda () (save-some-buffers t)))
When you use the -Q switch, you are telling emacs to not process both your init file AND the site init file. I suspect this prevents emacs from detecting and setting a default coding system. When emacs then tries to save a file, such as the eshell history file, it doesn't know what coding system to use.
I can think of two ways to solve this. The most ...
I temporarily solved the problem by deleting the file history located in ~\.eshell\. It appears that the entries of the last sessions of eshell are saved in this file. This solution is not satisfying as the problem can again arise.
Is there a way to just disable this message, but not the auto-saving functionality?
Yes, Emacs 27 will introduce the user option auto-save-no-message:
auto-save-no-message is a variable defined in ‘keyboard.c’.
Its value is nil
You can customize this variable.
This variable was introduced, or its default value was changed, in
version 27.1 of Emacs.
You can ensure do-auto-save is called with the correct argument to suppress the message by advising the function:
(defun my-auto-save-wrapper (save-fn &rest args)
(apply save-fn '(t)))
(advice-add 'do-auto-save :around #'my-auto-save-wrapper)
Backup and auto-save are different operations, controlled by different variables.
If you want to discard auto-save for files opened as root, you might change the buffer-local variable auto-save-file-name-transforms. Something like this (untested):
(when (and (stringp buffer-file-name)
I had the same problem and now I use:
(let ((my-auto-save-dir (locate-user-emacs-file "auto-save")))
`((".*" ,(expand-file-name "\\2" my-auto-save-dir) t)))
(unless (file-exists-p my-auto-save-dir)
(setq auto-save-default t
According to the suggestion by @lawlist, I ran M-x describe-variable RET timer-idle-list RET to find out that a function named deft-auto-save ran instantly after Emacs went idle. Setting
(setq deft-auto-save-interval 20)
did the trick. Apparently, this interval matters only for org files that were launched by deft. This explains why the autosaving ...
Emacs has cool feature - defadvice. You can surround any function with your own operation.
In this case, something along the lines of
(add-hook 'org-mode-hook (lambda ()
(defadvice org-clock-in (after org-clock-in-after activate) (save-buffer))
(defadvice org-clock-out (after org-clock-out-after ...