From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "ISHIKAWA,chiaki" Newsgroups: gmane.emacs.help 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 Message-ID: References: <51ed4bfc-fbb1-9c29-afe9-fafabab3b7ce@yk.rim.or.jp> <87r37o5nm5.fsf@gavenkoa.example.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1476232001 7966 195.159.176.226 (12 Oct 2016 00:26:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2016 00:26:41 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 To: Oleksandr Gavenko , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 12 02:26:25 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bu7N2-0006be-5M for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Oct 2016 02:26:08 +0200 Original-Received: from localhost ([::1]:58547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu7N0-0004QL-U9 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Oct 2016 20:26:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu7MZ-0004QB-W1 for help-gnu-emacs@gnu.org; Tue, 11 Oct 2016 20:25:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bu7MV-0005Xf-IF for help-gnu-emacs@gnu.org; Tue, 11 Oct 2016 20:25:38 -0400 Original-Received: from mail117.siriuscloud.jp ([219.118.72.117]:44002 helo=mail07.SiriusCloud.jp) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bu7MU-0005V1-Qa for help-gnu-emacs@gnu.org; Tue, 11 Oct 2016 20:25:35 -0400 Original-Received: from [192.168.0.111] (ntkngw423231.kngw.nt.ngn2.ppp.infoweb.ne.jp [111.64.168.231]) (Authenticated sender: ishikawa@yk.rim.or.jp) by access07.SiriusCloud.jp (Postfix) with ESMTPA id BFDEE400F6D9C; Wed, 12 Oct 2016 09:25:25 +0900 (JST) Authentication-Results: access07.SiriusCloud.jp; dkim=none (no signature) header.i=unknown; x-dkim-adsp=none (insecure policy) In-Reply-To: <87r37o5nm5.fsf@gavenkoa.example.com> X-Virus-Scanned: clamav-milter 0.98.6 at si-mail07 X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 219.118.72.117 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111505 Archived-At: 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 >