all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Applying macro to lines which match regexp
Date: Thu, 16 Oct 2008 01:36:59 +0200	[thread overview]
Message-ID: <1224114164.589682@arno.fh-trier.de> (raw)
In-Reply-To: <mailman.1136.1224098481.25473.help-gnu-emacs@gnu.org>

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


  parent reply	other threads:[~2008-10-15 23:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1136.1224098481.25473.help-gnu-emacs@gnu.org>
2008-10-15 19:54 ` Applying macro to lines which match regexp Xah
2008-10-15 21:16   ` Xah
2008-10-15 23:09     ` Parker, Matthew
2008-10-15 23:36 ` Andreas Politz [this message]
2008-10-16  0:38 ` Tim X
2008-10-15 19:21 Corey Foote

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

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

  git send-email \
    --in-reply-to=1224114164.589682@arno.fh-trier.de \
    --to=politza@fh-trier.de \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.