help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macros in dired - Is it possible?


From: Xah Lee
Subject: Re: Macros in dired - Is it possible?
Date: Sun, 19 Jul 2009 09:04:04 -0700 (PDT)
User-agent: G2/1.0

On Jul 18, 7:29 pm, zeek <zp1z...@gmail.com> wrote:
> Thank you Anselm Helbig and Muede for the functions
>
> Looking forward to trying them out. Already learning more Lisp. There
> is no way I could have come up with them.
>
> Now I understand why I couldn't get the macros to save & kill the
> buffer - makes sense. Well written.
>
> Thank you again for responding so quickly with your solutions.
>
> Cheers

To apply a function to marked files in dired, use “dired-get-marked-
files”, like this:

;; idiom for processing a list of files in dired's marked files

;; suppose myProcessFile is your function that takes a file path
;; and do some processing on the file

(defun dired-myProcessFile ()
  "apply myProcessFile function to marked files in dired."
  (interactive)
  (require 'dired)
  (mapc 'myProcessFile (dired-get-marked-files))
)

See:
• Emacs Lisp Idioms
  http://xahlee.org/emacs/elisp_idioms.html

you just need to write the myProcessFile function ... it's pretty easy
to do what you want. The function should open the file, use search-
forward to move cursor to the place of the word, then delete that
paragraph, repeat, then save the file. I'd say this code would be less
than 20 or 30 lines, and will take (me) about 20 min.

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]