* replace text in files from buffer=*grep* ?
@ 2015-05-05 15:38 Tom Roche
2015-05-05 16:28 ` Drew Adams
0 siblings, 1 reply; 5+ messages in thread
From: Tom Roche @ 2015-05-05 15:38 UTC (permalink / raw
To: help-gnu-emacs
[If possible, please reply both directly to me as well as to the list.]
What functionality exists to automate replacing text from a GNU Emacs *grep* (results) buffer? What I mean, why I ask:
Suppose I want to change an identifier in some code. I `M-x find-grep` from the root of the filetree of the sources and their docs, producing results like
buffer=*grep*
> find ../ -type f -print | grep -ve '[#~]$\|\.git/' | sort | xargs -e fgrep -nH -e 'F5NAP_FIREFOX_BUILD_DIR'
> ../scripts/install_Firefox_for_F5NAP.sh:88:elif [[ -z "${F5NAP_FIREFOX_BUILD_DIR}" ]] ; then
> ../scripts/install_Firefox_for_F5NAP.sh:89: echo -e "${ERROR_PREFIX} F5NAP_FIREFOX_BUILD_DIR not defined, exiting ..."
> ../scripts/install_Firefox_for_F5NAP.sh:119: "mkdir -p ${F5NAP_FIREFOX_BUILD_DIR}" \
> ../scripts/install_Firefox_for_F5NAP.sh:124: "find ${F5NAP_FIREFOX_BUILD_DIR} | wc -l" \
> ../scripts/public.properties:106:F5NAP_FIREFOX_BUILD_DIR="/tmp/${F5NAP_FIREFOX_WITH_VERSION}"
> ../scripts/public.properties:107:F5NAP_FIREFOX_UNZIP_DIR="${F5NAP_FIREFOX_BUILD_DIR}/firefox"
> ../scripts/start_Firefox_for_F5NAP.sh:82:elif [[ -z "${F5NAP_FIREFOX_BUILD_DIR}" ]] ; then
> ../scripts/start_Firefox_for_F5NAP.sh:83: echo -e "${ERROR_PREFIX} F5NAP_FIREFOX_BUILD_DIR not defined, exiting ..."
> ../scripts/start_Firefox_for_F5NAP.sh:113: "mkdir -p ${F5NAP_FIREFOX_BUILD_DIR}" \
> ../scripts/start_Firefox_for_F5NAP.sh:118: "find ${F5NAP_FIREFOX_BUILD_DIR} | wc -l" \
Depending on the results, I typically take 1 of 3 options:
0. |results| are large && results look dangerous: abort
1. |results| are large && results look safe: run `sed` from the root of the filetree
2. |results| are small && results look safe: make a macro changing the first one, then repeat on the rest.
Obviously there's no better solution for case#=0 :-) but my handling of the other cases feels kludgey. Is there a {better, easier, more Emacs-y} way to handle this?
OTTOMH, what I'd really like would be something that would "raise the level of abstraction" (RLA) on a *grep* buffer in the manner that Wdired RLAs a Dired buffer, by allowing one to treat file metadata as "mere text." If I'm in a Dired buffer and want to make several changes to the names/permissions of a bunch of files/subdirs of a single directory/folder, I
1. key 'w' to enter Wdired mode
2. apply any of the many wonderful means we have to do text editing on the now-editable data
3. key 'C-c C-c'
Wdired then applies the changes made from the Dired buffer to the objects it represents. So what I'd most like for my usecase would be to RLA on a *grep* buffer, allowing a Wdired-like workflow.
Is there something like that for *grep* buffers, or something even better? Apologies if this is a FAQ, but a (probably too casual) web search failed to find.
TIA, Tom Roche <Tom_Roche@pobox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: replace text in files from buffer=*grep* ?
2015-05-05 15:38 replace text in files from buffer=*grep* ? Tom Roche
@ 2015-05-05 16:28 ` Drew Adams
2015-05-05 16:59 ` Milan Stanojević
2015-05-05 21:09 ` Tom Roche
0 siblings, 2 replies; 5+ messages in thread
From: Drew Adams @ 2015-05-05 16:28 UTC (permalink / raw
To: help-gnu-emacs, Tom Roche
> What functionality exists to automate replacing text from a GNU
> Emacs *grep* (results) buffer? What I mean, why I ask:
...
> Wdired then applies the changes made from the Dired buffer to the
> objects it represents. So what I'd most like for my usecase would be
> to RLA on a *grep* buffer, allowing a Wdired-like workflow.
>
> Is there something like that for *grep* buffers.
Here is one such, found by searching for `grep' on Emacs Wiki:
http://www.emacswiki.org/emacs/grep-edit.el
(Haven't tried it.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: replace text in files from buffer=*grep* ?
2015-05-05 16:28 ` Drew Adams
@ 2015-05-05 16:59 ` Milan Stanojević
2015-05-05 21:09 ` Tom Roche
1 sibling, 0 replies; 5+ messages in thread
From: Milan Stanojević @ 2015-05-05 16:59 UTC (permalink / raw
To: Drew Adams; +Cc: Emacs mailing list, Tom Roche
Also
https://github.com/mhayashi1120/Emacs-wgrep
I use wgrep from time to time, it does more or less what you want.
On Tue, May 5, 2015 at 12:28 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> What functionality exists to automate replacing text from a GNU
>> Emacs *grep* (results) buffer? What I mean, why I ask:
> ...
>> Wdired then applies the changes made from the Dired buffer to the
>> objects it represents. So what I'd most like for my usecase would be
>> to RLA on a *grep* buffer, allowing a Wdired-like workflow.
>>
>> Is there something like that for *grep* buffers.
>
> Here is one such, found by searching for `grep' on Emacs Wiki:
> http://www.emacswiki.org/emacs/grep-edit.el
>
> (Haven't tried it.)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: replace text in files from buffer=*grep* ?
2015-05-05 16:28 ` Drew Adams
2015-05-05 16:59 ` Milan Stanojević
@ 2015-05-05 21:09 ` Tom Roche
2015-05-05 21:28 ` Drew Adams
1 sibling, 1 reply; 5+ messages in thread
From: Tom Roche @ 2015-05-05 21:09 UTC (permalink / raw
To: help-gnu-emacs
summary: https://github.com/mhayashi1120/Emacs-wgrep
details:
[If possible, please reply both directly to me as well as to the list.]
Tom Roche Tue, 05 May 2015 11:38:44 -0400
>>> What functionality exists to automate replacing text from a GNU Emacs *grep* (results) buffer?
...
>>> Apologies if this is a FAQ, but a (probably too casual) web search failed to find.
Drew Adams Tue, 5 May 2015 09:28:57 -0700 (PDT)
>> Here is one such, found by searching for `grep' on Emacs Wiki:
doh!
>> http://www.emacswiki.org/emacs/grep-edit.el
Milan Stanojević Tue, 5 May 2015 12:59:53 -0400
> https://github.com/mhayashi1120/Emacs-wgrep
The version of grep-edit.el @ EmacsWiki is downlevel: there's a newer version @ http://www.bookshelf.jp/elc/grep-edit.el , which is also the source of the fork that is https://github.com/mhayashi1120/Emacs-wgrep . So I tried the latter (seems better maintained--ICBW) and it solves my usecase!
thanks all, Tom Roche <Tom_Roche@pobox.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-05 21:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-05 15:38 replace text in files from buffer=*grep* ? Tom Roche
2015-05-05 16:28 ` Drew Adams
2015-05-05 16:59 ` Milan Stanojević
2015-05-05 21:09 ` Tom Roche
2015-05-05 21:28 ` Drew Adams
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.