When using Emacs shell with the auto-completion feature enabled, I notice that whenever I perform typing and auto-completing a command, Emacs shell always adds an extra space after the first word. I illustrate this issue by an example as follow:
Suppose that my current working directory is
user@linux ~/foo/bar $
Now if I want to type the command
mkdir
by auto-completion, I first typemk
, and then pressTAB
to show a list of completion possibilities and pressENTER
choosemkdir
. Now, a whitespace is added at the end ofmkdir
, which is indicated by the pair[ ]
user@linux ~/foo/bar $ mkdir[ ]
In this scenario, adding a whitespace after the command
mkdir
is fine sincemkdir
is a full command, I certainly want to type a new word after that.But if the first word is not a full command, but a part of a command, a white-space is still added and it is quite inconvenient.
For example, I want to type and auto-complete the command such as
~/workspace/tool/my-command
Then, if I type
~/work
first and then pressTAB
to auto-complete, Emacs shell will automatically add a new white-space after the first directory~/workspace
, which is indicated by[ ]
user@linux ~/foo/bar $ ~/workspace[ ]
This is an unwanted white-space, since I have to delete it, in order to continue typing the rest of
~/workspace/tool/my-command
Is there anybody know how to make Emacs shell knows when an extra white-space should be added?
FYI, I am using the Spacemacs distribution of Emacs.
I discovered that this is due to the package bash-completion of Emacs. After removing it, the Emacs shell works as usual.
emacs -Q
. If that fixes the issue, as it should, then there's something in your config that has caused the problem.emacs -Q
. I also use Emacs 26.0.50. I will look into my configuration.bash-completion
of Emacs. After removing it, the Emacs shell works as usual