From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: muede Newsgroups: gmane.emacs.help Subject: Re: Macros in dired - Is it possible? Date: Sat, 18 Jul 2009 14:02:04 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1247953264 28570 80.91.229.12 (18 Jul 2009 21:41:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Jul 2009 21:41:04 +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 Jul 18 23:40:57 2009 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 1MSHeA-0005OY-Fu for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Jul 2009 23:40:46 +0200 Original-Received: from localhost ([127.0.0.1]:34293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSHe9-0003IQ-U2 for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Jul 2009 17:40:45 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!k1g2000yqf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 34 Original-NNTP-Posting-Host: 88.68.192.67 Original-X-Trace: posting.google.com 1247950924 15060 127.0.0.1 (18 Jul 2009 21:02:04 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 18 Jul 2009 21:02:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k1g2000yqf.googlegroups.com; posting-host=88.68.192.67; posting-account=Cb0eCQoAAADOp8Qt5mU0s83Gs6qJzY70 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.11) Gecko/2009061208 Iceweasel/3.0.9 (Debian-3.0.9-1),gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:171025 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:66212 Archived-At: On Jul 17, 8:41=A0pm, zeek peters wrote: > [ *Question* ] > Is it possible to mark files in dired and then run a macro on all > the selected files? > You could write a function like this one. (defun dired-do-apply-form (form &optional arg) (interactive "xApply form: \nP") (save-window-excursion (dolist (f (dired-get-marked-files nil arg 'dired-nondirectory-p)) (let ((visiting-p (find-buffer-visiting f)) (buffer (find-file f))) (condition-case nil (eval form) (error)) (unless (or visiting-p ;; form may have killed the buffer (not (buffer-live-p buffer))) (with-current-buffer buffer (save-buffer) (kill-this-buffer))))))) Mark some files in a dired buffer, then M-x dired-do-apply-form RET (kmacro-call-macro 0) RET to run the last macro till an error occurs on each file. -ap