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

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

Re: cannot call-last-kbd-macro on named macro


From: Kevin Rodgers
Subject: Re: cannot call-last-kbd-macro on named macro
Date: Tue, 09 May 2006 15:17:27 -0600
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)

james.kingston@gmail.com wrote:
GNU Emacs 21.4.1....

I have saved some keyboard macros using insert-kbd-macro into my
.emacs, like the following:

(fset 'toggle-next-perlsub
   [?\C-\M-s ?\\ ?b ?s ?u ?b ?\\ ?b ?\C-m ?\C-\M-s ?{ ?\C-m ?\M-x ?f ?o
?l ?d ?- ?d ?w ?i ?m ?- ?t ?o ?g ?g ?l ?e return])

I can M-x fold-next-perlsub if I want to run the macro, but I cannot
then run call-last-kbd-macro (which I have bound to an F-key)... it's
as if the macro is loaded as a function rather than a kbd macro.

No, a keyboard macro is also an interactive function (i.e. a command).
But `M-x call-last-kbd-macro' (which is already bound to `C-x e', not
any harder to type than <Fn>) calls the last keyboard macro that you
defined interactively with `C-x (', not the last macro you defined
programatically with `fset'.

If you want to run the last keyboard macro that you called via `M-x'
again, try `M-x M-p'.

As a workaround I could change the binding of the F-key to call my
named macro, but then I wouldn't be able to use the macros with
apply-macro-to-region-lines... So is there some way to push a named
macro onto some sort of macro stack so I can use the macro commands
with my macro?

First, note that `M-x apply-macro-to-region-lines' is available as
`C-x C-k r' in Emacs 22.  But in previous versions I used `C-x E':

(global-set-key "\C-xE" 'apply-macro-to-region-lines) ; uppercase `E'

To call named macros via apply-macro-to-region-lines, I use `C-u ...':

(defadvice apply-macro-to-region-lines (before read-named-macro activate)
"With a prefix arg, read a named macro to apply (instead of the last macro)."
  (interactive
   (list (region-beginning)
         (region-end)
         (if current-prefix-arg
             (read-command "Name of keyboard macro to apply: ")))))

--
Kevin





reply via email to

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