Skip to main content
Share Your Experience: Take the 2024 Developer Survey
9 votes

How to autosave a buffer to the original file on disk?

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 ...
Emacs User's user avatar
  • 5,653
6 votes
Accepted

Disabling the "Auto-saving...done" message

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 ‘...
Basil's user avatar
  • 12.5k
5 votes

How to autosave a buffer to the original file on disk?

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, ...
Drew's user avatar
  • 77.9k
5 votes
Accepted

save a particular buffer without prompting on emacs exit?

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-...
Gilles 'SO- stop being evil''s user avatar
4 votes
Accepted

How can I get Emacs to save the changes automatically each X seconds?

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 ...
Drew's user avatar
  • 77.9k
4 votes

Save an org-mode buffer when I clock in/out of a task

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)...
erikstokes's user avatar
  • 12.9k
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 ...
muffinmad's user avatar
  • 2,310
4 votes
Accepted

Global Auto Save Visited Mode

C-h v auto-save-visited-mode: Setting this variable directly does not take effect; either customize it or call the function auto-save-visited-mode. Use (auto-save-visited-mode) to enable it, (auto-...
shynur's user avatar
  • 5,328
3 votes
Accepted

Keep auto-save files out of directory

You can avoid the removal of the directory component of auto-save files by setting the UNIQUIFY component in the entries of the variable auto-save-file-name-transforms to nil. From the doc of auto-...
Tobias's user avatar
  • 33.3k
3 votes
Accepted

How do I disable savehist-autosave in emacs?

To disable savehist-mode, which is a global minor-mode, one can use: (savehist-mode -1) When disabling savehist-mode, the function savehist-uninstall is called ... savehist-minibuffer-hook is removed ...
lawlist's user avatar
  • 19.2k
3 votes
Accepted

Save an org-mode buffer when I clock in/out of a task

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 () (...
Konstantin Levinski's user avatar
3 votes
Accepted

autosave on shell buffers

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....
pedz's user avatar
  • 375
3 votes
Accepted

Emacs wont reopen my files from recover session

If you call M-x recover-session RET you are offered a dired buffer with save files. Pressing RET on one of those files opens it in an Emacs file buffer. You can use the following function to open all ...
Tobias's user avatar
  • 33.3k
3 votes

How to place all auto-save files in a directory

I had the same problem and now I use: (let ((my-auto-save-dir (locate-user-emacs-file "auto-save"))) (setq auto-save-file-name-transforms `((".*" ,(expand-file-name "\\2" my-auto-save-dir) ...
rchar01's user avatar
  • 447
3 votes

quick way to restore backups

Try recover-file for one specific file. If you call it with a filename it will prompt if the auto-save data exists e.g. (recover-file "note-xyz") otherwise, you could use recover-session if ...
zzkt's user avatar
  • 486
3 votes
Accepted

How to force Yes/y answer to `emacs has changed since visited or saved. Save anyway?` prompt

You might want to check the auto-answer package. It works on functions whose the underlying prompt is yes-or-no-p, read-string, read-from-minibuffer, read-key-sequence, read-key-sequence-vector, read-...
Firmin Martin's user avatar
3 votes
Accepted

Buffer file replaced with lockfile/backupfile location

It helps to read the fine variable descriptions. Namely, the following about auto-save-visited-file-name: This variable is obsolete since Emacs 26.1; use `auto-save-visited-mode' instead. You can ...
kballou's user avatar
  • 125
3 votes
Accepted

How can I save all buffers on auto-save except the ones have specifc mode?

I guess, after the set-buffer, just add the condition using unless to only save a buffer 'when not' the major`mode is a member of the list of modes that you would like to exclude, as follows: (defun ...
dalanicolai's user avatar
  • 7,855
3 votes
Accepted

How to never auto-save large files — or, how to run a function whenever any buffer starts — or, how to abort loading a minor mode in one of its hooks

presumably, running (auto-save-mode 0) is executing auto-save-mode-hook again. I'm not quite sure why this would happen, given that it is turning off the mode, not turning it on, C-h f auto-save-mode:...
shynur's user avatar
  • 5,328
2 votes
Accepted

Certain org-mode buffers keep saving automatically

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-...
Kiran's user avatar
  • 121
2 votes
Accepted

spacemacs and "file name too long" error on auto-save

You might want to show us the part of your ~/.emacs which sets up the autosave machinery to use home/xxx/.emacs.d/.cache/auto-save/site/... (or is it a Spacemacs thing?). But in any case, you should ...
Stefan's user avatar
  • 26.5k
2 votes
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/...
nega's user avatar
  • 3,276
2 votes
Accepted

How to automatically save buffer after each modification without using packages

To automatically save buffer after each modification, add the following elisp snippet to emacs config (defun savebuf(begin end length) (if (and (buffer-file-name) (buffer-modified-p)) (save-...
junnu's user avatar
  • 780
2 votes
Accepted

Emacs leaving behind files preceded with # despite lock files being disabled

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 ...
TheDarkHoarse's user avatar
2 votes

Emacs leaving behind files preceded with # despite lock files being disabled

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 ...
Drew's user avatar
  • 77.9k
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 ...
Drew's user avatar
  • 77.9k
2 votes
Accepted

Getting call stack during call of a specific function

Say M-x debug-on-entry RET save-buffer RET.
jch's user avatar
  • 5,750
2 votes

quick way to restore backups

I believe M-x recover-session should be all you need. However... I've just tested your scenario, and for some reason the session file is deleted if I kill emacs externally, which means that there is ...
phils's user avatar
  • 51.6k
2 votes

How can I make Emacs put files named like .#filename into another directory too

emacs-28, which has just been released, comes with lock-file-name-transforms, which lets you place those lockfiles somewhere other than in the same directory.
rpluim's user avatar
  • 5,325
2 votes

Is there a way to prevent Emacs from deleting an auto-saved file?

Have you tried customizing option delete-auto-save-files to nil? delete-auto-save-files is a variable defined in files.el. Its value is t Documentation: Non-nil means delete auto-save file when a ...
Drew's user avatar
  • 77.9k

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