Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!voder!pyramid!leadsv!esl!dml From: dml@esl.com (Denis Lynch) Newsgroups: comp.sys.next Subject: Re: emacs shell Message-ID: Date: 19 Feb 91 18:06:53 GMT References: <2341@mas1.UUCP> <11903@pt.cs.cmu.edu> <16650@sdcc6.ucsd.edu> Sender: news@esl.ESL.COM Reply-To: dml@esl.com (Denis Lynch) Organization: ESL, Inc. Sunnyvale, CA Lines: 167 In-reply-to: cpenrose@sdcc13.ucsd.edu's message of 13 Feb 91 19:00:27 GMT Several people lately have complained of not being able to find the documentation on NeXT's nice csh editing features. It sure isn't easy to find, but the description is in the csh man page. Just for the record, here's the contents of my .bindings file: bind-to-key EraseWord \\e\\^? bind-to-key FilenameExpansion "\^I" This make Esc-Delete (and Alt-Delete in Terminal) like M-Del in Emacs, and makes the tab key do filename completion, like in Emacs. (My brain has trouble using tab for completion sometimes and escape other times.) Here's the relevant part of the 2.0 csh page, which is the same as the 1.0 page in this section. One caveat: csh's "binding" mechanism just aint emacs. In particular, csh can only deal with one-character prefixes. That means that your standard arrow key sequences (ESC-0-A, for example) can't be bound to csh editing functions. Too bad. EXTENDED C-SHELL FEATURES The version of the C-shell supplied on the NeXT computer includes several entensions, such as intra-command line editing, a kill buffer, multi-line named keyboard macros which can be automatically saved and restored, convenient access to the history list, and user settable key bindings. A summary of the currently available functions and their default key bindings is given in the BINDINGS section below. In most cases the functionality will be apparent from the names of the routines in the list. The shell's editing mode is determined by the value of the shell editmode variable which users should set to emacs in their .cshrc files If editmode is not set, then the shell will run in "dumb" mode. It is possible to set the mode after the shell starts up; so if you find yourself in "dumb" mode, you can alter the situation without having to log out and log in again. Setting the editmode variable has two important side effects: (1) it causes the key bindings to be reevaluated, and (2) it sets the EDITMODE environment variable. The latter has no effect within the shell; so users should not set the environment variable directly in hopes of altering the editing mode. Terminal control capabilities are extracted from the user's termcap file (usually /etc/termcap), using the value of the shell variable term -- not the environment variable TERM -- as the terminal type. If term is undefined, unknown, or if the associated termcap definition is inadequate, a warning will be displayed and most, or all, of the editing features of the shell will be disabled. It is the user's responsi- bility to make sure that term is set to an appropriate value before the editmode variable is set to emacs. Usually this should be done in the .cshrc file. If editing is disabled because term is not properly set when the shell starts up, simply setting term to the proper value will normally cause the shell editor to be re-enabled. NB: Setting the shell variable term causes the environment variable TERM to be set to the same value. For information on controlling the bell, see the DIAGNOSTICS section. There is a new command in this shell, bind-to-key, which allows the functions listed in the BINDINGS section below, and also user defined keyboard macros, to be bound to keys. The form of the command is bind-to-key function key ... where function is one of the function names from the list or else the single character name of a keyboard macro and where key is a quoted string designating a key sequence. Control characters in the key designation should not be entered literally, but should be indicated by the prefix "\^", e.g. "\^X". Similarly, escape is indicated by "\e". A literal slash is "\\". Escape and control-X are the only legitimate "prefix" characters. The following mnemonics should be used: "\t" for tab, "\^?" for rubout, "\n" for newline, and "\r" for return. Since the shell converts returns to new- lines it is probably unwise to alter the binding of newline. During editor initialization the shell will read a file named .bindings in the user's home directory. If you regu- larly want certain non-default key bindings to be effective, put the appropriate bind-to-key commands in your ~/.bindings file. NB: The bind-to-key commands would work if placed in your ~/.cshrc file, but they will be more useful (in the future) if they are in the ~/.bindings file. Invocation of the history mechanism with "!" either causes the matched command to be inserted on the command line for editing before execution or immediatedly executes the com- mand. This is controlled by the shell variable edithist, which is automatically set, when the shell variable editmode is set, thereby allowing editing of previous commands invoked by the history mechanism. This feature may be turned off with the command "unset edithist", which may be placed in the user's .cshrc file. HOW TO ENABLE THE EXTENDED C-SHELL FEATURES To enable the extended C-Shell features, put the line: set editmode = emacs in the .cshrc file in your home directory. If you don't have such a file, create one and add the line to the end. Log out and log in again and you will be using the new shell. BINDINGS The following functions and default key bindings are currently implemented. Emacs Function Name Remark ^B Backspace ESC-b BackwardWord ^A BeginningOfLine ^L ClearScreen DefaultBinding ESC-n DefineNamedMacro name macro ^D DeleteCurrentChar ^H DeletePreviousChar ESC-d DeleteWord after cursor EndOfFile exit shell ^E EndOfLine EraseLine kills whole line ESC-h EraseWord before cursor ESC-e ExecuteNamedMacro ESC-x ExecuteNamedMacro ^X-e ExecuteUnNamedMacro ESC-ESC FilenameExpansion ESC-l FilenameList ^F ForwardChar ESC-f ForwardWord ^W KillRegion to kill buffer ^K KillToEOL to kill buffer IncrementalSearchForward IncrementalSearchReverse InsertChar self insert ^V InsertLiteralChar ^X^R LoadMacroFile ^N NextHistEntry wraps around ^P PreviousHistEntry wraps around ^R Redisplay redraws line ^U Repetition greater than 0 ^M,^J Return ^X^S SaveMacroFile ^@ SetMark default mark at BOL SearchReverse look for next char SearchForward look for next char ^Q StartFlow (see FLOW CONTROL) ^X-( StartRemembering begin a macro ^S StopFlow (see FLOW CONTROL) ^X-) StopRemembering end a macro ^I Tab inserts 8 spaces ^T TransposeChars before cursor ^Y YankKillBuffer no kill ring Users may change the bindings of functions to keys by means of the shell bind-to-key command. These commands may be stored in a file named .bindings in the users home directory and will then be read by the shell when the editor is ini- tialized. NB: The shell variable bindings is no longer being sup- ported and will become ineffective in a future release. Before that happens users should convert to using the ~/.bindings file.