2.8 Completion

Eshell uses the pcomplete package for programmable completion, similar to that of other command shells. Argument completion differs depending on the preceding command: for example, possible completions for rmdir are only directories, while rm completions can be directories and files. Eshell provides predefined completions for the built-in functions and some common external commands, and you can define your own for any command.

Eshell completion also works for Lisp forms and glob patterns. If the point is on a Lisp form, then TAB will behave similarly to completion in elisp-mode and lisp-interaction-mode. For glob patterns, the pattern will be removed from the input line, and replaced by the completion.

If you want to see the entire list of possible completions (e.g. when it’s below the completion-cycle-threshold), press M-?.

2.8.1 pcomplete

Pcomplete, short for programmable completion, is the completion library originally written for Eshell, but usable for command completion6 in other modes.

Completions are defined as functions (with defun) named pcomplete/COMMAND, where COMMAND is the name of the command for which this function provides completions; you can also name the function pcomplete/MAJOR-MODE/COMMAND to define completions for a specific major mode.


Footnotes

(6)

Command completion, as opposed to code completion, which is beyond the scope of pcomplete.