From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: Completion Date: Wed, 05 Sep 2018 18:03:17 -0500 Message-ID: <867ejzfsy2.fsf@stephe-leake.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1536188956 6333 195.159.176.226 (5 Sep 2018 23:09:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Sep 2018 23:09:16 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (windows-nt) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 06 01:09:12 2018 Return-path: Envelope-to: ged-emacs-devel@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 1fxgv9-0001Wy-W7 for ged-emacs-devel@m.gmane.org; Thu, 06 Sep 2018 01:09:12 +0200 Original-Received: from localhost ([::1]:58506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxgxD-0003F8-C0 for ged-emacs-devel@m.gmane.org; Wed, 05 Sep 2018 19:11:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fxgw6-00037o-VF for emacs-devel@gnu.org; Wed, 05 Sep 2018 19:10:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fxgpj-00062J-Jv for emacs-devel@gnu.org; Wed, 05 Sep 2018 19:03:39 -0400 Original-Received: from smtp105.ord1d.emailsrvr.com ([184.106.54.105]:55816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fxgpj-0005io-AY for emacs-devel@gnu.org; Wed, 05 Sep 2018 19:03:35 -0400 Original-Received: from smtp22.relay.ord1d.emailsrvr.com (localhost [127.0.0.1]) by smtp22.relay.ord1d.emailsrvr.com (SMTP Server) with ESMTP id 96F75E033A for ; Wed, 5 Sep 2018 19:03:20 -0400 (EDT) X-Auth-ID: board-president@tomahawk-creek-hoa.com Original-Received: by smtp22.relay.ord1d.emailsrvr.com (Authenticated sender: board-president-AT-tomahawk-creek-hoa.com) with ESMTPSA id 51E90E02AA for ; Wed, 5 Sep 2018 19:03:20 -0400 (EDT) X-Sender-Id: board-president@tomahawk-creek-hoa.com Original-Received: from Takver4 (76-218-37-33.lightspeed.kscymo.sbcglobal.net [76.218.37.33]) (using TLSv1.2 with cipher AES256-GCM-SHA384) by 0.0.0.0:25 (trex/5.7.12); Wed, 05 Sep 2018 19:03:20 -0400 In-Reply-To: (Lars Ingebrigtsen's message of "Mon, 03 Sep 2018 19:40:57 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 184.106.54.105 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:229317 Archived-At: Lars Ingebrigtsen writes: > Stefan Monnier writes: > >>> +if there is one match, but it's not an exact match, the function >>> +should return the match; >> >> Actualy, when there is one match, "the common substring of all matches" >> is that match, so I think we can make it simpler, e.g.: >> >> This specifies a @code{try-completion} operation. The function should >> return @code{t} if the specified string is a unique and exact match; >> It should return @code{nil} if there are no matches; and it should >> return the longest common prefix of all matches otherwise. > > Yes, that seems clearer. > >> What if the user writes the whole name by hand: how do you get the ID in >> this case? In my experience, the need to handle that "manual case" most >> of the time ends up covering just as well the case where the user >> selected an entry from the *Completions*. > > Oh, I didn't even consider that the user may type the name. Yeah, > you're right; returning the text properties wouldn't really be generally > useful here... I had a similar problem completing on names in an Ada buffer; names can be overloaded, so just the name is not unique. So I included the line number with the name in the completion table; each entry looks like: foo<1> bar<10> foo<20> The user sees those strings, and can complete on the line number to pick the instance of an overloaded name. Then the code can retrieve the line number from the completed string. If the user types the name without completing, you're out of luck (my code throws an unhelpful error). But that never happens in practice, since completion works so nicely. I use icomplete-mode, with completion options set so I have to type C-j to get out of a completing read with non-matching text. This code is in a development version of ada-mode; available via email on request. For IMDB, you could use | to separate fields, and complete on filmname|year|actor1|... Whether the user will ever or often enter text without completing depends on the use case; finding function names in source code is a much smaller problem than finding films in IMDB. -- -- Stephe