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

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

Re: Apply a saved macro to region


From: Nikos Apostolakis
Subject: Re: Apply a saved macro to region
Date: Thu, 31 Jan 2008 20:10:43 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

"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





reply via email to

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