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: need help with editing multiple files in a directory Date: Fri, 20 Jul 2007 07:33:19 +0200 Message-ID: References: <1184860347.592401.221020@22g2000hsm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1184910065 9682 80.91.229.12 (20 Jul 2007 05:41:05 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 20 Jul 2007 05:41:05 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 20 07:41:03 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 1IBlEc-0006DN-RB for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jul 2007 07:41:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IBlEc-0007KX-4U for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Jul 2007 01:41:02 -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: 19 Original-X-Trace: individual.net bbMt9LCeU3OTwsufegzL6QhEame3eRJiSODXUlNiOVOWr+h2b0 Cancel-Lock: sha1:Z2jHgxKbapkwh33kpwrVVsOStfs= sha1:q+YyMtmtS2TfiglqN5icfn1wEXM= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (windows-nt) Original-Xref: shelby.stanford.edu gnu.emacs.help:150246 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:45827 Archived-At: bittna@gmail.com writes: > Hello, I have multiple files in a directory that need a line added > at a certain point in the file. I wrote a lisp expression to do it, > but I have to load the file, then run the command on the buffer, the > save the file and I lose my place. I used dired to do a find and > replace on all of the files I needed, but how do I run my lisp > expression on all of the files? Pascal posted a good example of how to use lisp to do what you want. Depending on what exactly it is that you want to do, I would also suggest using keyboard macros, they are really useful for adhoc manipulations. Find the files to work with in Dired, kill all other lines, then record the macro having point on the first file, do all manipulations you want to do, close the file, go to the next file and stop macro recording. Then execute the macro for the rest of the files. Works in many cases. /Mathias