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
lisp-interaction-mode. For glob
patterns, If there are few enough possible completions of the patterns,
they will be cycled when <TAB> is pressed, otherwise it will be removed
from the input line and the possible completions will be listed.
If you want to see the entire list of possible completions when it's below the cycling threshold, press M-?.
Pcomplete, short for programmable completion, is the completion library originally written for Eshell, but usable for command completion1 in other modes.
Completions are defined as functions (with
COMMAND is the name of the
command for which this function provides completions; you can also name
pcomplete/MAJOR-MODE/COMMAND to define completions
for a specific major mode.
 Command completion as opposed to code completion, which is a beyond the scope of pcomplete.