whitney@walsh.harvard.edu (Glen Whitney) (03/09/89)
How is the term "keyboard macros" used in this newsgroup, and (how) does Emacs support them? If they're simply elisp functions bound to keys, no need to reply on that matter. More importantly, a question I could not find the answer to in *Info*: Is it possible to embed cursor motions into an abbrev, so that if I have a complex abbrev (say for a LaTeX structure), the cursor will end up where I want to be typing? Thanks. -Glen. Other ID stuff above. (Am I supposed to have a disclaimer?)
jr@bbn.com (John Robinson) (03/11/89)
In article <1366@husc6.harvard.edu>, whitney@walsh (Glen Whitney) writes: >How is the term "keyboard macros" used in this newsgroup, and (how) >does Emacs support them? If they're simply elisp functions bound to >keys, no need to reply on that matter. They aren't. An Apropos on "macro" gives you a long list of stuff; several entries refer to kbd-macros. ^H a kbd-macro yields: call-last-kbd-macro C-x e Function: Call the last keyboard macro that you defined with C-x (. defining-kbd-macro Variable: Non-nil means store keyboard input into kbd macro being defined. end-kbd-macro C-x ) Function: Finish defining a keyboard macro. execute-kbd-macro Function: Execute MACRO as string of editor command characters. executing-kbd-macro Variable: Currently executing keyboard macro (a string); nil if none executing. insert-kbd-macro Function: Insert in buffer the definition of kbd macro NAME, as Lisp code. kbd-macro-query C-x q Function: Query user during kbd macro execution. last-kbd-macro Variable: Last kbd macro defined, as a string; nil if none defined. mouse-call-kbd-macro Function: Invokes last keyboard macro at mouse cursor. name-last-kbd-macro Function: Assign a name to the last keyboard macro defined. start-kbd-macro C-x ( Function: Record subsequent keyboard input, defining a keyboard macro. The important ones are the bound ones. Suppose you are about to type something at emacs that you will want to type over and over again. before starting, type ^X (. Emacs will echo "Defining kbd macro" in the minibuffer. Every key you type will be saved away in a string (and will also have its normal effect) until you type ^X ), at which point Emacs will say "Keyboard macro defined". Now you can "retype" the exact same sequence of characters by simply typing ^X e. These characters can do anything at all, including searches, cursor motions, inserts, kills, what have you. There should be an explanation of this in Info. Some of the other functions let you save away the kbd macro string as a named command so you can call it later using M-X, or turn it into an elisp definition suitable for placing in your .emacs. Also, there is a package which attempts to "disassemble" the keyboard macro into the sequence of lisp functions its causes to be executed, so that you can make it into a real function. >More importantly, a question I could not find the answer to in *Info*: > >Is it possible to embed cursor motions into an abbrev, so that if I >have a complex abbrev (say for a LaTeX structure), the cursor will >end up where I want to be typing? For abbrevs, I am not sure. But maybe you want to use keyboard macros, now that I have described them. Maybe not. -- /jr jr@bbn.com or bbn!jr
jthomas@nmsu.EDU (03/11/89)
Recently, John Robinson <jr%bbn.com> answered:
] In article <1366@husc6.harvard.edu>, whitney@walsh (Glen Whitney) writes:
] >How is the term "keyboard macros" used in this newsgroup, and (how)
] >does Emacs support them? If they're simply elisp functions bound to
] >keys, no need to reply on that matter.
.....
] >More importantly, a question I could not find the answer to in *Info*:
] >
] >Is it possible to embed cursor motions into an abbrev, so that if I
] >have a complex abbrev (say for a LaTeX structure), the cursor will
] >end up where I want to be typing?
] For abbrevs, I am not sure. But maybe you want to use keyboard
] macros, now that I have described them. Maybe not.
Of course, if you don't mind lisp, one can use M-x edit-abbrevs and add
hooks as the fourth argument to the abbreviation (as some electric modes
do, for example. Then one can put the cursor whereever one wants (or do
other handwaving) in a lisp function call or two.
Jim Thomas jthomas@nmsu.edu