| | 1 | [[PageOutline]] |
| | 2 | |
| | 3 | = 13 Simple Customization = |
| | 4 | |
| | 5 | Hemlock can be customized and extended to a very large degree, but in |
| | 6 | order to do much of this a knowledge of Lisp is required. These |
| | 7 | advanced aspects of customization are discussed in the Hemlock Command |
| | 8 | Implementor's Manual, while simpler methods of customization are |
| | 9 | discussed here. |
| | 10 | |
| | 11 | == 13.1 Keyboard Macros == |
| | 12 | |
| | 13 | Keyboard macros provide a facility to turn a sequence of commands into |
| | 14 | one command. |
| | 15 | |
| | 16 | Define Keyboard Macro (bound to C-x () [Command] |
| | 17 | |
| | 18 | End Keyboard Macro (bound to C-x )) [Command] |
| | 19 | |
| | 20 | Define Keyboard Macro starts the definition of a keyboard macro. The |
| | 21 | commands which are invoked up until End Keyboard Macro is invoked |
| | 22 | become the definition for the keyboard macro, thus replaying the |
| | 23 | keyboard macro is synonymous with invoking that sequence of commands. |
| | 24 | |
| | 25 | |
| | 26 | Last Keyboard Macro (bound to C-x e) [Command] |
| | 27 | |
| | 28 | This command is the keyboard macro most recently defined; invoking it |
| | 29 | will replay the keyboard macro. The prefix argument is used as a |
| | 30 | repeat count. |
| | 31 | |
| | 32 | |
| | 33 | Define Keyboard Macro Key (bound to C-x M-(; ) [Command] |
| | 34 | |
| | 35 | Define Keyboard Macro Key Confirm (initial value t) [Variable] |
| | 36 | |
| | 37 | This command prompts for a key before going into a mode for defining |
| | 38 | keyboard macros. After defining the macro Hemlock binds it to the |
| | 39 | key. If the key is already bound, Hemlock asks for confirmation before |
| | 40 | clobbering the binding; this prompting can be inhibited by setting |
| | 41 | Define Keyboard Macro Key Confirm to nil. |
| | 42 | |
| | 43 | |
| | 44 | |
| | 45 | Keyboard Macro Query (bound to C-x q) [Command] |
| | 46 | |
| | 47 | This command conditionalizes the execution of a keyboard macro. When |
| | 48 | invoked during the definition of a macro, it does nothing. When the |
| | 49 | macro replays, it prompts the user for a key-event indicating what |
| | 50 | action to take. The following commands are defined: |
| | 51 | |
| | 52 | Escape:: |
| | 53 | Exit all repetitions of this keyboard macro. More than one may have |
| | 54 | been specified using a prefix argument. |
| | 55 | |
| | 56 | Space, y:: |
| | 57 | Proceed with the execution of the keyboard macro. |
| | 58 | |
| | 59 | Delete, Backspace, n:: |
| | 60 | Skip the remainder of the keyboard macro and go on to the next |
| | 61 | repetition, if any. |
| | 62 | |
| | 63 | !:: |
| | 64 | Do all remaining repetitions of the keyboard macro without prompting. |
| | 65 | |
| | 66 | .:: |
| | 67 | Complete this repetition of the macro and then exit without doing |
| | 68 | any of the remaining repetitions. |
| | 69 | |
| | 70 | C-r:: |
| | 71 | Do a recursive edit and then prompt again. |
| | 72 | |
| | 73 | |
| | 74 | Name Keyboard Macro [Command] |
| | 75 | |
| | 76 | This command prompts for the name of a command and then makes the |
| | 77 | definition for that command the same as Last Keyboard Macro's current |
| | 78 | definition. The command which results is not clobbered when another |
| | 79 | keyboard macro is defined, so it is possible to keep several keyboard |
| | 80 | macros around at once. The resulting command may also be bound to a |
| | 81 | key using Bind Key, in the same way any other command is. |
| | 82 | |
| | 83 | |
| | 84 | |
| | 85 | Many keyboard macros are not for customization, but rather for |
| | 86 | one-shot use, a typical example being performing some operation on |
| | 87 | each line of a file. To add "del " to the beginning and ".*" to the |
| | 88 | end of every line in in a buffer, one could do this: |
| | 89 | |
| | 90 | {{{ |
| | 91 | C-x ( d e l Space C-e . * C-n C-a C-x ) C-u 9 9 9 C-x e |
| | 92 | }}} |
| | 93 | |
| | 94 | First a keyboard macro is defined which performs the desired operation |
| | 95 | on one line, and then the keyboard macro is invoked with a large |
| | 96 | prefix argument. The keyboard macro will not actually execute that |
| | 97 | many times; when the end of the buffer is reached the C-n will get an |
| | 98 | error and abort the execution. |
| | 99 | |
| | 100 | == 13.2 Binding Keys == |
| | 101 | |
| | 102 | Bind Key [Command] |
| | 103 | |
| | 104 | This command prompts for a command, a key and a kind of binding to |
| | 105 | make, and then makes the specified binding. The following kinds of |
| | 106 | bindings are allowed: |
| | 107 | |
| | 108 | buffer:: |
| | 109 | Prompts for a buffer and then makes a key binding which is only |
| | 110 | present when that buffer is the current buffer. |
| | 111 | |
| | 112 | mode:: |
| | 113 | Prompts for the name of a mode and then makes a key binding which is |
| | 114 | only in present when that mode is active in the current buffer. |
| | 115 | |
| | 116 | global:: |
| | 117 | Makes a global key binding which is in effect when there is no |
| | 118 | applicable mode or buffer key binding. This is the default. |
| | 119 | |
| | 120 | |
| | 121 | Delete Key Binding [Command] |
| | 122 | |
| | 123 | This command prompts for a key binding the same way that Bind Key does |
| | 124 | and makes the specified binding go away. |
| | 125 | |
| | 126 | |
| | 127 | |
| | 128 | == 13.3 Hemlock Variables == |
| | 129 | |
| | 130 | A number of commands use Hemlock variables as flags to control their |
| | 131 | behavior. Often you can get a command to do what you want by setting a |
| | 132 | variable. Generally the default value for a variable is chosen to be |
| | 133 | the safest value for novice users. |
| | 134 | |
| | 135 | Set Variable [Command] |
| | 136 | |
| | 137 | This command prompts for the name of a Hemlock variable and an |
| | 138 | expression, then sets the current value of the variable to the result |
| | 139 | of the evaluation of the expression. |
| | 140 | |
| | 141 | |
| | 142 | Defhvar [Command] |
| | 143 | |
| | 144 | Like Set Variable, this command prompts for the name of a Hemlock |
| | 145 | variable and an expression. Like Bind Key, this command prompts for a |
| | 146 | place: mode, buffer or local. The result of evaluating the expression |
| | 147 | is defined to be the value of the named variable in the specified |
| | 148 | place. |
| | 149 | |
| | 150 | This command is most useful for making mode or buffer local bindings |
| | 151 | of variables. Redefining a variable in a mode or buffer will create a |
| | 152 | customization that takes effect only when in that mode or buffer. |
| | 153 | |
| | 154 | Unlike Set Variable, the variable name need not be the name of an |
| | 155 | existing variable: new variables may be defined. If the variable is |
| | 156 | already defined in the current environment, Hemlock copies the |
| | 157 | documentation and hooks to the new definition. |
| | 158 | |
| | 159 | |
| | 160 | == 13.4 Init Files == |
| | 161 | |
| | 162 | Hemlock customizations are normally put in Hemlock's initialization |
| | 163 | file, "hemlock-init.lisp", or when compiled "hemlock-init.fasl". When |
| | 164 | starting up Lisp, use the -hinit switch to indicate a particular |
| | 165 | file. The contents of the init file must be Lisp code, but there is a |
| | 166 | fairly straightforward correspondence between the basic customization |
| | 167 | commands and the equivalent Lisp code. Rather than describe these |
| | 168 | functions in depth here, a brief example follows: |
| | 169 | |
| | 170 | {{{ |
| | 171 | ;;; -*- Mode: Lisp; Package: Hemlock -*- |
| | 172 | |
| | 173 | ;;; It is necessary to specify that the customizations go in |
| | 174 | ;;; the hemlock package. |
| | 175 | (in-package 'hemlock) |
| | 176 | |
| | 177 | ;;; Bind Kill Previous Word to M-h. |
| | 178 | (bind-key "Kill Previous Word" '#(#\m-h)) |
| | 179 | ;;; |
| | 180 | ;;; Bind Extract List to C-M-? when in Lisp mode. |
| | 181 | (bind-key "Extract List" '#(#\c-m-?) :mode "Lisp") |
| | 182 | |
| | 183 | ;;; Make C-w globally unbound. |
| | 184 | (delete-key-binding '#(#\c-w)) |
| | 185 | |
| | 186 | ;;; Make string searches case-sensitive. |
| | 187 | (setv string-search-ignore-case nil) |
| | 188 | ;;; |
| | 189 | ;;; Make "Query Replace" replace strings literally. |
| | 190 | (setv case-replace nil) |
| | 191 | }}} |
| | 192 | |
| | 193 | For a detailed description of these functions, see the Hemlock Command |
| | 194 | Implementor's Manual. |
| | 195 | |