deadgrep
deadgrep copied to clipboard
Enable editable buffer and save changes to files
Feature request: Edit results in buffer and save all touched files.
Similar in spirit to wdired, make search results editable in buffer. C-c C-c would save any changes in all modified files.
Here's what that's like using helm-ag and pressing C-c C-e to open an editable buffer:
Yep, this is definitely something I want to do. It's quite a big feature, so I wanted to be happy with the overall UI first, but I will add this at some point.
Awesome. Thanks. Had a feeling you'd add this too :)
Was just about to request this. This package has a really nice ui, and I like how you can change the settings on the result screen. Thanks either way :).
Any progress here?
OK, this is now implemented! Please try M-x deadgrep-edit-mode
and tell me what you think.
There will undoubtedly be rough edges and bugs, but it does work. If you edit a line from a file you have open, the buffer gets updated. If the file isn't open, the changes are written to the file directly.
Have a play with it and let me know what you think of the feel :)
OK, this is now implemented! Please try M-x deadgrep-edit-mode
Thanks for taking the time to implement this Wilfred! Just gave it a try. Very cool.
Have a play with it and let me know what you think of the feel :)
The following may be subjective suggestions...
-
Apply buffer/file changes with explicit intent (ie.
C-c C-c
). That is, useC-x C-q
to enterdeadgrep-edit-mode
, make your edits, and useC-c C-c
to apply the changes to all files. This seems to be consistent with other commands (ie.dired-toggle-read-only
). Similarly,C-c C-k
would discard the changes. -
Save changes to open buffers also. After making batch-changes using
deadgrep-edit-mode
,magit
prompted me to save changed buffers. We may want to save all files (including open buffers) or none for consistency. The former would remove some friction (no additional magit prompts).
Having said this, please gauge feedback from other active users. I unfortunately haven't been using deadgrep much recently. Sorry :/
+1 to what @xenodium said:
That is, useC-x C-q to enterdeadgrep-edit-mode, make your edits, and use C-c C-c to apply the changes to all files. This seems to be consistent with other commands (ie. dired-toggle-read-only). Similarly, C-c C-k would discard the changes.
I've sent deadgrep
support PR to wgrep
. https://github.com/mhayashi1120/Emacs-wgrep/pull/58
I hope it could solve the issue.
@iquiw Nice, looking forward to that.
@Wilfred I think it'd be nice to have an explicit exit function back to deadgrep-mode.
I found deadgrep-edit-mode
worked well for simple edits, inserting or deleting characters. However I used downcase-word
at the start of a word ("Brian") and while the deadgrep buffer properly changed the text ("brian") the original buffer changed incorrectly to "rian", that is the first character of the word was deleted.
Hi, I'm also noticing an issue with deadgrep-edit-mode
. Edits fail when running query-replace
with an " Match data clobbered by buffer modification hooks” error.
I'm using a fairly standard Doom Emacs config. The vaule of before-change-functions
is
sp--reset-memoization
syntax-ppss-flush-cache)
after-change-functions
is
(flycheck-handle-change
deadgrep--propagate-change
t
ws-butler-after-change)
Not sure really if this is due to the Doom emacs hooks. Let me know if you have any tips for making deadgrep-edit-mode
work better (with Doom).
Thanks
I am seeing the same error replace-match-maybe-edit: Match data clobbered by buffer modification hooks
in *messages*
using Spacemacs when running query-replace
in a deadgrep-edit-mode
buffer. before-change-functions
is nil
. How to debug this further?