This package interacts with a shell’s native completion functionality to provide the same completions in Emacs that you would get from the shell itself.
Currently this has been tested in
- various CAD tool shells
This package contains two completion functions;
native-complete-at-point is a “completion at point
function” (capf) and can be enabled by adding it to
completion-at-point-functions in a shell buffer.
company-native-complete is an
asynchronous backend for the company completion framework. It is enabled by
adding it to
These functions look at the shell prompt or process name to determine which
completion style to use. A completion style is the mechanism used to get the
candidates from the native shell. Most shells support
<tab> , but some shells
won’t give you all the candidates consistently without using a different
mechanism. There are currently the following completion styles:
Which completion mechanism to use is determined by the
shell-file-name, which is
the executable that is used to start your shell. If the mechanism can’t be
determined from that, or if you use subshells that are a different type, you can
native-complete-style-regex-alist. This variable is a alist of
. mechanism) pairs. If the prompt of the current shell matches
mechanism will be used. For example, if your prompt is of the
user> and your shell is bash, you could you the following setting to
(setq native-complete-style-regex-alist '(("[a-z]+> " . bash)))
To test what completion style your shell is using, evaluate
(native-complete-get-completion-style) when the point is at an empty prompt.
The default completion mechanism is
native-complete-exclude-regex is a regular expression that is used to match
potential candidates that should not appear in the final completion list.
prompt components in completion list
if you encouter an issue where parts of your shell prompt are showing up as
completion candidates you can add a function to
comint-redirect-filter-functions to remove the prompt line from the process
output. See the doc string of that variable for more details.
native-complete-setup-bash in Emacs before you load your first shell.
(with-eval-after-load 'shell (native-complete-setup-bash))
HISTCONTROL environment variable is not set to
you will get a lot of garbage in your shell history.
Make sure editing is enabled.