![]() ![]() The variable is always local to the current terminal and cannot be buffer-local. This variable is the definition of the most recently defined keyboard macro. The commands start-kbd-macro, kmacro-start-macro and end-kbd-macro set this variable-do not set it yourself. The value is append while appending to the definition of an existing macro. A command can test this variable so as to behave differently while a macro is being defined. This variable is non- nil if and only if a keyboard macro is being defined. A command can test this variable so as to behave differently when run from an executing macro. ![]() It is nil if no macro is currently executing. This variable contains the string or vector that defines the keyboard macro that is currently executing. See Reading One Event, for an example of using execute-kbd-macro. If loopfunc returns nil, then this stops execution of the macro. If loopfunc is non- nil, it is a function that is called, without arguments, prior to each iteration of the macro. If it is 0, kbdmacro is executed over and over until it encounters an error or a failing search. If count is omitted or nil, kbdmacro is executed once. The argument count is a repeat count kbdmacro is executed that many times. If the result is not a symbol, string, or vector, an error is signaled. Eventually the result should be a string or vector. If that is another symbol, this process repeats. If kbdmacro is a symbol, then its function definition is used in place of kbdmacro. The sequence is not expected to be a single key sequence normally a keyboard macro definition consists of several key sequences concatenated. If kbdmacro is a string or vector, then the events in it are executed exactly as if they had been input by the user. This function executes kbdmacro as a sequence of events. function execute-kbd-macro kbdmacro \&optional count loopfunc Don’t confuse keyboard macros with Lisp macros (see Macros). ![]() The Lisp representation of a keyboard macro is a string or vector containing the events. This is particularly useful in scenarios where a predicate function returns a true value that contains useful information beyond t or nil.A keyboard macro is a canned sequence of input events that can be considered a command and made the definition of a key. ![]() What both of these macros have in common is that they emulate an existing conditional special form, while adding a local binding that makes it possible to access the result of the condition. (let ((escape (gensym "awhile-escape-"))) The value of the testĮxpression is locally bound to 'it' during execution of the body The second macro is an anaphoric version of while: (defmacro awhile (test &rest body) The binding is present in both consequent The value of the testĮxpression is locally bound to 'it' during execution of theĬonsequent clauses. The first of the two macros is an anaphoric version of the standard if special form: (defmacro aif (test if-expr &optional else-expr) Since I haven't been able to find Emacs Lisp implementations of these macos, I wrote my own. My first exposure to this type of macro (and deliberate variable capture) was in Paul Graham's On Lisp. In my Lisp programming, I find myself using Anaphoric Macros quite a bit. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |