all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: muede <politza@googlemail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Macros in dired - Is it possible?
Date: Sat, 18 Jul 2009 14:02:04 -0700 (PDT)	[thread overview]
Message-ID: <f1bdfe94-359d-49d2-ab9d-6030d68c8de4@k1g2000yqf.googlegroups.com> (raw)
In-Reply-To: mailman.2744.1247896840.2239.help-gnu-emacs@gnu.org

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


  parent reply	other threads:[~2009-07-18 21:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2744.1247896840.2239.help-gnu-emacs@gnu.org>
2009-07-18  9:14 ` Macros in dired - Is it possible? Xah Lee
2009-07-18 17:19   ` zeek
2009-07-18 21:10     ` Anselm Helbig
2009-07-18 21:02 ` muede [this message]
2009-07-18 21:08 ` Anselm Helbig
2009-07-19  2:29   ` zeek
2009-07-19 16:04     ` Xah Lee
2009-07-17 18:41 zeek peters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f1bdfe94-359d-49d2-ab9d-6030d68c8de4@k1g2000yqf.googlegroups.com \
    --to=politza@googlemail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.