Optimize wgrep usability

I often use wgrep for refactoring, and it usually works pretty well. However, there are some minor troubles that I hope can be resolved:

  • After performing an rgrep search, changing to wgrep and making changes to the rgrep buffer, wgrep will open all the files that need to be changed and make the changes. However, in this case, files usually open in emacs, so they will undergo normal mode loading, which can take quite a while if this action is associated with large source files that are being analyzed.

    Is it possible to change wgrep so that it opens files in the most basic mode (I assume that the main mode is normal mode ) instead?

  • After making the changes, wgrep will not close the newly opened buffers.

    Is it possible to change wgrep so that it automatically closes any buffers that were open during the run phase (that is, buffers that were not open before the wgrep procedure started).

Finally, a meta-question: is this more likely a problem that should be sent to the wgrep developer search tracker or is this the right StackOverflow question?

+6
source share
1 answer

From what I see in the source of wgrep.el, you will need to modify (or aggressively defadvice ) some functions of wgrep.el.

In particular, in wgrep-get-file-buffer argument RAWFILE find-file-noselect should be t, in your case, and the buffer should be added to the list of buffers for destruction. In wgrep-finish-edit a dolist in this new list can be used to destroy open wgrep buffers.

Thus, a function request to the author may be in order :-)

In the meantime, the changes you need are easy to implement (just override the short wgrep-get-file-buffer and the "defadvice after" wgrep-finish-edit ), but you will be vulnerable to updates in the package.

[And, of course, an author / patch request can be sent, but in this case a new configuration variable can be added ( wgrep-auto-kill-buffer or something like that]]

+3
source

All Articles