bbatsov / super-save Goto Github PK
View Code? Open in Web Editor NEWSave Emacs buffers when they lose focus
Save Emacs buffers when they lose focus
If a file is changed in the background by scheduled elisp functions, super-save will not save it. It this a setting, to always save buffers?
Hi,
What would be a good way to not use super-save-max-buffer-size
? For the past few days I've been confused why a file I often edit was not saving how it used too — after some investigation I see that it is because (I think) of the new super-save-max-buffer-size
from this commit #37.
I can't set it to nil to disable. I guess I can just make it a really big number but that doesn't feel so neat.
Thanks. One of my favorite little Emacs packages.
I'm running into an issue with lsp-mode
which is described in emacs-lsp/lsp-mode#1322. lsp-mode
uses lv-message
instead of message
to print some information, and this seems to trigger saving with super-save
. I don't want to disable any super-save
triggers, so I'm wondering if there's any good way to work around this issue (i.e. is it possible to detect if certain functions resulted in the trigger and ignore it in some cases?).
I've currently worked around this issue in lsp-mode
by adding (setq lsp-signature-function 'message)
to my config file. But I'd prefer to remove this in the future so I can get the default lv-message
functionality.
I use EXWM which allows you to run GUI applications as a buffer within emacs. When I have a buffer with unsaved changes and click on a 'GUI' buffer eg: Firefox then the previous buffer is not saved.
If I click on a normal emacs buffer it will save no problem.
I tried (set-buffer-modified-p nil)
(setq set-buffer-modified-p nil)
but it doesn't seem to work.
$ uname -r
: 4.19.0-5-amd64Setting and evaluating super-save-idle-duration
to any value has no effect whatsoever. The only way to change it is to reboot Emacs completely. It is also not possible to use setq-local
to set different values for different modes.
This is my use-package declaration for super-save:
(use-package super-save
:defer nil
:ensure t
:config
(setq auto-save-default nil
auto-save-file-name-transforms `((".*" "~/.emacs.d/var/temp" t))
auto-save-interval 300
auto-save-timeout 30
auto-save-visited-mode t
super-save-exclude '(".py")
super-save-auto-save-when-idle t
super-save-idle-duration 1
super-save-triggers
'(balance-windows
evil-window-next
evil-window-prev
eyebrowse-close-window-config
eyebrowse-create-window-config
my/no-highlight
eyebrowse-next-window-config
eyebrowse-prev-window-config
eyebrowse-switch-to-window-config-1
eyebrowse-switch-to-window-config-2
eyebrowse-switch-to-window-config-3
eyebrowse-switch-to-window-config-4
eyebrowse-switch-to-window-config-5
eyebrowse-switch-to-window-config-6
eyebrowse-switch-to-window-config-7
eyebrowse-switch-to-window-config-8
eyebrowse-switch-to-window-config-9
next-buffer
org-babel-execute-src-block
other-window
previous-buffer
split-window-below
split-window-horizontally
start-process-shell-command
switch-to-buffer
treemacs-select-window
windmove-down
windmove-left
windmove-right
windmove-up))
(super-save-mode +1))
This is technically not a bug in super-save but rather an oddity of (save-excursion), but in my Prelude setup it's coming from super-save so I am wondering if it's possible to tinker with super-save to work around it.
When triggering super-save hooks with a format-on-save hook ((add-hook 'before-save-hook 'cider-format-buffer) in init.el), the file should format and the cursor should stay in its appropriate place, just like it stays there when you run cider-format-buffer or basic-buffer-save without super-save
Triggering the super-save hook (e.g., navigating to a different application) saves and formats the document, but the cursor yeets to the beginning of the buffer
Version: 20231209.1044
29.1
macOS Sonoma 14.1.2
would it be possible for super-save to not trigger save hooks — reserving those for when a file is manually saved?
for my specific use-case, i'm using org-roam which binds:
(add-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h nil t)
the db autosync is cpu intensive so there's a periodic bit of a lag when i have super-save-auto-save-when-idle
turned on (which I would like to keep).
is there a way i can adjust the org-roam hook and/or configure super-save to make the two mutually exclusive?
Super-save is saving the current modified buffer when I left click the mouse anywhere in the text.
Is there a way to stop this behavior?
Sorry, this issue was created in error, please delete it!
Tested with this config:
(use-package! super-save
:ensure t
:config
(super-save-mode +1))
(setq super-save-auto-save-when-idle t)
Works with .md
files just fine, but .org
files not unfortunately... Was testing windmove-left/right and out of focus events, all the same though.
Thought at first this has something to do with the triggering event but I tried all kinds of stuff, reinstallation and other peoples config.
Also tried removing all other packages and configs, so my doom emacs it was pretty vanilla. Also had a look at the init.el but couldn't find anything obvious that would affect this.
Don't know what else to try...
I think it will be great if we can exclude some file from super-save. Other package had this feature, e.g recentf-exclude, dimmer, etc.
Disabling super-save in certain file can be achieved using file header #10, but it didn't automatically re-enable when we switch to other file.
Thank you for super-save, using this for years.
$ uname -r
: 4.19.0-5-amd64I have the following to prevent super-save from working on Python files:
(setq super-save-exclude '(".py"))
But it does not work, super-save remain active. In fact, super-save seems to remain active in all modes, in all circumstances, even after I hit M-x super-save-mode
. Altering super-save-duration
requires a full reboot (I use emacsclient
).
This is my use-package
declaration for super-save:
(use-package super-save
:defer nil
:ensure t
:config
(setq auto-save-default nil
auto-save-file-name-transforms `((".*" "~/.emacs.d/var/temp" t))
auto-save-interval 300
auto-save-timeout 30
auto-save-visited-mode t
super-save-exclude '(".py")
super-save-auto-save-when-idle t
super-save-idle-duration 1
super-save-triggers
'(balance-windows
evil-window-next
evil-window-prev
eyebrowse-close-window-config
eyebrowse-create-window-config
my/no-highlight
eyebrowse-next-window-config
eyebrowse-prev-window-config
eyebrowse-switch-to-window-config-1
eyebrowse-switch-to-window-config-2
eyebrowse-switch-to-window-config-3
eyebrowse-switch-to-window-config-4
eyebrowse-switch-to-window-config-5
eyebrowse-switch-to-window-config-6
eyebrowse-switch-to-window-config-7
eyebrowse-switch-to-window-config-8
eyebrowse-switch-to-window-config-9
next-buffer
org-babel-execute-src-block
other-window
previous-buffer
split-window-below
split-window-horizontally
start-process-shell-command
switch-to-buffer
treemacs-select-window
windmove-down
windmove-left
windmove-right
windmove-up))
(super-save-mode +1))
Hi
while using org-crypt and when super-save is enabled the entries in org-mode file gets encrypted every time based on super-save settings/triggers. As I have (org-crypt-use-before-save-magic) turned on.
For auto-save we have header like:
which will disable auto-save for the particular file worked on.
How can we achieve the same with super-save? i.e disable super-save for just the file working on.
tips and pointers appreciated. thanks.
Although there's a variable defining which commands trigger auto save (super-save-triggers
) there are still two hard-coded triggers on super-save-initialize
(on mouse-leave-buffer-hook
and focus-out-hook
respectively). These could also be customizable (for users that only want the idle trigger, for example).
I'm unable to do it in this way:
(defun my/set-save ()
(interactive)
(setq super-save-idle-duration 2))
(add-hook 'web-mode-hook 'my/web-mode-hooks)
Even though the variable is actually set, is has no effect on the saving behavior. setq-local
doesn't work either.
That's my use-package
for super-save
:
(use-package super-save
:ensure t
:config
(setq super-save-triggers
'(switch-to-buffer
other-window
windmove-up
windmove-down
windmove-left
windmove-right
next-buffer
previous-buffer
evil-window-prev
evil-window-next
eyebrowse-next-window-config
eyebrowse-prev-window-config
eyebrowse-create-window-config))
(setq super-save-auto-save-when-idle t)
(setq auto-save-default nil)
(super-save-mode +1))
Is there anyway to exclude files during peep-dired session?
I found this problem out at the worst possible way: writing a long text over a period of time and having emacs to crash when exiting the capture frame with C-c C-c
. While writing, I kept changing focus between a PDF and the capture buffer. The file was never saved.
I've just tested it and the buffer the org capture is adding text to never gets saved unless I explicitly move focus to the main buffer.
The capture template I am using should not have anything special in it: ("n" "note" entry (file+olp+datetree "~/Dropbox/org/reference.org") "* %?\n :PROPERTIES:\n :CREATED: %U\n :END: \n%i")
Is there a way to get super-save respond to the org-mode capture buffer losing focus?
$ uname -r
: 4.19.0-5-amd64M-x super-save-mode
has no effect in any buffer: it just keeps saving no matter what. To disable it, I need to change my configurations and reboot. Evaluating (super-save-mode +1)
or (setq super-save-mode nil)
has absolutely no effect.
This is my use-package
declaration for super-save:
(use-package super-save
:defer nil
:ensure t
:config
(setq auto-save-default nil
auto-save-file-name-transforms `((".*" "~/.emacs.d/var/temp" t))
auto-save-interval 300
auto-save-timeout 30
auto-save-visited-mode t
super-save-exclude '(".py")
super-save-auto-save-when-idle t
super-save-idle-duration 1
super-save-triggers
'(balance-windows
evil-window-next
evil-window-prev
eyebrowse-close-window-config
eyebrowse-create-window-config
my/no-highlight
eyebrowse-next-window-config
eyebrowse-prev-window-config
eyebrowse-switch-to-window-config-1
eyebrowse-switch-to-window-config-2
eyebrowse-switch-to-window-config-3
eyebrowse-switch-to-window-config-4
eyebrowse-switch-to-window-config-5
eyebrowse-switch-to-window-config-6
eyebrowse-switch-to-window-config-7
eyebrowse-switch-to-window-config-8
eyebrowse-switch-to-window-config-9
next-buffer
org-babel-execute-src-block
other-window
previous-buffer
split-window-below
split-window-horizontally
start-process-shell-command
switch-to-buffer
treemacs-select-window
windmove-down
windmove-left
windmove-right
windmove-up))
(super-save-mode +1))
GNU Emacs 26.1, macOS/Ubuntu
When I open some emacs lib files (.el.gz), super-save
may empty the file contents sometimes.
Add a tag so that we get one on melpa.stable :)
(maybe after adding the autoload cookies cf #1)
I have commands from two packages that I use regularly that do not trigger super-save. Typically my current buffer is unsaved:
Could you please either advise how to add code to include them or add fixes to the distribution code.
Hello,
I'm using Spacemacs and it has a feature to number all Emacs windows from 1, 2, 3... using the window-numbering package: https://github.com/nschum/window-numbering.el
When editing a file with super-save is enabled, the file is not automatically saved when I move the cursor to a new window by using the select-window-...
function from window-numbering.el
package.
Given the code of the core function of select-window-by-number
as follow, can you advise how to hook super-save
with the code that changes the window (setq window (aref windows i))
?
(defun select-window-by-number (i &optional arg)
"Select window given number I by `window-numbering-mode'.
If prefix ARG is given, delete the window instead of selecting it."
(interactive "P")
(let ((windows (car (gethash (selected-frame) window-numbering-table)))
window)
(if (and (>= i 0) (< i 10)
(setq window (aref windows i)))
(if arg
(delete-window window)
(select-window window))
(error "No window numbered %s" i))))
Thanks!
I used another package which saves all file-visiting buffers when idle, now I'm switching to super-save because the focus-out-hook
style works better with file watchers, e.g. web front-end transpilers. Meanwhile, I really miss the save-all-buffers feature. Would be nice to have an option to enable this, though it looks easily achievable by modifying super-save-command
myself.
Here is the code to save all buffers I used, should you be interested: https://github.com/manateelazycat/lazycat-emacs/blob/ce87fb97286a187b66355a587a4230dea01d0de5/site-lisp/extensions/lazycat/auto-save.el#L120
Currently super-save advises a couple of Emacs functions to catch buffer switching, but I think we could replace these advises with two hooks:
window-configuration-change-hook
: This hook will trigger—among other things—when a window gets to display a different buffer, i.e. if the user switches to a different buffer within the current window. This would replace the switch-to-buffer
advise.buffer-list-update-hook
: This hook triggers whenever the buffer list changes, which occurs—among other things–upon calls to select-window
, i.e. when the user switches to a different window.I have some code that auto updates some org files every midnight.
Now, in the morning, I have a bunch of files modified, but not saved.
How does super-save notice and save these files?
Hi @bbatsov.
First of all, thank you for this awesome plugin.
I'm using spacemacs and after installing super-save i can't change windows using the default shortcuts.
I get the following error when i press SPC w h(Move to window on the left) or SPC w l(Move to window on the right):
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . &rest) 0) super-save-command-advice() apply(super-save-command-advice nil) windmove-right() evil-window-right(1) call-interactively(evil-window-right nil nil) command-execute(evil-window-right)
I tried some workarounds but none of them worked.
Do you have any ideia of what is causing this?
Thank you very much.
I noticed that having super-save enabled in buffers that use Tramp (e.g. when editing a file over ssh) can be very annoying and cause significant delays. What do you think about adding an option to automatically disable super-save in such buffers?
I prefer to auto-save
all the time instead save-buffer
, so it's not constantly making new backup files. Is there a way to get this to do-auto-save
instead of actually saving the buffer?
When used in conjunct with https://github.com/pythonic-emacs/blacken/blob/master/blacken.el, Super Save fails to keep the cursor in the same position (does not save excursion), and it ends up going to the top of the file.
This does not occur with super-save in any other mode, nor if I save the python file manually.
Is the super-save package also intended to work in non-GUI Emacs (terminal) when using the idle option?
I followed the installation instructions, including refreshing the packages.
Added the following to my init.el:
(add-to-list 'load-path "~/.emacs.d/elpa/super-save-20160426.729")
(require 'super-save)
(super-save-mode +1)
(setq super-save-auto-save-when-idle t)
When switching buffers it saves, but when the default 5 seconds of idle time passed, it never saves buffers.
Any help would be appreciated.
Diego.
Please turn that into a proper global minor mode that can be enabled and disabled again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.