Changes between Initial Version and Version 1 of HemlockUser/SimpleCustomization

11/05/07 18:09:42 (9 years ago)



  • HemlockUser/SimpleCustomization

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