From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Completion Date: Mon, 03 Sep 2018 18:45:10 +0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1535993011 23961 195.159.176.226 (3 Sep 2018 16:43:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 3 Sep 2018 16:43:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 03 18:43:27 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 1fwrwk-00067J-Sx for ged-emacs-devel@m.gmane.org; Mon, 03 Sep 2018 18:43:27 +0200 Original-Received: from localhost ([::1]:46108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwryr-0002Lp-1Z for ged-emacs-devel@m.gmane.org; Mon, 03 Sep 2018 12:45:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwryh-0002Li-6h for emacs-devel@gnu.org; Mon, 03 Sep 2018 12:45:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwryd-0003EV-1b for emacs-devel@gnu.org; Mon, 03 Sep 2018 12:45:27 -0400 Original-Received: from hermes.netfonds.no ([80.91.224.195]:50968) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwryc-00038c-Qr for emacs-devel@gnu.org; Mon, 03 Sep 2018 12:45:22 -0400 Original-Received: from cm-84.212.221.165.getinternet.no ([84.212.221.165] helo=stories) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fwryQ-0000z3-7j; Mon, 03 Sep 2018 18:45:12 +0200 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEVaQTotHRt1VUeniXGE Y1EjFRI9KycZDApEJ3J7AAACMklEQVQ4jVWTsa7bMAxF1QDPuwY5qyP47UXtD2gcda8GRms0RJ09 uP793kvaD6gA2xIPLylRtIsppSWOfCVOdRmdc7RFfQ06Ixjc0DnOoilOlwX+zVGfuExRg4wUEIxn ZNJIwAStufgfGNwl0vw6FPEAGsV1tW/eFLqmqYOza75Vb4rPyKH7WH632gcfDPzC85imaZ7T/Gzw 76uBO60c82SgHYp7gslGAvA1iyW/pwTfx/SYZgAfnmIg3pZk/g+CGmT3VpL7eID0mBVQwST3OJ7p p7/IIVIM3HiIhYmmec057LXafdzGmObIcPOwXkU2yQRL/LyQM1CMAJnJFdx8a61rqKsP2+YFxXJ6 C8MFBa+932EN/ro9URLnjtJWkX3fN0Eg6bGrE2D3WwEpRB7VddorALIrwJCcSzmuEneEvAa2TUrZ T0Xru8O+m9INChpU5QvwZTv6sI821IEOkL5GVFE5wLfxC4z0L4fi9aE9C6uCnSdyLw11GfkXRJR+ 0UMa6Nr7wq5Fv0PIEyIctokBYBkWgA0CXC1aUhV2rz+WxFPwzuHv2ttdDHxP48YSZwUVIM4a6mcc YN5k9UcObWor84oWKVs28Mf1/PRo2rq+fREAzvGf0MgRxNfgpaiCrOITyOCAPUnvMIcEXeJ99iFj EVje5iyC789AEPMg1WGOjjkJh14IQCbyiCY9gz2vBGtAjuqzmG/GiQFwGzigGUT7LONvld0ay3ks aVdRfr1hL8jZ/gGPwA7K9u7JaAAAAABJRU5ErkJggg== In-Reply-To: (Stefan Monnier's message of "Sat, 01 Sep 2018 11:14:59 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 80.91.224.195 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:229212 Archived-At: Stefan Monnier writes: >> Let's say the set is '("foo" "zot") and the string is "fo". Then >> there's one match, and it's unique, of course. But it's not exact? So >> should it return nil, then? > > It should return "foo". Then I guess the documentation should say so... Does the following look correct? diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index d091787a68..4cd2210e2f 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -1777,11 +1777,12 @@ Programmed Completion @item nil This specifies a @code{try-completion} operation. The function should return @code{t} if the specified string is a unique and exact match; -if there is more than one match, it should return the common substring -of all matches (if the string is an exact match for one completion -alternative but also matches other longer alternatives, the return -value is the string); if there are no matches, it should return -@code{nil}. +if there is one match, but it's not an exact match, the function +should return the match; if there is more than one match, it should +return the common substring of all matches (if the string is an exact +match for one completion alternative but also matches other longer +alternatives, the return value is the string); if there are no +matches, it should return @code{nil}. @item t This specifies an @code{all-completions} operation. The function >> 2) The entire `completing-read' machinery is based on prefix, matches >> and nothing else; is that right? > > No. The *completion tables* (i.e. the "objects" that define what > completions are available) only offer methods that work for prefixes. > But `completing-read` uses completion commands which do a lot more than > just let the completion tables do the completion for them. Hm, I see.. >> That is, if you want to do completion on words inside strings (for >> instance, if you want "foo" to have a match in a collection string >> like "zot foo bar", then there is no built-in machinery in Emacs >> for this? > > There's completion-try-completion and completion-all-completions, both > of which offer completions according to completion-styles. Ah, right, the choices from `completion-styles-alist'. I thought I had checked that, but I must have missed that bit. Thanks. >> `minibuffer-allow-text-properties' exists. Would it make sense to add a >> new variable, like `completion-allow-text-properties', to handle this >> case as well? > > We could, I guess. What's your use case? I'm completing over people and films from the IMDB database, and they're uniquely identified by IDs. I'd like to complete over the names (or perhaps also adorn the names with more... stuff, like years for the films (but not complete over that bit))), but get the IMDB IDs back after choosing a name. So I just propertize the strings before handing them over `choose-completion', and it almost works except that it strips the text properties. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no