deadgrep icon indicating copy to clipboard operation
deadgrep copied to clipboard

Enable editable buffer and save changes to files

Open xenodium opened this issue 6 years ago • 12 comments

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:

helm-ag-edit

xenodium avatar Jul 15 '18 19:07 xenodium

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.

Wilfred avatar Jul 15 '18 22:07 Wilfred

Awesome. Thanks. Had a feeling you'd add this too :)

xenodium avatar Jul 17 '18 20:07 xenodium

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 :).

phoenixanimations avatar Jul 18 '18 16:07 phoenixanimations

Any progress here?

Pitometsu avatar Feb 18 '19 13:02 Pitometsu

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 :)

Wilfred avatar Mar 14 '19 22:03 Wilfred

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...

  1. 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 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.

  2. 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 :/

xenodium avatar Mar 16 '19 12:03 xenodium

+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.

kaushalmodi avatar Mar 16 '19 12:03 kaushalmodi

I've sent deadgrep support PR to wgrep. https://github.com/mhayashi1120/Emacs-wgrep/pull/58

I hope it could solve the issue.

iquiw avatar May 01 '19 02:05 iquiw

@iquiw Nice, looking forward to that.

@Wilfred I think it'd be nice to have an explicit exit function back to deadgrep-mode.

jojojames avatar May 03 '19 02:05 jojojames

I found deadgrep-edit-modeworked 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.

hmelman avatar Jun 25 '19 15:06 hmelman

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

andreidum avatar Jun 29 '20 17:06 andreidum

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?

fleimgruber avatar Dec 09 '20 15:12 fleimgruber