[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macros in dired - Is it possible?
From: |
muede |
Subject: |
Re: Macros in dired - Is it possible? |
Date: |
Sat, 18 Jul 2009 14:02:04 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Jul 17, 8:41 pm, zeek peters <zp1z...@gmail.com> 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