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

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

Re: Applying macro to lines which match regexp


From: Andreas Politz
Subject: Re: Applying macro to lines which match regexp
Date: Thu, 16 Oct 2008 01:36:59 +0200
User-agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724)

Corey Foote wrote:
I was reading through the Emacs manual today, and came across C-x C-k r 
(apply-macro-to-region-lines) which applies the last keyboard macro to each 
line that begins in the region. How would I apply the last keyboard macro to 
each line that begins in the region which match a certain regular expression. 
For example, say I was editing a Perl script and wanted to apply the last macro 
to all line which consist solely of a comment. For example:

1    # Print some text
2    print "foo";
3    print "foobar";
4
5    # And then a while later
6    print "foobarbaz";

I would want to apply the macro to lines 1 and 6 which match the regular 
expression ^\s-*#. Thanks a bunch!

Corey Foote
Toby Software

Bind the macro, e.g. with C-x C-k b 1 , and create another new macro
that does the searching part and then calls macro-1.
Or edit your macro (C-x C-k e) and prepend some searching `code'.

-ap


reply via email to

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