Keyboard MacrosEpsilon can remember a set of keystrokes, and store them away in a keyboard macro. Executing a keyboard macro has the same effect as typing the characters themselves. Use keyboard macros to make repetitive changes to a buffer that involve the same keystrokes. You can even write new commands with keyboard macros.
To define a keyboard macro, use the Ctrl-x ( command. The echo area will display the message "Remembering", and the word "Def" will appear in the mode line. Whatever you type at the keyboard gets executed as it does normally, but Epsilon also stores the keystrokes away in the definition of the keyboard macro.
When you have finished defining the keyboard macro, press the Ctrl-x ) key. The echo area will display the message "Keyboard macro defined", and a keyboard macro named last-kbd-macro will then exist with the keys you typed since you issued the Ctrl-x ( command. To execute the macro, use the Ctrl-F4 command (or use Ctrl-x e if you prefer). This executes the last macro defined from the keyboard. If you want to repeatedly execute the macro, give the Ctrl-F4 command a numeric argument telling how many times you want to execute the macro.
You can bind this macro to a different key, naming it as well, using the bind-last-macro function on Ctrl-x Alt-n. Once the macro has its own name, defining a new macro won't overwrite it. This command prompts for a new name, then asks for a key binding for the macro. (You can press Ctrl-g at that point if you want to give the macro a name but not its own key binding.) The name-kbd-macro command prompts for a name but doesn't offer to bind the macro to a key. (Use delete-name to delete a keyboard macro.)
You can make a keyboard macro that suspends itself while running to wait for some user input, then continues. Press Shift-F4 while writing the macro and Epsilon will stop recording. Press Shift-F4 again to continue recording. When you play back the macro, Epsilon will stop at the same point in the macro to let you type in a file name, do some editing, or whatever's appropriate. Press Shift-F4 to continue running the macro. When a macro has been suspended, "Susp" appears in the mode line.
Keyboard macros do not record most types of mouse operations. Commands in a keyboard macro must be keyboard keys. However, you can invoke commands on a menu or tool bar while defining a keyboard macro, and they will be recorded correctly. While running a macro, Epsilon's commands for killing and yanking text don't use the clipboard; see Clipboard Access.
Instead of interactive definition with Ctrl-x (, you can also define keyboard macros in a command file. The details appear in the section on command files, which appears in Command Files. Command files also provide a way to edit an existing macro, by inserting it into a scratch buffer in an editable format with the insert-macro command, modifying the macro text, then using the load-buffer command to load the modified macro.
Epsilon doesn't execute a keyboard macro as it reads the definition from a command file, like it does when you define a macro from the keyboard. This causes a rather subtle difference between the two methods of definition. Keyboard macros may contain other keyboard macros, simply by invoking a second macro inside a macro definition. When you create a macro from the keyboard, the keys you used to invoke the second macro do not appear in the macro. Instead, the text of the second macro appears. This allows you to define a temporary macro, accessible with Ctrl-F4, and then define another macro using the old macro.
With macros defined from files, this substitution does not take place. Epsilon makes such a macro contain exactly the keys you specified in the file. When you execute this macro, the inner macro will execute at the right time, then the outer macro will continue, just as you would expect.
The difference between these two ways of defining macros that contain other macros shows up when you consider what happens if you redefine the inner macro. An outer macro defined from the keyboard remains the same, since it doesn't contain any reference to the inner macro, just the text of the inner macro at the time you defined the outer one. However, an outer macro defined from a file contains a reference to the inner macro, by name or by a key bound to that macro. For this reason the altered version of the inner macro will execute in the course of executing the outer macro.
Normally Epsilon refrains from writing to the screen during the execution of a keyboard macro, or during typeahead. The command redisplay forces a complete rewrite of the screen. You may find this useful for writing macros that should update the screen in the middle of execution.