From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Newsgroups: gmane.emacs.devel Subject: Re: Comint: handle raw tab Date: Tue, 13 Sep 2011 15:51:52 +0200 Message-ID: <87vcsw1rev.fsf@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1315922237 17270 80.91.229.12 (13 Sep 2011 13:57:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 13 Sep 2011 13:57:17 +0000 (UTC) Cc: Emacs-Devel devel , Fabian Ezequiel Gallina To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 13 15:57:12 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R3TU5-0007kQ-23 for ged-emacs-devel@m.gmane.org; Tue, 13 Sep 2011 15:57:09 +0200 Original-Received: from localhost ([::1]:34971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3TU4-0007oQ-Fw for ged-emacs-devel@m.gmane.org; Tue, 13 Sep 2011 09:57:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:54011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3TTz-0007ny-Db for emacs-devel@gnu.org; Tue, 13 Sep 2011 09:57:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3TTx-0005ae-S9 for emacs-devel@gnu.org; Tue, 13 Sep 2011 09:57:03 -0400 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:41415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3TTx-0005aH-H1 for emacs-devel@gnu.org; Tue, 13 Sep 2011 09:57:01 -0400 Original-Received: by fxh17 with SMTP id 17so671867fxh.0 for ; Tue, 13 Sep 2011 06:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:content-transfer-encoding; bh=jNSgc+6k10tXQHR/qcLeaTH0fyAewGQNUpjW75TiTWg=; b=tX9E38ehFb63mhamm8TYhavZAZNi9jxTXSyDfBOZuGvvqyrXWGjxJOpCXyxkjEI+8L uBYtg+0rgzq5cN8GyYXMUKVb/IHRtudfQc9Q6Kx6X0h5tj7cmq6ieoUgAjpvgix4ex6n gBKdNX4TaYaSo3CTqnxcCU9fe9zqF7w2MQu8w= Original-Received: by 10.223.101.2 with SMTP id a2mr1577105fao.2.1315922220031; Tue, 13 Sep 2011 06:57:00 -0700 (PDT) Original-Received: from localhost (176.119.broadband10.iol.cz. [90.177.119.176]) by mx.google.com with ESMTPS id w6sm535161fah.0.2011.09.13.06.56.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Sep 2011 06:56:58 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Tue, 13 Sep 2011 08:43:10 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:143969 Archived-At: On Tue, 13 Sep 2011 14:43:10 +0200 Stefan Monnier wrote: >> First case scenario, unique completion: >> Consider the only possible completion being "True". >> In [1]: Tr >> Then hit C-q TAB so a TAB gets inserted after it and evaled: >> (comint-send-input t) >> In a normal ipython shell the result of this causes the input to be expa= nded >> to "True" which is the unique completion. On the comint buffer this caus= es >> the input to remain frozen. Internally, the input *does* get updated sin= ce >> when I hit RET after evaling the code above the out shows "True" but I >> didn't find a way to update the current input accordingly. Is there any = way >> to achieve that? > > You're going to have to redirect the process's output to read the > shell's output and then use it to fill the user's current input. > >> Second scenario, multiple completions available: >> Consider now I have typed just T: >> In [1]: T >> Then hit C-q TAB so a TAB gets inserted after it and evaled: >> (comint-send-input t) >> Now interesting things happens, since ipython outputs the list of possib= le >> completions I can get them with comint-output-filter-functions, the thin= g is >> the buffer now looks like this: >> In [1]: T >> TabError True TypeError > >> And the only way I found to show the prompt again without sending "T" to= the >> process was sending a BREAK signal because comint-delete-input does not = work >> in that instance. Is there a better way to handle that? > > The better way (IMNSHO) is to catch the process output so it doesn't get > inserted in the buffer, build a completion table from it, and then > call the normal in-buffer completion code with it so it gets displayed > in *Completions*. IMO native tab completion for subprocess REPLs is a common enough need that the basic machinery should be handled by Emacs itself, i.e. probably the comint library. I'm somewhat surprised there is no such code yet (or is there, outside Emacs perhaps?). --=20 =C5=A0t=C4=9Bp=C3=A1n