Skip to content
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

Enhancements for deadgrep-edit-mode #105

Open
hjudt opened this issue Dec 6, 2021 · 5 comments
Open

Enhancements for deadgrep-edit-mode #105

hjudt opened this issue Dec 6, 2021 · 5 comments

Comments

@hjudt
Copy link

hjudt commented Dec 6, 2021

Please consider adding C-x C-q to deadgrep-mode-map as default keybinding for activating deadgrep-edit-mode. dired uses this for enabling editing dired buffers, so it would feel natural to have this.

Also add C-c C-c to deadgrep-edit-mode-map to perform the changes, or C-c C-k to abort them, restoring the previous state. This would be similar to magit and other tools, and wgrep uses C-c too. Aborting the changes and restoring the previous state probably needs to be implemented first.

Finally, refreshing the buffer often returns the results in a different order. I assume this is because rg does a multi-threaded search. However, sometimes it would be less confusing if the order of the results stayed the same. rg itself has options for this (--sort and --sortr), though it probably makes search slower because single-threaded.

@hjudt
Copy link
Author

hjudt commented Dec 6, 2021

Of course, one can achieve C-x C-q and C-c C-c in e.g. the use-package definition:

(use-package deadgrep
  :ensure t
  :bind (("C-c g" . deadgrep)
         :map deadgrep-mode-map
         ("C-x C-q" . deadgrep-edit-mode)
         :map deadgrep-edit-mode-map
         ("C-c C-c" . deadgrep-mode)))

Unfortunately, there will be no feedback when saving the changes and returning from deadgrep-edit-mode to deadgrep-mode.

@gvol
Copy link

gvol commented Aug 16, 2023

As far as I can tell, the updating of files happens as you are typing in deadgrep-edit-mode rather than when you exit deadgrep-edit-mode. I find this a little scary and different, but it does mean that feedback from exiting deadgrep-edit-mode is less important.

EDIT: Ah, I see that you probably knew this already. Sorry for the noise.

@petergaultney
Copy link

this is unsolicited feedback, but coming to deadgrep from some other things, I was definitely taken aback when the changes happened without a final "save" step - some other things I've used intercept C-x C-s to actually save the changes to the files (and also save the buffers to disk). That interface seemed a lot more intuitive to me.

@pierre-rouleau
Copy link
Contributor

pierre-rouleau commented Sep 26, 2024

deadgrep-edit-mode would be much more useful if it did not update files until the user executed a command. The purpose of using it is to change a large number of text instances over a large set of files. But when you do that, it takes forever, making the feature very annoying and close to useless.

Also I found that when the operation is completed (after waiting for all buffers/files to be modified), typing C-x C-s does not commit all buffers to files. It does not seem reliable. So one has to check all buffer to ensure they are saved.

It's too bad because otherwise deadgrep is great.

@hjudt
Copy link
Author

hjudt commented Sep 26, 2024

Nowadays, I can recommend to use consult-ripgrep and embark-export. They let you narrow the search easily, giving you live results and a standard grep buffer that you can switch to a writable grep buffer. You can configure consult-ripgrep args, and if that is not enough, maybe write a small wrapper function that adds sorting to the args, then call consult-ripgrep, and bind it to some key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants