From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ke Lu Newsgroups: gmane.emacs.help Subject: Re: Interative batch query-replace question Date: Sat, 01 Dec 2007 18:11:57 +0900 Organization: Bentium Ltd. (CN99) Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1196502117 8626 80.91.229.12 (1 Dec 2007 09:41:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Dec 2007 09:41:57 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 01 10:42:06 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IyOrL-0000kH-Ld for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2007 10:42:03 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IyOr5-00028c-OQ for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Dec 2007 04:41:47 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!news.cn99.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 77 Original-NNTP-Posting-Host: softbank218118058050.bbtec.net Original-X-Trace: news.cn99.com 1196504678 13093 218.118.58.50 (1 Dec 2007 10:24:38 GMT) Original-X-Complaints-To: usenet@news.cn99.com Original-NNTP-Posting-Date: Sat, 1 Dec 2007 10:24:38 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:7pflGzzb0KfTtIzjnTZ0WBYPq7Y= Original-Xref: shelby.stanford.edu gnu.emacs.help:154323 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49753 Archived-At: Perhaps my explain is not quite enough. I want to query-replace some files.(not filename) 1. Use find-dired to Find some files.(M-x find-dired) In "*File" buffer,it looks like: /home/lu/workspace/: find . \( -name "*.java" \) -exec ls -ld \{\} \; -rw-r--r-- 1 lu lu 215 1月 21 2003 ejbdemo/DemoEntity.java -rw-r--r-- 1 lu lu 178 1月 21 2003 ejbdemo/DemoSession.java -rw-r--r-- 1 lu lu 146 1月 21 2003 ejbdemo/DemoSessionLocal.java -rw-r--r-- 1 lu lu 573 1月 21 2003 ejbdemo/DemoSessionEJB.java -rw-r--r-- 1 lu lu 194 1月 21 2003 ejbdemo/DemoSessionHome.java 2. Mark some file in "*Find*" buffer In "*File" buffer,it looks like: /home/lu/workspace/: find . \( -name "*.java" \) -exec ls -ld \{\} \; -rw-r--r-- 1 lu lu 215 1月 21 2003 ejbdemo/DemoEntity.java * -rw-r--r-- 1 lu lu 178 1月 21 2003 ejbdemo/DemoSession.java * -rw-r--r-- 1 lu lu 146 1月 21 2003 ejbdemo/DemoSessionLocal.java * -rw-r--r-- 1 lu lu 573 1月 21 2003 ejbdemo/DemoSessionEJB.java -rw-r--r-- 1 lu lu 194 1月 21 2003 ejbdemo/DemoSessionHome.java * -rw-r--r-- 1 lu lu 159 1月 21 2003 ejbdemo/DemoSessionLocalHome.java 3. call batch-query-replace-regexp. >> (defun batch-query-replace-regexp() >> (interactive) >> (switch-to-buffer "*Find*") >> (dired-do-query-replace-regexp "jp\\.co" "jp.co2") >> ->can't reach here (switch-to-buffer "*Find*") >> (dired-do-query-replace-regexp "java" "java2") ...a lot of pattern to query-replace-regexp >> ) >> You can press "Q" key to dired-do-query-replace-regexp once. But I have about 50 patterns to replace, do it one by one is quite troublesome. so I copy patterns from excel file and write them to a function (which named batch-query-replace-regexp above). The problem is the function finished when first call of dired-do-query-replace-regexp finish. Doesn't you feel it is strange? Andreas Röhler writes: > Am Samstag, 1. Dezember 2007 02:00 schrieb Ke Lu: >> > Do want to change filenames in a directory or the contents of files in >> > that directory? >> >> I don't want to change filenames. >> I want to change contents of files in a directory. >> > > So let's start with the first task: > > If you want to add a "2" at all endings in that directory, > > as "jp.co" => "jp.co2" let's assume, > > you can perform this > > with > > M-x wdired-change-to-wdired-mode > > M-x query-replace-regexp $ RET 2 ! > > If everything looks fine, do C-c C-c to write down your > changing or quit (with C-c ESC or C-d). > > With quit nothing is changed. > > Andreas Röhler