-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save buffer on focus lost #2376
Comments
No, afaik, but you can add a naive version yourself very easily:
|
I have very similar code (add-hook 'focus-out-hook
(defun save-current-buffer-if-needed ()
(interactive)
(when (and (buffer-file-name) (buffer-modified-p))
(save-buffer)))) This only saves the current buffer, if it belongs to a file and has changes that need to be saved. |
Nice improvement, will be using it. Thanks. |
I looked at my config and it’s just one line there: (add-hook 'focus-out-hook (lambda () (save-some-buffers t))) Maybe it makes sense to include the function from Emacs Prelude, too. |
The main question of this issue has been answered. If someone thinks it's used widely enough to be included in Spacemacs, feel free to open a PR with this change, it will be better discussed there 😄 Closing this issue in the meantime |
Hi guys, I have the same requirement and I don't think this question is answered. The documentation of
It's not when switch buffer/window. I found a solution here http://batsov.com/articles/2012/03/08/emacs-tip-number-5-save-buffers-automatically-on-buffer-or-window-switch/ Code like below:
It works for me. So I paste it here. |
Did a pull request ever get raised for this? In Emacs, I use:
I've only just downloaded Spacemacs today! It seems that I may expect to have a configuration variable in my ~/.spacemacs file:
which I could toggle to |
@martin-liu It auto-saves after every paste as well :( |
Pull request for this highly appreciated! 😅 |
Hi everyone, Shouldn't this solution be also in the documentation? At least until #4964 is done. @syl20bnr If you don't mind I can open a PR updating the docs including this snippet. ;; see: http://batsov.com/articles/2012/03/08/emacs-tip-number-5-save-buffers-automatically-on-buffer-or-window-switch/
(defadvice switch-to-buffer (before save-buffer-now activate)
(when buffer-file-name (save-buffer)))
(defadvice other-window (before other-window-now activate)
(when buffer-file-name (save-buffer))) Thanks @martin-liu. Also, this one is also great, however, not sure how to install it (any help will be pretty much appreciated). |
Hi,
One feature I sorely miss from emacs prelude is the ability to save buffers whenever focus changes to another buffer or window. This is very valuable as the file is automatically saved, and I dont have to manually save them.
Is there such a feature in sapcemacs ?
Thanks,
Murtaza
The text was updated successfully, but these errors were encountered: