unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Macros in dired - Is it possible?
Date: Sat, 18 Jul 2009 02:14:47 -0700 (PDT)	[thread overview]
Message-ID: <7b577771-72b5-4d61-ad90-430bb2e81d49@m3g2000pri.googlegroups.com> (raw)
In-Reply-To: mailman.2744.1247896840.2239.help-gnu-emacs@gnu.org

On Jul 17, 11:41 am, 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?
>
> [ *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	other threads:[~2009-07-18  9:14 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 ` Xah Lee [this message]
2009-07-18 17:19   ` Macros in dired - Is it possible? zeek
2009-07-18 21:10     ` Anselm Helbig
2009-07-18 21:02 ` muede
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=7b577771-72b5-4d61-ad90-430bb2e81d49@m3g2000pri.googlegroups.com \
    --to=xahlee@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).