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: Sat, 18 Jul 2009 02:14:47 -0700 (PDT)
User-agent: G2/1.0

On Jul 17, 11:41 am, zeek peters <address@hidden> wrote:
> [ *Question* ]
> Is it possible to mark files in dired and then run a macro on all
> the selected files?
>
> [ *Background* ]
> The macro finds and deletes certain portions/paragraphs from text
> files to cut them down in size so that I can read them easier and quicker.
>
> But I am getting tired of loading one file at a time into Emacs to
> run the macro ( via ^u 0 MX macro1 ). I do this about 100x/day. So is there
> a
> quicker/better way to run a macro en mass?
>
> [ *What I Have Tried, but Hasn't Worked* ]
> As an example
> 1. I load 10 text files into emacs, thus creating 10 separate
> buffers.
> 2. Then tried creating another macro that calls the first macro,
> and also saves the edited and much smaller file, and then kills the buffer
> 3.  So, for 10 files, I would call macro2 via [ ^u 10 Mx macro2 ]
> 4. The problem, I am having is that the 2nd macro doesn't record
> the save or the kill. So, I tried to edit the saved macro2 via [
> Mx edit-named-k TAB RET macro2 ]. I add the commands [ ^x ^s ]
> and [ ^x k RET ], and do a [ c ^c ]. The changes are saved, but
> when I try again, the 2nd macro calls macro1 to do its magic, but
> the modifications aren't saved, nor is the buffer killed. So,
> only one of the 10 files files has been modified.
>
> [ *What I have learned* ]
> A lot, since I am a completely new to this. Learned a little bit about Git,
> compiling, Org-mode. Currently, reading the both manuals ( emacs
> and Lisp how2 ).
>
> I'm looking forward to learning more, but starting to get a bit
> frustated. Hope you could offer some insight/assistance. Thanks
>
> [ *Info* ]
> emacs-snapshot ( GNU Emacs 23.0.95.1 (i486-pc-linux-gnu, GTK+
> Version 2.16.4) of 2009-07-03

seems what you wanted certainly can be done. But it is very unclear to
me exactly what you want to be done.

can you give description in terms of what you watn to do exactly?
e.g.

which files you want to process? are they all html files? files with
certain line? etc?

what do you want to do to each file? delete certain lines, then save?
what text pattern does the line needs to match? etc.

kbd macros are typically one session use only. they are not meant to
be edited, and they are pretty unreadable. They simply are record of
keystrokes. In your case, of calling kbd macros on kbd macros, is
probably much simpler having a elisp function.

  Xah
∑ http://xahlee.org/

reply via email to

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