unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Nikos Apostolakis <nikos.ap@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Apply a saved macro to region
Date: Thu, 31 Jan 2008 20:10:43 -0500	[thread overview]
Message-ID: <87myqlwkfg.fsf@Sullivan.bcc.cuny.edu> (raw)
In-Reply-To: fb9f05100801310718j5aceb08bt92247cd220a769f8@mail.gmail.com

"Ankur Jain" <ankurj@gmail.com> writes:

> Hi
>
> I saved a macro which appends a comma(,) at the end of a line. I want to apply
> this saved macro to a region now. I mean, I select a region in emacs and do
> "append_comma" macro command to apply this to the whole region.
>
> If that's possible, kindly reply.
>

There are two solutions that come to mind.  The first one is to use
"C-x C-k C-n" etc to bring the desired macro at the front of the
keyboard macro ring (yes, emacs has one of those) and then call
"apply-macro-to-region-lines" as usual.

Also, looking at the documentation of "apply-macro-to-region-lines"
we see that it takes an optional argument "macro", the problem is
that the this argument cannot be given interactively.  So one could
do something like

(defun my-apply-macro-to-region-lines (start end macro)
  "Wrapper of apply-macro-to-region-lines."
(interactive "r\nCnamed kboard macro to apply: ")
(apply-macro-to-region-lines start end macro))

and then provide the name of the saved macro at the prompt.  Note
that this hasn't being really tested, and my elisp skills are not
that great, but it should work.

HTH,
Nikos





      parent reply	other threads:[~2008-02-01  1:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 15:18 Apply a saved macro to region Ankur Jain
2008-01-31 15:22 ` Michael Hoffman
2008-01-31 15:46   ` Ankur Jain
2008-01-31 15:50 ` Andreas Röhler
2008-01-31 16:06 ` Tom Tromey
     [not found] ` <mailman.6814.1201797949.18990.help-gnu-emacs@gnu.org>
2008-01-31 20:03   ` Colin S. Miller
2008-02-01  1:10 ` Nikos Apostolakis [this message]

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=87myqlwkfg.fsf@Sullivan.bcc.cuny.edu \
    --to=nikos.ap@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).