* Apply a saved macro to region
@ 2008-01-31 15:18 Ankur Jain
2008-01-31 15:22 ` Michael Hoffman
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Ankur Jain @ 2008-01-31 15:18 UTC (permalink / raw)
To: Gnu Emacs Mailing List
[-- Attachment #1: Type: text/plain, Size: 304 bytes --]
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.
--
Regards
Ankur Jain
http://ankurjain.org
[-- Attachment #2: Type: text/html, Size: 384 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Apply a saved macro to region
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
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Michael Hoffman @ 2008-01-31 15:22 UTC (permalink / raw)
To: help-gnu-emacs
Ankur Jain wrote:
> 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.
It would be easier just to use query-replace-regexp to add a comma to
the end of each line:
M-C-% $ RET , RET
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Apply a saved macro to region
2008-01-31 15:22 ` Michael Hoffman
@ 2008-01-31 15:46 ` Ankur Jain
0 siblings, 0 replies; 7+ messages in thread
From: Ankur Jain @ 2008-01-31 15:46 UTC (permalink / raw)
To: Michael Hoffman; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 728 bytes --]
But there are some other similar macros, which would have same requirement
for me. So, is it possible to run a saved macro to run for a selected
region. Like apply-macro-to-region-lines function for a saved macro.
Ankur
On Jan 31, 2008 8:52 PM, Michael Hoffman <b3i4old02@sneakemail.com> wrote:
> Ankur Jain wrote:
>
> > 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.
>
> It would be easier just to use query-replace-regexp to add a comma to
> the end of each line:
>
> M-C-% $ RET , RET
>
>
>
>
--
Regards
Ankur Jain
http://ankurjain.org
[-- Attachment #2: Type: text/html, Size: 1100 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Apply a saved macro to region
2008-01-31 15:18 Apply a saved macro to region Ankur Jain
2008-01-31 15:22 ` Michael Hoffman
@ 2008-01-31 15:50 ` Andreas Röhler
2008-01-31 16:06 ` Tom Tromey
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2008-01-31 15:50 UTC (permalink / raw)
To: help-gnu-emacs
Am Donnerstag, 31. Januar 2008 16:18 schrieb Ankur Jain:
> 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.
What about a function?
(defun insert-comma-at-region-end (beg end)
" "
(interactive "*r")
(goto-char (region-end))
(insert ","))
Andreas Röhler
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Apply a saved macro to region
2008-01-31 15:18 Apply a saved macro to region Ankur Jain
2008-01-31 15:22 ` Michael Hoffman
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-02-01 1:10 ` Nikos Apostolakis
4 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2008-01-31 16:06 UTC (permalink / raw)
To: help-gnu-emacs
>>>>> "Ankur" == Ankur Jain <ankurj@gmail.com> writes:
Ankur> I saved a macro which appends a comma(,) at the end of a
Ankur> line. I want to apply this saved macro to a region now. I mean,
Ankur> I select a region in emacs and do "append_comma" macro command
Ankur> to apply this to the whole region.
What I would usually do is make a keyboard macro that operates on the
current line and then moves to the next line. That way if I run it
multiple times it will do the right thing.
Then to apply it to a region, I would 'C-x n n' (narrow-to-region),
move to the start, and run it enough times. You can do this using C-u
a lot. Finally, 'C-x n w' to widen to the whole buffer again.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Apply a saved macro to region
[not found] ` <mailman.6814.1201797949.18990.help-gnu-emacs@gnu.org>
@ 2008-01-31 20:03 ` Colin S. Miller
0 siblings, 0 replies; 7+ messages in thread
From: Colin S. Miller @ 2008-01-31 20:03 UTC (permalink / raw)
To: help-gnu-emacs
Tom Tromey wrote:
>>>>>> "Ankur" == Ankur Jain <ankurj@gmail.com> writes:
>
> Ankur> I saved a macro which appends a comma(,) at the end of a
> Ankur> line. I want to apply this saved macro to a region now. I mean,
> Ankur> I select a region in emacs and do "append_comma" macro command
> Ankur> to apply this to the whole region.
>
> What I would usually do is make a keyboard macro that operates on the
> current line and then moves to the next line. That way if I run it
> multiple times it will do the right thing.
>
> Then to apply it to a region, I would 'C-x n n' (narrow-to-region),
> move to the start, and run it enough times. You can do this using C-u
> a lot. Finally, 'C-x n w' to widen to the whole buffer again.
Tom, Ankur,
C-u 0 C-x e
repeats the last macro until the bell rings. (C-u nnn C-x erepeats the macro 'nnn' times).
As previous commentators have said, you are better of with regexps (they are lot faster).
Disabling font-lock-mode (or even putting the buffer into fundamental-mode) will speed up macros.
HTH,
Colin S. Miller
>
> Tom
>
>
>
--
Replace the obvious in my email address with the first three letters of the hostname to reply.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Apply a saved macro to region
2008-01-31 15:18 Apply a saved macro to region Ankur Jain
` (3 preceding siblings ...)
[not found] ` <mailman.6814.1201797949.18990.help-gnu-emacs@gnu.org>
@ 2008-02-01 1:10 ` Nikos Apostolakis
4 siblings, 0 replies; 7+ messages in thread
From: Nikos Apostolakis @ 2008-02-01 1:10 UTC (permalink / raw)
To: help-gnu-emacs
"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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-02-01 1:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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.