3.31 Running shell commands from the editor

The editor allows both single shell commands to be executed and also provides a means of running a shell interactively.

Shell Command

Editor Command

Argument:
command
Key sequence:
Meta+!
command

Executes the single shell command
command
. The output from the command is displayed in a Shell Output buffer. A prefix argument causes the output from the shell command to be sent to the
*terminal-io*
stream rather than the Shell Output buffer.

Run Command

Editor Command

Argument:
command
Key sequence: None

Executes the single shell command
command
in a Shell window. When the command terminates, the subprocess is closed down.

Shell

Editor Command

Argument: None
Key sequence: None

Opens a Shell window which allows the user to run a shell interactively. The major mode of the buffer is Shell mode, and the minor mode is Execute mode so the history key bindings available in the Listener can also be used in the Shell window.

Whenever the working directory is changed within the shell, the editor attempts to keep track of these changes and update the default directory of the Shell buffer. When a shell command is issued beginning with a string matching one of the editor variables shell-cd-regexp, shell-pushd-regexp or shell-popd-regexp, the editor recognises this command as a change directory command and attempt to change the default directory of the Shell buffer accordingly. If you have your own aliases for any of the shell change directory commands, alter the value of the appropriate variable. For example, if the value of shell-cd-regexp is
"cd
" and the shell command
cd
~programs/lisp
is issued, the next time the editor command
Wfind File
is issued, the default directory offered is
~programs/lisp
. If you find that the editor has not recognised a change directory command then the editor command
cd
may be used to change the default directory of the buffer.

CD

Editor Command

Arguments:
directory
Key sequence: None
Mode: Shell

Changes the directory associated with the current buffer to
directory
. The current directory is offered as a default.

shell-cd-regexp

Editor Variable

Default value:
"cd"
Mode: Shell

A regular expression that matches the shell command to change the current working directory.

shell-pushd-regexp

Editor Variable

Default value:
"pushd"
Mode: Shell

A regular expression that matches the shell command to push the current working directory onto the directory stack.

shell-popd-regexp

Editor Variable

Default value:
"popd"
Mode: Shell

A regular expression that matches the shell command to pop the current working directory from the directory stack.

prompt-regexp-string

Editor Variable

Default value:
"^[^#$%>
]*[#$%>] *"
Mode: Shell

The regexp used to find the prompt in a Shell window. This variable is also used in the Listener.

Interrupt Shell Subjob

Editor Command

Argument: None
Key sequence:
Ctrl+C Ctrl+C
Mode: Shell

Sends an interrupt signal to the subjob currently being run by the shell. This is equivalent to issuing the shell command
Ctrl+C
.

Note: this command does not work on Microsoft Windows.

Stop Shell Subjob

Editor Command

Argument: None
Key sequence:
Ctrl+C Ctrl+Z
Mode: Shell

Sends a stop signal to the subjob currently being run by the shell. This is equivalent to issuing the shell command
Ctrl+Z
.

Note: this command does not work on Microsoft Windows.

Shell Send Eof

Editor Command

Argument: None
Key sequence:
Ctrl+C Ctrl+D
Mode: Shell

Sends an end-of-file character (
Ctrl+D
) to the shell, causing either the shell or its current subjob to finish.