unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: cannot call-last-kbd-macro on named macro
Date: Tue, 09 May 2006 15:17:27 -0600	[thread overview]
Message-ID: <e3r0ug$oa9$1@sea.gmane.org> (raw)
In-Reply-To: <1147203016.768665.319890@v46g2000cwv.googlegroups.com>

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

  parent reply	other threads:[~2006-05-09 21:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-09 19:30 cannot call-last-kbd-macro on named macro james.kingston
2006-05-09 19:33 ` james.kingston
2006-05-09 21:17 ` Kevin Rodgers [this message]
     [not found] ` <mailman.1620.1147209514.9609.help-gnu-emacs@gnu.org>
2006-05-10 19:12   ` james
2006-05-15 12:08     ` Brendan Halpin
2006-05-15 17:50       ` Kevin Rodgers
2006-05-16 15:20       ` Mathias Dahl
2006-05-16 15:41         ` Brendan Halpin
2006-05-19 14:06           ` Mathias Dahl

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='e3r0ug$oa9$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /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).