EoghanM
EoghanM

Reputation: 27013

Emacs: Keyboard Macros and Dired

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

Upvotes: 4

Views: 919

Answers (2)

Jonathan Arkell
Jonathan Arkell

Reputation: 10814

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)

Upvotes: 3

aaron
aaron

Reputation: 1796

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

Upvotes: 1

Related Questions