From: Tom Roche <Tom_Roche@pobox.com>
To: help-gnu-emacs@gnu.org,
Subject: replace text in files from buffer=*grep* ?
Date: Tue, 05 May 2015 11:38:44 -0400 [thread overview]
Message-ID: <87y4l3qbjv.fsf@pobox.com> (raw)
[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>
next reply other threads:[~2015-05-05 15:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 15:38 Tom Roche [this message]
2015-05-05 16:28 ` replace text in files from buffer=*grep* ? Drew Adams
2015-05-05 16:59 ` Milan Stanojević
2015-05-05 21:09 ` Tom Roche
2015-05-05 21:28 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y4l3qbjv.fsf@pobox.com \
--to=tom_roche@pobox.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.