From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Roche Newsgroups: gmane.emacs.help Subject: replace text in files from buffer=*grep* ? Date: Tue, 05 May 2015 11:38:44 -0400 Message-ID: <87y4l3qbjv.fsf@pobox.com> Reply-To: help-gnu-emacs@gnu.org, Tom Roche NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1430840366 9447 80.91.229.3 (5 May 2015 15:39:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 May 2015 15:39:26 +0000 (UTC) To: help-gnu-emacs@gnu.org, Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 05 17:39:12 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YpewC-0007HW-7f for geh-help-gnu-emacs@m.gmane.org; Tue, 05 May 2015 17:39:12 +0200 Original-Received: from localhost ([::1]:40011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YpewB-0003q2-4v for geh-help-gnu-emacs@m.gmane.org; Tue, 05 May 2015 11:39:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypevz-0003pt-8q for help-gnu-emacs@gnu.org; Tue, 05 May 2015 11:39:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ypevu-0003oA-H5 for help-gnu-emacs@gnu.org; Tue, 05 May 2015 11:38:59 -0400 Original-Received: from pb-smtp1.int.icgroup.com ([208.72.237.35]:56340 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypevu-0003nr-C0 for help-gnu-emacs@gnu.org; Tue, 05 May 2015 11:38:54 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 5F9634D65F; Tue, 5 May 2015 11:38:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:reply-to:date:message-id:mime-version:content-type; s= sasl; bh=LIIMGV/xgVZ/GyjoPq4qZ1TcLQg=; b=tgVcjWOc98FSeoAA4HGA/XO hmbUw2/SfIUMVzbvllMBN1/kWI6cMGleJhcu0M8awafX69XfUXamNi7x2Su7dwX4 i3YbPmTc0JTK9LlVkdfBqJ48cleNLujydunLEfkwVmNGwVpMBEBTCwGMt+G9MHts v0VwubulZ5vPaR2lrELs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :reply-to:date:message-id:mime-version:content-type; q=dns; s= sasl; b=Bja4mNHrRg3SaH9jyum8QFWCQS4yIzBk7OO/GntnAoatvc+jRfl7RKei 2Yk8Of97ZJlZCoa5mUgMXLeYOHKVmC0PkPuUpiSFtbpAVMU6dWuk829xUy+M5a8L rgWB4IJv9TN2hAW8AglMv2Y8Wfrax2Kb4F1GTFTUhpN1eHa7sGU= Original-Received: from pb-smtp1.int.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 581EC4D65E; Tue, 5 May 2015 11:38:53 -0400 (EDT) Original-Received: from tlrW510.pobox.com (unknown [71.20.203.128]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 1A0384D65C; Tue, 5 May 2015 11:38:51 -0400 (EDT) User-Agent: GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.4) X-Pobox-Relay-ID: D4ED78D6-F33C-11E4-ADB3-83E09F42C9D4-07218935!pb-smtp1.pobox.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.72.237.35 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104209 Archived-At: [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