reddit / emacs
[ANN] alphapapa/salv.el: Local minor mode to save a buffer when Emacs is idle
github-alphapapa · 2022-07-03 15:30
RadonedWasEaten · 2022-07-03 15:41
Nice! Can you make is so it will not save a empty buffer
github-alphapapa · 2022-07-03 15:58
We could, but why?
[deleted] · 2022-07-03 18:22
[removed]
Ivancz · 2022-07-03 19:15
Dude, I'm impressed how much you've been releasing lately, are you ok?
a-c-d-w · 2022-07-03 19:26
interesting. I think I'm gonna stick to super-save-mode, or maybe audit this code and if it's more lightweight just enable it everywhere, lol.
oh does this do scratch buffers? or I guess.... would it?
jigarthanda-paal · 2022-07-03 23:33
༼ つ ◕_◕ ༽つ
Praise alphapapa
RadonedWasEaten · 2022-07-04 02:27
I make lots of buffers accidentally that I discard
onetom · 2022-07-04 04:07
seems like a serious case is prolifiritis :)
github-alphapapa · 2022-07-04 05:29
So don't enable `salv-mode` in those buffers.
github-alphapapa · 2022-07-04 05:30
It's funny that you would say that, because I haven't been doing that much Elisp coding lately. This, for example, is only a few lines of code.
Just because I "release" something doesn't mean I just wrote it. For example, the recent "release" of Burly 0.2 is mostly comprised of code that's been sitting on the master branch for a while now. After it's been used for a while and seems stable, I may tag it as a release so I can work on new features for a new release.
But thanks for the kind words...I think... :)
github-alphapapa · 2022-07-04 05:33
`super-save` is a fine package if you want a global minor mode. I prefer to only enable `salv-mode` for the certain buffers I want to be automatically saved.
`salv-mode` will only call `save-buffer` in the buffers in which you activate it. The scratch buffer is not file-backed, anyway.
github-alphapapa · 2022-07-04 05:38
😶
😎
🤣
🙏
b3n · 2022-07-04 09:36
See also: The built in `auto-save-visited-mode`
You can enable this with `(auto-save-visited-mode 1)`, and once enabled set the buffer-local value of `auto-save-visited-mode` if you don't want it to apply globally.
So the example in the README would look something like this in vanilla Emacs:
(auto-save-visited-mode 1)
(setq-default auto-save-visited-mode nil)
(add-hook 'org-mode-hook
(lambda ()
(when (file-in-directory-p (buffer-file-name) "~/org")
(setq-local auto-save-visited-mode t))))
Teknikal_Domain · 2022-07-04 15:33
I have a feeling someone just made it global in their init...
AdjectivePronoun · 2022-07-05 19:56
For some reason (even after almost 8 years, I'm still just beginner with emacs) `super-save` wasn't running when I would modify my tasks in my Org Agenda - the "remote editing" of my gtd.org file. This lead to annoying situations where Beorg on my phone would say I didn't actually complete tasks, and then my desktop later saying I didn't complete them after Beorg synced and auto-reverted :-(
I replaced it with `salv-mode` with your hook
```elisp
(add-hook 'org-mode-hook
(lambda ()
(when (file-in-directory-p (buffer-file-name) "~/org")
(salv-mode))))
```
and changes inside the agenda view are correctly saved within seconds. Great job and thanks for the really useful and simple tool!
github-alphapapa · 2022-07-06 14:02
Well, there's `auto-save-visited-mode` for that, but to each his own. :)
github-alphapapa · 2022-07-06 14:14
Ah, that's interesting. I discovered `first-change-hook` when I was putting `salv-mode` together, which seems to work well. I haven''t looked at `super-save`'s code, but I guess whatever method it uses doesn't detect remote changes, or something like that. Glad that this is helpful to you. :)
poiu- · 2022-07-07 14:13
what are the pros/cons of using `salv` over `auto-save-visited-mode`?
poiu- · 2022-07-07 14:15
Thanks for your work!
github-alphapapa · 2022-07-14 12:53
Thanks for the kind words. :)