unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "ISHIKAWA,chiaki" <ishikawa@yk.rim.or.jp>
To: Oleksandr Gavenko <gavenkoa@gmail.com>, help-gnu-emacs@gnu.org
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	[thread overview]
Message-ID: <a6a03dd7-8fdb-ff57-bc96-540efb7c6a56@yk.rim.or.jp> (raw)
In-Reply-To: <87r37o5nm5.fsf@gavenkoa.example.com>

Hi,

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,
Chiaki

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:
>
>   http://stackoverflow.com/a/28618762/173149
>
> 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:
>
>   https://github.com/szermatt/emacs-bash-completion
>




  parent reply	other threads:[~2016-10-12  0:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-08 19:14 Question: Is there any way to use the bash completion feature from Emacs shell mode ISHIKAWA,chiaki
2016-10-09 18:11 ` Dan Hitt
2016-10-10  6:06   ` Eli Zaretskii
2016-10-10 14:05     ` Dan Hitt
2016-10-10 14:13       ` Dan Hitt
2016-10-11  1:02         ` Bob Proulx
2016-10-11  0:59       ` Bob Proulx
2016-10-11 12:12         ` Filipp Gunbin
2016-10-10  0:49 ` Bob Proulx
2016-10-10 13:40 ` Oleksandr Gavenko
2016-10-10 23:24   ` Dmitry Gutov
2016-10-12  0:25   ` ISHIKAWA,chiaki [this message]
2016-10-12 18:50     ` Oleksandr Gavenko
2016-10-19  1:12     ` Robert Thorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6a03dd7-8fdb-ff57-bc96-540efb7c6a56@yk.rim.or.jp \
    --to=ishikawa@yk.rim.or.jp \
    --cc=gavenkoa@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).