all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

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.