reddit / emacs

How can I get projectile-replace-regexp to save after each replace?

OS6aDohpegavod4 · 2022-09-14 02:30
After going through each replacement, it doesn't save the files, so I have to go back to every single file and save it again.
Danrobi1 · 2022-09-14 02:40
There's always `auto-save-mode`
Hammar_Morty · 2022-09-14 03:15
Your wording makes me think you are not aware of `save-some-buffers`. This is bound `C-x s` by default and is basically "save all" with more control. Would this satisfy your needs? Because IMO I think it's good having to save modified buffers manually. You could also open ibuffer select all modified buffers and save that way.
jkdufair · 2022-09-14 03:22
`s-p S` saves all project buffers. Not sure the actual function name at the moment.
xtifr · 2022-09-14 09:15
Just a reminder: Emacs's menus are really handy, *especially* for modes. If you had looked in the `Projectile` menu, for example, I suspect you might have noticed the `Save Project Buffers` option! It will even list the key to press, so you don't have to go back to the menu the next time. (Unless you forget the key, in which case, hey, the menu's still right there!)
[deleted] · 2022-09-14 11:30
[deleted]
[deleted] · 2022-09-14 11:31
[deleted]
akirakom · 2022-09-14 12:30
I think you can define your own function that first performs replacement and then save buffers.
Hammar_Morty · 2022-09-14 13:43
>unsaved changed in another file which I don't want to save it's trivial to save multiple files with high granularity quickly. The edge case of dealing with buffers that are already modified makes automatically saving in this case much harder. What if that already modified file that you didn't want to save had a replacement in it?
quokka70 · 2022-09-14 14:06
+1. This is what I use when I've updated a bunch of files. It's `projectile-save-project-buffers`. However, this saves all modified project buffers, while OP says there may be some buffers for which saving is not desired.