[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question: Is there any way to use the bash completion feature from E

From: ISHIKAWA,chiaki
Subject: Re: Question: Is there any way to use the bash completion feature from Emacs shell mode.
Date: Wed, 12 Oct 2016 09:25:25 +0900
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0


Sorry for top posting.

I have tried term mode and it certainly can use the full featured bash completion (tailored for each command, e.g. hg command, and its subcomands even.)

However, as some mentioned, basically almost all the keys are eaten now by term-mode. This negates the benefit of copy&paste using emacs of the output of previous commands executed by bash, etc.
(I can use mouse to do the operation, but I prefer key binding.)
However, I did not realize C-C ad C-X are swapped there. Maybe I should retry the experience.

emacs-bash-completion may be a way to go. I will check it out.

OTOH, I think my needs can be satisfied using
term mode, but somehow keeping C-N, C-P, C-@ and C-W for emacs.
After thinking more, I think I need C-A and C-E and C-K for emacs mode editing, too.
But this definitely interferes with bash's idea of readline editing.
We can't have cake and eat it, too.

I will try using these different methods a few days more and report back
my experience.

I once tried using term mode, but gave up.
But the merit of bash completion is now too good to ignore these days.
It magically works for many commands!

Thank you again.

Best Regards,

PS: The shell mode completion can
offer the candidates for command names and arguments that are filenames.
This is useful definitely.

But bash completion database "KNOWS" the name of the options each command takes, AND sometimes it knows where the argument which is mapped to a file path name in one way or the other: for example, MERCURIUM source control system command "hg" has "qqueue" subcommand to switch between different patch queues. Patch queues are stored
under .hg/patches-QQNAMES where QQNAMES is the name of the queue.
So if we issue
hg qqueue original
it refers to .hg/patches-original queue.
hg qqueue myfix
refers to .hg/patches-myfix

And this .hg subdirector is searched if it is not under the current directory. It will be searched in the parent directory, and so on. Bash completion is very clever (of course, it depends on the completion database that defines the functions to look for candidates for command options and arguments.)

The completion of Emacs's shell mode cannot handle such advanced mapping to a file name. But bash's completion can (!).
This is why I wanted to use bash's completion.

On 2016/10/10 22:40, Oleksandr Gavenko wrote:
On 2016-10-08, ISHIKAWA,chiaki wrote:

Unfortunately, bash's completion feature does not work in Emacs shell mode.
Obviously, [TAB] is stolen by Emacs for its own handling of TAB character.
Emacs's tab completion for filenames works great.
But I would like Bash's completion somehow works, too.

Please look to my answer:

In short you should learn ``M-x term`` mode and a few key binding:

 * ``C-C C-j``
 * ``C-c C-k``
 * ``C-c ...``

There is attempts to define ``comint-dynamic-complete-functions``:

--8<---------------cut here---------------start------------->8---
(defun comint-completion-at-point ()
  (run-hook-with-args-until-success 'comint-dynamic-complete-functions))
--8<---------------cut here---------------end--------------->8---

for readline-enabled programs:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]