* cannot call-last-kbd-macro on named macro @ 2006-05-09 19:30 james.kingston 2006-05-09 19:33 ` james.kingston ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: james.kingston @ 2006-05-09 19:30 UTC (permalink / raw) 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. 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? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 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 [not found] ` <mailman.1620.1147209514.9609.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 9+ messages in thread From: james.kingston @ 2006-05-09 19:33 UTC (permalink / raw) As a workaround... I realized that I could define a kbd macro that called my named macro... C-x ( M-x toggle-next-perlsub C-x ) heh... it works, I guess ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 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 [not found] ` <mailman.1620.1147209514.9609.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 9+ messages in thread From: Kevin Rodgers @ 2006-05-09 21:17 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.1620.1147209514.9609.help-gnu-emacs@gnu.org>]
* Re: cannot call-last-kbd-macro on named macro [not found] ` <mailman.1620.1147209514.9609.help-gnu-emacs@gnu.org> @ 2006-05-10 19:12 ` james 2006-05-15 12:08 ` Brendan Halpin 0 siblings, 1 reply; 9+ messages in thread From: james @ 2006-05-10 19:12 UTC (permalink / raw) I'd have to disagree that C-x e is easier to type than F5. I find that if I tried typing it a bunch of times in a row I'd eventually hit C-x C-e and land in the backtrace buffer... but thank you for clearing that all up. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 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 0 siblings, 2 replies; 9+ messages in thread From: Brendan Halpin @ 2006-05-15 12:08 UTC (permalink / raw) "james" <james.kingston@gmail.com> writes: > I'd have to disagree that C-x e is easier to type than F5. A very nice feature of CVS emacs is that once you type C-x e to execute a macro, you can re-execute it by typing e. Brendan -- Brendan Halpin, Department of Sociology, University of Limerick, Ireland Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147 mailto:brendan.halpin@ul.ie http://www.ul.ie/sociology/brendan.halpin.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 2006-05-15 12:08 ` Brendan Halpin @ 2006-05-15 17:50 ` Kevin Rodgers 2006-05-16 15:20 ` Mathias Dahl 1 sibling, 0 replies; 9+ messages in thread From: Kevin Rodgers @ 2006-05-15 17:50 UTC (permalink / raw) Brendan Halpin wrote: > A very nice feature of CVS emacs is that once you type C-x e to > execute a macro, you can re-execute it by typing e. Wow, there are a lot of nice features in Emacs 22 (see etc/NEWS): ** The new kmacro package provides a simpler user interface to emacs' keyboard macro facilities. Basically, it uses two function keys (default F3 and F4) like this: F3 starts a macro, F4 ends the macro, and pressing F4 again executes the last macro. While defining the macro, F3 inserts a counter value which automatically increments every time the macro is executed. There is now a keyboard macro ring which stores the most recently defined macros. The C-x C-k sequence is now a prefix for the kmacro keymap which defines bindings for moving through the keyboard macro ring, C-x C-k C-p and C-x C-k C-n, editing the last macro C-x C-k C-e, manipulating the macro counter and format via C-x C-k C-c, C-x C-k C-a, and C-x C-k C-f. See the commentary in kmacro.el for more commands. The normal macro bindings C-x (, C-x ), and C-x e now interfaces to the keyboard macro ring. The C-x e command now automatically terminates the current macro before calling it, if used while defining a macro. In addition, when ending or calling a macro with C-x e, the macro can be repeated immediately by typing just the `e'. You can customize this behavior via the variables kmacro-call-repeat-key and kmacro-call-repeat-with-arg. Keyboard macros can now be debugged and edited interactively. C-x C-k SPC steps through the last keyboard macro one key sequence at a time, prompting for the actions to take. -- Kevin ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 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 1 sibling, 1 reply; 9+ messages in thread From: Mathias Dahl @ 2006-05-16 15:20 UTC (permalink / raw) Brendan Halpin <brendan.halpin@ul.ie> writes: >> I'd have to disagree that C-x e is easier to type than F5. > > A very nice feature of CVS emacs is that once you type C-x e to > execute a macro, you can re-execute it by typing e. Yes, that is really neat! How is it done? Programatically I mean. It would be cool to be able to do the same with other commands (buffer cycling, for example, which is now by default on C-x <left> and C-x <right>). ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 2006-05-16 15:20 ` Mathias Dahl @ 2006-05-16 15:41 ` Brendan Halpin 2006-05-19 14:06 ` Mathias Dahl 0 siblings, 1 reply; 9+ messages in thread From: Brendan Halpin @ 2006-05-16 15:41 UTC (permalink / raw) Mathias Dahl <brakjoller@gmail.com> writes: > Brendan Halpin <brendan.halpin@ul.ie> writes: > >> A very nice feature of CVS emacs is that once you type C-x e to >> execute a macro, you can re-execute it by typing e. > > Yes, that is really neat! How is it done? Programatically I mean. It > would be cool to be able to do the same with other commands (buffer > cycling, for example, which is now by default on C-x <left> and C-x > <right>). The function kmacro-call-macro in kmacro.el might be a good starting point. Brendan -- Brendan Halpin, Department of Sociology, University of Limerick, Ireland Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147 mailto:brendan.halpin@ul.ie http://www.ul.ie/sociology/brendan.halpin.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: cannot call-last-kbd-macro on named macro 2006-05-16 15:41 ` Brendan Halpin @ 2006-05-19 14:06 ` Mathias Dahl 0 siblings, 0 replies; 9+ messages in thread From: Mathias Dahl @ 2006-05-19 14:06 UTC (permalink / raw) Brendan Halpin <brendan.halpin@ul.ie> writes: >> Yes, that is really neat! How is it done? Programatically I mean. It >> would be cool to be able to do the same with other commands (buffer >> cycling, for example, which is now by default on C-x <left> and C-x >> <right>). > > The function kmacro-call-macro in kmacro.el might be a good > starting point. Aaaaa... After looking at that piece of code for a while I noticed this: (if (equal repeat-key (read-event)) So *that* is what it does, read another event and then handles that. Cool! Don't ask me why I did not bother to look this up myself, it was right there, only a C-h k away... :) ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-05-19 14:06 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 [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
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).