2

When running in a terminal, the shell does auto-completion even for loaded functions:

$ check-<tab><tab>
check-bios-nx           check-dirty             check-language-support  check-manifest          

And check-dirty is a function:

» type check-dirty 
check-dirty is a function
check-dirty () 
{ 
    is-older-than 24 ${REPO_LIST} || refresh-repo-list;
    cat ${REPO_LIST} | while read dir; do
        cd $dir;
        test -z "$(git status --porcelain)" || printf "%-50s : dirty\n" "$dir";
        cd - > /dev/null;
    done
}

But in emacs, the completions buffer show me a different list:

Click on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
check-bios-nx
check-language-support
check-manifest

The function is also loaded in the emacs shell buffer. In fact, the whole environment is exactly the same as the environment in the shell in the terminal (except minor things like TERM)

Why is my loaded function not being shown in auto-completion in emacs? Is there a "bash compatibility mode" for the shell mode?

It is this small inconsistencies in behavior which prevent me for going full emacs, and I keep using other tools (in this case bash in a terminal) for different tasks.

1

The completion function for shell-mode is shell--command-completion-data. It searches for filenames in the current directory and executable files on your path. It does not consider functions. You could write your own replacement function, possibly using the shell command declare -F to dynamically collect the list of defined functions. However, there's nothing available 'out of the box' to do this for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.