tags:

views:

161

answers:

2

Is there an emacs command which would apply a kbd macro to every file in dired?

e.g. query-replace-regexp has dired-do-query-replace-regexp

I'm looking for a dired-do-call-last-kbd-macro

+1  A: 

C-h f dired-do-query-replace-regexp reveals the code for this:

(dolist (file (dired-get-marked-files nil nil 'dired-nondirectory-p))
    (let ((buffer (get-file-buffer file)))
      (if (and buffer (with-current-buffer buffer
      buffer-read-only))
      (error "File `%s' is visited read-only" file))))

I'd just make some elisp that does what you want using this as a template

aaron
That is only the part that displays an error message. The part that does the replacing is this:(tags-query-replace from to delimited '(dired-get-marked-files nil nil 'dired-nondirectory-p))But the code you posted is probably better to base the code on anyway.
dkagedal
whoops, that's right! lol.
aaron
+2  A: 

Another option is to do this:

  1. go to the top of your dired buffer
  2. Record Macro
  3. Press enter to visit the file
  4. M-x kmacro-call-ring-2nd
  5. C-x o (other buffer)
  6. Down a line
  7. Stop Recording
  8. C-u 0 C-x e (call-last-keyboard-macro till the end of the file)
Jonathan Arkell
Interesting, but you shold not that you need to load kmacro first (a library I had never seen before).
dkagedal