wiki:HemlockUser/SpecialModes

6 Special Modes

6.1 Dired Mode

Hemlock provides a directory editing mechanism. The user can flag files and directories for deletion, undelete flagged files, and with a keystroke read in files and descend into directories. In some implementations, it also supports copying, renaming, and a simple wildcard feature.

6.1.1 Inspecting Directories

Dired (bound to C-x C-M-d) [Command]

This command prompts for a directory and fills a buffer with a verbose listing of that directory. When the prefix argument is supplied, this includes Unix dot files. If a dired buffer already exists for the directory, this switches to the buffer and makes sure it displays dot files if appropriate.

Dired with Pattern (bound to C-x C-M-d) [Command]

This command prompts for a directory and a pattern that may contain at most one wildcard, an asterisk, and it fills a buffer with a verbose listing of the files in the directory matching the pattern. When the prefix argument is supplied, this includes Unix dot files. If a dired buffer already exists for this directory, this switches to the buffer and makes sure it displays dot files if appropriate.

Dired from Buffer Pathname [Command]

This command invokes Dired on the directory name of the current buffer's pathname.

Dired Help (bound to Dired: ?) [Command]

This command pops up a help window listing the various Dired commands.

Dired View File (bound to Dired: Space) [Command]

Dired Edit File (bound to Dired: e) [Command]

These command read in the file on the current line with the point. If the line describes a directory instead of a file, then this command effectively invokes Dired on the specification. This associates the file's buffer with the Dired buffer.

Dired View File reads in the file as if by View File, and Dired Edit File as if by Find File.

Dired View File always reads into a newly created buffer, warning if the file already exists in some buffer.

Dired Up Directory (bound to Dired: ) [Command]

This command invokes Dired on the directory up one level from the current Dired buffer. This is useful for going backwards after repeatedly invoking Dired View File and descending into a series of subdirectories. Remember, Dired only generates directory listings when no buffer contains a dired for the specified directory.

Dired Update Buffer (bound to Dired: H-u) [Command]

This command is useful when the user knows the directory in the current Dired buffer has changed. Hemlock cannot know the directory structure has changed, but the user can explicitly update the buffer with this command instead of having to delete it and invoke Dired again.

Dired Next File [Command] Dired Previous File [Command]

These commands move to next or previous undeleted file.

6.1.2 Deleting Files

Dired Delete File and Down Line (bound to Dired: d) [Command]

This command marks for deletion the file on the current line with the point and moves point down a line.

Dired Delete File with Pattern (bound to Dired: D) [Command]

This command prompts for a name pattern that may contain at most one wildcard, an asterisk, and marks for deletion all the names matching the pattern.

Dired Delete File (bound to Dired: C-d) [Command]

This command marks for deletion the file on the current line with the point without moving the point.

6.1.3 Undeleting Files

Dired Undelete File and Down Line (bound to Dired: u) [Command]

This command unmarks for deletion the file on the current line with the point and moves point down a line.

Dired Undelete File with Pattern (bound to Dired: U) [Command]

This command prompts for a name pattern that may contain at most one wildcard, an asterisk, and unmarks for deletion all the names matching the pattern.

Dired Undelete File (bound to Dired: C-u) [Command]

This command unmarks for deletion the file on the current line with the point without moving the point.

6.1.4 Expunging and Quitting

Dired Expunge Files (bound to Dired: !) [Command]

Dired File Expunge Confirm (initial value t) [Variable]

Dired Directory Expunge Confirm (initial value t) [Variable]

This command deletes files marked for deletion, asking the user for confirmation once for all the files flagged. It recursively deletes any marked directories, asking the user for confirmation once for all those marked. Dired File Expunge Confirm and Dired Directory Expunge Confirm when set to nil individually inhibit the confirmation prompting for the appropriate deleting.

Dired Quit (bound to Dired: q) [Command]

This command expunges any marked files or directories as if by Expunge Dired Files before deleting the Dired buffer.

6.1.5 Copying Files

Dired Copy File (bound to Dired: c) [Command]

This command prompts for a destination specification and copies the file on the line with the point. When prompting, the current line's specification is the default, which provides some convenience in supplying the destination. The destination is either a directory specification or a file name, and when it is the former, the source is copied into the directory under its current file name and extension.

Dired Copy with Wildcard (bound to Dired: C) [Command]

This command prompts for a name pattern that may contain at most one wildcard, an asterisk, and copies all the names matching the pattern. When prompting for a destination, this provides the Dired buffer's directory as a default. The destination is either a directory specification or a file name with a wildcard. When it is the former, all the source files are copied into the directory under their current file names and extensions. When it is the later, each sources file's substitution for the wildcard causing it to match the first pattern replaces the wildcard in the destination pattern; for example, you might want to copy "*.txt" to "*.text".

Dired Copy File Confirm (initial value t) [Variable]

This variable controls interaction with the user when it is not obvious what the copying process should do. This takes one of the following values:

t
When the destination specification exists, the copying process stops and asks the user if it should overwrite the destination.
nil
The copying process always copies the source file to the destination specification without interacting with the user.
:update
When the destination specification exists, and its write date is newer than the source's write date, then the copying process stops and asks the user if it should overwrite the destination.

6.1.6 Renaming Files

Dired Rename File (bound to Dired: r) [Command]

Rename the file or directory under the point.

Dired Rename with Wildcard (bound to Dired: R) [Command]

Rename files that match a pattern containing ONE wildcard.

Dired Rename File Confirm (initial value t) [Variable]

When non-nil, Dired will query before clobbering an existing file.

6.2 View Mode

View mode provides for scrolling through a file read-only, terminating the buffer upon reaching the end.

View File [Command]

This command reads a file into a new buffer as if by "Visit File", but read-only. Bindings exist for scrolling and backing up in a single key stroke.

View Help (bound to View: ?) [Command]

This command shows a help message for View mode.

View Edit File (bound to View: e) [Command]

This commands makes a buffer in View mode a normal editing buffer, warning if the file exists in another buffer simultaneously.

View Scroll Down (bound to View: Space) [Command]

View Scroll Deleting Buffer (initial value t) [Variable]

This command scrolls the current window down through its buffer. If the end of the file is visible, then this deletes the buffer if View Scroll Deleting Buffer is set. If the buffer is associated with a Dired buffer, this returns there instead of to the previous buffer.

View Return (bound to View: ) [Command]

View Quit (bound to View: q) [Command]

These commands invoke a function that returns to the buffer that created the current buffer in View mode. Sometimes this function does nothing, but it is useful for returning to Dired buffers and similar Hemlock features.

After invoking the viewing return function if there is one, View Quit deletes the buffer that is current when the user invokes it.

Also, bound in View mode are the following commands:

backspace, delete
Scrolls the window up.
<
Goes to the beginning of the buffer.

::

Goes to the end of the buffer.

6.3 Process Mode

Process mode allows the user to execute a Unix process within a Hemlock buffer. These commands and default bindings cater to running Unix shells in buffers. For example, Stop Buffer Subprocess is bound to H-z to stop the process you are running in the shell instead of binding Stop Main Process to this key which would stop the shell itself.

Shell (bound to C-M-s) [Command]

Shell Utility (initial value "/bin/csh") [Variable]

Shell Utility Switches (initial value nil) [Variable]

Current Shell (initial value ) [Variable]

Ask about Old Shells (initial value ) [Variable]

This command executes the process determined by the values of Shell Utility and Shell Utility Switches in a new buffer named "Shell n" where "n" is some distinguishing integer.

Current Shell is a Hemlock variable that holds to the current shell buffer. When Shell is invoked, if there is a Current Shell, the command goes to that buffer.

When there is no Current Shell, but shell buffers do exist, if Ask about Old Shells is set, the Shell command prompts for one of them, setting Current Shell to the indicated shell, and goes to the buffer.

Invoking Shell with an argument forces the creation of a new shell buffer.

Shell Utility is the string name of the process to execute.

Shell Utility Switches is a string containing the default command line arguments to Shell Utility. This is a string since the utility is typically "/bin/csh", and this string can contain I/O redirection and other shell directives.

Shell Command Line in Buffer [Command]

This command prompts for a buffer and a shell command line. It then runs a shell, giving it the command line, in the buffer.

Set Current Shell [Command]

This command sets the value of Current Shell.

Stop Main Process [Command]

This command stops the process running in the current buffer by sending a :SIGTSTP to that process. With an argument, stops the process using :SIGSTOP.

Continue Main Process [Command]

If the process in the current buffer is stopped, this command continues it.

Kill Main Process [Command]

Kill Process Confirm (initial value t) [Variable]

This command prompts for confirmation and kills the process running in the current buffer.

Setting this variable to nil inhibits Hemlock's prompting for confirmation.

Stop Buffer Subprocess [Command]

This command stops the foreground subprocess of the process in the current buffer, similar to the effect of C-Z in a shell.

Kill Buffer Subprocess [Command]

This command kills the foreground subprocess of the process in the current buffer.

Interrupt Buffer Subprocess [Command]

This command interrupts the foreground subprocess of the process in the current buffer, similar to the effect of C-C in a shell.

Quit Buffer Subprocess [Command]

This command dumps the core of the foreground subprocess of the processs in the current buffer, similar to the effect of C-\ in a shell.

Send EOF to Process [Command]

This command sends the end of file character to the process in the current buffer, similar to the effect of C-D in a shell.

Confirm Process Input [Command]

This command sends the text the user has inserted at the end of a process buffer to the process in that buffer. Resulting output is inserted at the end of the process buffer.

The user may edit process input using commands that are shared with Typescript mode, see section 9.2.

6.4 Bufed Mode

Hemlock provides a mechanism for managing buffers as an itemized list. Bufed supports conveniently deleting several buffers at once, saving them, going to one, etc., all in a key stroke.

Bufed (bound to C-x C-M-b) [Command]

This command creates a list of buffers in a buffer supporting operations such as deletion, saving, and selection. If there already is a Bufed buffer, this just goes to it.

Bufed Help [Command]

This command pops up a display of Bufed help.

Bufed Delete (bound to Bufed: C-d, C-D, D, d) [Command]

Virtual Buffer Deletion (initial value t) [Variable]

Bufed Delete Confirm (initial value t) [Variable]

Bufed Delete deletes the buffer on the current line.

When Virtual Buffer Deletion is set, this merely flags the buffer for deletion until Bufed Expunge or Bufed Quit executes.

Whenever these commands actually delete a buffer, if Bufed Delete Confirm is set, then Hemlock prompts the user for permission; if more than one buffer is flagged for deletion, this only prompts once. For each modified buffer, Hemlock asks to save the buffer before deleting it.

Bufed Undelete (bound to Bufed: U, u) [Command]

This command undeletes the buffer on the current line.

Bufed Expunge (bound to Bufed: !) [Command]

This command expunges any buffers marked for deletion regarding Bufed Delete Confirm.

Bufed Quit (bound to Bufed: q) [Command]

This command kills the Bufed buffer, expunging any buffers marked for deletion.

Bufed Goto (bound to Bufed: Space) [Command]

This command selects the buffer on the current line, switching to it.

Bufed Goto and Quit (bound to Bufed: S-leftdown) [Command]

This command goes to the buffer under the pointer, quitting Bufed. It supplies a function for Generic Pointer Up which is a no-op.

Bufed Save File (bound to Bufed: s) [Command]

This command saves the buffer on the current line.

6.5 Completion

This is a minor mode that saves words greater than three characters in length, allowing later completion of those words. This is very useful for the often long identifiers used in Lisp programs. As you type a word, such as a Lisp symbol when in Lisp mode, and you progress to typing the third letter, Hemlock displays a possible completion in the status line. You can then rotate through the possible completions or type some more letters to narrow down the possibilities. If you choose a completion, you can also rotate through the possibilities in the buffer instead of in the status line. Choosing a completion or inserting a character that delimits words moves the word forward in the ring of possible completions, so the next time you enter its initial characters, Hemlock will prefer it over less recently used completions.

Completion Mode [Command]

This command toggles Completion mode in the current buffer.

Completion Self Insert [Command]

This command is like Self Insert, but it also checks for possible completions displaying any result in the status line. This is bound to most of the key-events with corresponding graphic characters.

Completion Complete Word (bound to Completion: End) [Command]

This command selects the currently displayed completion if there is one, guessing the case of the inserted text as with Query Replace. Invoking this immediately in succession rotates through possible completions in the buffer. If there is no currently displayed completion on a first invocation, this tries to find a completion from text immediately before the point and displays the completion if found.

Completion Rotate Completions (bound to Completion: M-End) [Command]

This command displays the next possible completion in the status line. If there is no currently displayed completion, this tries to find a completion from text immediately before the point and displays the completion if found.

List Possible Completions [Command]

This command lists all the possible completions for the text immediately before the point in a pop-up display. Sometimes this is more useful than rotating through several completions to see if what you want is available.

Completion Bucket Size (initial value 20) [Variable]

Completions are stored in buckets determined by the first three letters of a word. This variable limits the number of completions saved for each combination of the first three letters of a word. If you have many identifier in some module beginning with the same first three letters, you'll need increase this variable to accommodate all the names.

Save Completions [Command]

Read Completions [Command]

Completion Database Filename (initial value nil) [Variable]

Save Completions writes the current completions to the file Completion Database Filename. It writes them, so Read Completions can read them back in preserving the most-recently-used order. If the user supplies an argument, then this prompts for a pathname.

Read Completions reads completions saved in Completion Database Filename. It moves any current completions to a less-recently-used status, and it removes any in a given bucket that exceed the limit Completion Bucket Size.

Parse Buffer for Completions [Command]

This command passes over the current buffer putting each valid completion word into the database. This is a good way of picking up many useful completions upon visiting a new file for which there are no saved completions.

6.6 CAPS-LOCK Mode

CAPS-LOCK is a minor mode in which Hemlock that inserts all alphabetic characters as uppercase letters.

Caps Lock Mode [Command]

This command toggles CAPS-LOCK mode for the current buffer; it is most useful when bound to a key, so you can enter and leave CAPS-LOCK mode casually.

Self Insert Caps Lock [Command]

This command inserts the uppercase version of the character corresponding to the last key-event typed.

6.7 Overwrite Mode

Overwrite mode is a minor mode which is useful for creating figures and tables out of text. In this mode, typing a key-event with a corresponding graphic character replaces the character at the point instead of inserting the character. Quoted Insert can be used to insert characters normally.

Overwrite Mode [Command]

This command turns on Overwrite mode in the current buffer. If it is already on, then it is turned off. A positive argument turns Overwrite mode on, while zero or a negative argument turns it off.

Self Overwrite [Command]

This command replaces the next character with the character corresponding to the key-event used to invoke the command. After replacing the character, this moves past it. If the next character is a tab, this first expands the tab into the appropriate number of spaces, replacing just the next space character. At the end of the line, it inserts the character instead of clobbering the newline.

This is bound to key-events with corresponding graphic characters in Overwrite mode.

Overwrite Delete Previous Character [Command]

This command replaces the previous character with a space and moves backwards. This deletes tabs and newlines.

6.8 Word Abbreviation

Word abbreviation provides a way to speed the typing of frequently used words and phrases. When in Abbrev mode, typing a word delimiter causes the previous word to be replaced with its expansion if there is one currently defined. The expansion for an abbrev may be any string, so this mode can be used for abbreviating programming language constructs and other more obscure uses. For example, Abbrev mode can be used to automatically correct common spelling mistakes and to enforce consistent capitalization of identifiers in programs.

Abbrev is an abbreviation for abbreviation, which is used for historical reasons. Obviously the original writer of Abbrev mode hated to type long words and could hardly use Abbrev mode while writing Abbrev mode.

A word abbrev can be either global or local to a major mode. A global word abbrev is defined no matter what the current major mode is, while a mode word abbrev is only defined when its mode is the major mode in the current buffer. Mode word abbrevs can be used to prevent abbrev expansion in inappropriate contexts.

6.8.1 Basic Commands

Abbrev Mode [Command]

This command turns on Abbrev mode in the current buffer. If Abbrev mode is already on, it is turned off. Abbrev mode must be on for the automatic expansion of word abbrevs to occur, but the abbreviation commands are bound globally and may be used at any time.

Abbrev Expand Only [Command]

This is the word abbrev expansion command. If the word before the point is a defined word abbrev, then it is replaced with its expansion. The replacement is done using the same case-preserving heuristic as is used by Query Replace. This command is globally bound to M-Space so that abbrevs can be expanded when Abbrev mode is off. An undesirable expansion may be inhibited by using C-q to insert the delimiter.

Inverse Add Global Word Abbrev (bound to C-x -) [Command]

Inverse Add Mode Word Abbrev (bound to C-x C-h, C-x Backspace) [Command]

Inverse Add Global Word Abbrev prompts for a string and makes it the global word abbrev expansion for the word before the point.

Inverse Add Mode Word Abbrev is identical to Inverse Add Global Word Abbrev except that it defines an expansion which is local to the current major mode.

Make Word Abbrev [Command]

This command defines an arbitrary word abbreviation. It prompts for the mode, abbreviation and expansion. If the mode "Global" is specified, then it makes a global abbrev.

Add Global Word Abbrev (bound to C-x +) [Command]

Add Mode Word Abbrev (bound to C-x C-a) [Command]

Add Global Word Abbrev prompts for a word and defines it to be a global word abbreviation. The prefix argument determines which text is used as the expansion:

no prefix argument
The word before the point is used as the expansion of the abbreviation.
zero prefix argument
The text in the region is used as the expansion of the abbreviation.
positive prefix argument
That many words before the point are made the expansion of the abbreviation.
negative prefix argument
Do the same thing as Delete Global Word Abbrev instead of defining an abbreviation.

Add Mode Word Abbrev is identical to Add Global Word Abbrev except that it defines or deletes mode word abbrevs in the current major mode.

Word Abbrev Prefix Mark (bound to M-") [Command]

This command allows Abbrev Expand Only to recognize abbreviations when they have prefixes attached. First type the prefix, then use this command. A hyphen (-) will be inserted in the buffer. Now type the abbreviation and the word delimiter. Abbrev Expand Only will expand the abbreviation and remove the hyphen.

Note that there is no need for a suffixing command, since Abbrev Expand Only may be used explicitly by typing M-Space.

Unexpand Last Word (bound to C-x u) [Command]

This command undoes the last word abbrev expansion. If repeated, undoes its own effect.

6.8.2 Word Abbrev Files

A word abbrev file is a file which holds word abbrev definitions. Word abbrev files allow abbrevs to be saved so that they may be used across many editing sessions.

Abbrev Pathname Defaults (initial value (pathname "abbrev.defns")) [Variable]

This is sticky default for the following commands. When they prompt for a file to write, they offer this and set it for the next time one of them executes.

Read Word Abbrev File [Command]

This command reads in a word abbrev file, adding all the definitions to those currently defined. If a definition in the file is different from the current one, the current definition is replaced.

Write Word Abbrev File [Command]

This command prompts for a file and writes all currently defined word abbrevs out to it.

Append to Word Abbrev File [Command]

This command prompts for a word abbrev file and appends any new definitions to it. An abbrev is new if it has been defined or redefined since the last use of this command. Definitions made by reading word abbrev files are not considered.

6.8.3 Listing Word Abbrevs

List Word Abbrevs [Command]

Word Abbrev Apropos [Command]

List Word Abbrevs displays a list of each defined word abbrev, with its mode and expansion.

Word Abbrev Apropos is similar, except that it only displays abbrevs which contain a specified string, either in the definition, expansion or mode.

6.8.4 Editing Word Abbrevs

Word abbrev definition lists are edited by editing the text representation of the definitions. Word abbrev files may be edited directly, like any other text file. The set of abbrevs currently defined in Hemlock may be edited using the commands described in this section.

The text representation of a word abbrev is fairly simple. Each definition begins at the beginning of a line. Each line has three fields which are separated by ASCII tab characters. The fields are the abbreviation, the mode of the abbreviation and the expansion. The mode is represented as the mode name inside of parentheses. If the abbrev is global, then the mode field is empty. The expansion is represented as a quoted string since it may contain any character. The string is quoted with double-quotes ("); double-quotes in the expansion are represented by doubled double-quotes. The expansion may contain newline characters, in which case the definition will take up more than one line.

Edit Word Abbrevs [Command]

This command inserts the current word abbrev definitions into the Edit Word Abbrevs buffer and then enters a recursive edit on the buffer. When the recursive edit is exited, the definitions in the buffer become the new current abbrev definitions.

Insert Word Abbrevs [Command]

This command inserts at the point the text representation of the currently defined word abbrevs.

Define Word Abbrevs [Command]

This command interprets the text of the current buffer as a word abbrev definition list, adding all the definitions to those currently defined.

6.8.5 Deleting Word Abbrevs

The user may delete word abbrevs either individually or collectively. Individual abbrev deletion neutralizes single abbrevs which have outlived their usefulness; collective deletion provides a clean slate from which to initiate abbrev definitions.

Delete All Word Abbrevs [Command]

This command deletes all word abbrevs which are currently defined.

Delete Global Word Abbrev [Command]

Delete Mode Word Abbrev [Command]

Delete Global Word Abbrev prompts for a word abbreviation and deletes its global definition. If given a prefix argument, deletes all global abbrev definitions.

Delete Mode Word Abbrev is identical to Delete Global Word Abbrev except that it deletes definitions in the current major mode.

6.9 Lisp Library

This is an implementation dependent feature. The Lisp library is a collection of local hacks that users can submit and share that is maintained by the Lisp group. These commands help peruse the catalog or description files and figure out how to load the entries.

Lisp Library [Command]

This command finds all the library entries and lists them in a buffer. The following commands describe and load those entries.

Describe Library Entry (bound to Lisp-Lib: space) [Command]

Describe Pointer Library Entry (bound to Lisp-Lib: leftdown) [Command]

Load Library Entry (bound to Lisp-Lib: rightdown) [Command]

Load Pointer Library Entry (bound to Lisp-Lib: l) [Command]

Editor Load Library Entry [Command]

Editor Load Pointer Library Entry [Command]

Load Library Entry and Load Pointer Library Entry load the library entry indicated by the line on which the point lies or where the user clicked the pointer, respectively. These load the entry into the current slave Lisp.

Editor Load Library Entry and Editor Load Pointer Library Entry are the same, but they load the entry into the editor Lisp.

Exit Lisp Library (bound to Lisp-Lib: q) [Command]

This command deletes the Lisp Library buffer.

Lisp Library Help (bound to Lisp-Lib: ?) [Command]

This command pops up a help window listing Lisp-Lib commands.