From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mathias Dahl Newsgroups: gmane.emacs.help Subject: Re: creating a tags file for interactive search and replace regexp Date: Tue, 20 Jun 2006 11:55:44 +0200 Message-ID: References: <878xns1u6a.fsf@offby1.atm01.sea.blarg.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1150800064 15537 80.91.229.2 (20 Jun 2006 10:41:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 20 Jun 2006 10:41:04 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 20 12:41:02 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fsdey-0008NW-I7 for geh-help-gnu-emacs@m.gmane.org; Tue, 20 Jun 2006 12:40:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fsdey-0000XR-1x for geh-help-gnu-emacs@m.gmane.org; Tue, 20 Jun 2006 06:40:40 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 31 Original-X-Trace: individual.net xaZ0UHKgx43eMlB562slSAw4yoPVpt5mUYkTaAxyFAKHIP/b+S User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt) Cancel-Lock: sha1:BVbp8UgYCCWpTx2dD1j5DNfDUeI= Original-Xref: shelby.stanford.edu gnu.emacs.help:139929 Original-To: help-gnu-emacs@gnu.org 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:35553 Archived-At: "Ryan Krauss" writes: > Is there a way to do the dired-do-query-replace-regexp based on marked > files in the standard buffer list? The reason I ask is that it is > very easy for me to use python to open emacs with only the files I > want (basically doing emacs file1.tex file2.tex ...). The buffer list > will already have all the files I want and only the files I want. I ripped apart dired-do-query-replace-regexp and came up with this: (defun query-replace-regexp-in-files (from to files &optional delimited) "Do `query-replace-regexp' of FROM with TO, on all FILES. Third arg DELIMITED (prefix arg) means replace only word-delimited matches. If you exit (\\[keyboard-quit], RET or q), you can resume the query replace with the command \\[tags-loop-continue]." (dolist (file files) (let ((buffer (get-file-buffer file))) (if (and buffer (with-current-buffer buffer buffer-read-only)) (error "File `%s' is visited read-only" file)))) (tags-query-replace from to delimited 'files)) Example of usage: (query-replace-regexp-in-files "from" "to" '("c:/tmp/test1.txt" "c:/tmp/test2.txt")) /Mathias