From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#42149: Substring and flex completion ignore implicit trailing =?UTF-8?Q?=E2=80=98any=E2=80=99?= Date: Wed, 01 Jul 2020 11:58:22 +0100 Message-ID: <87o8ozsdrl.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3433"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 42149@debbugs.gnu.org To: Dario Gjorgjevski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 01 12:59:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqaSP-0000n4-Ke for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jul 2020 12:59:13 +0200 Original-Received: from localhost ([::1]:47498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqaSO-0001EG-MO for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jul 2020 06:59:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqaSE-0001Dw-36 for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqaSD-00038b-R8 for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:59:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jqaSD-0003wE-Qr for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Jul 2020 10:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42149 X-GNU-PR-Package: emacs Original-Received: via spool by 42149-submit@debbugs.gnu.org id=B42149.159360111415102 (code B ref 42149); Wed, 01 Jul 2020 10:59:01 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 1 Jul 2020 10:58:34 +0000 Original-Received: from localhost ([127.0.0.1]:52366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqaRl-0003vV-U2 for submit@debbugs.gnu.org; Wed, 01 Jul 2020 06:58:34 -0400 Original-Received: from mail-wm1-f48.google.com ([209.85.128.48]:33770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqaRj-0003vE-RL for 42149@debbugs.gnu.org; Wed, 01 Jul 2020 06:58:32 -0400 Original-Received: by mail-wm1-f48.google.com with SMTP id a6so17976175wmm.0 for <42149@debbugs.gnu.org>; Wed, 01 Jul 2020 03:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=LcJ9YLp/HnhaFoVwJUPEwp1GB9VeIpLXiZA+ZjSsV4Q=; b=be5FLsR8miKl0CmsoyTXHPyQUbnvHWccf6E7HFigjgOYcgoEU/Twqro/1Pv0f4wRn5 ySlYFuYf+O8j2nccl1PlquAbsLV2PTsWYYVMpJNoBS0Gwx8DfAIpNP4boIEMSVixRfVE mXp8vSGjd6BYD+c/mJkDAoQ3xczIded8ICztbMJJnIFMtEtTSEf1Rhhz0gIcFcFOHkyf db3K9xErh5dMDpwFWrvoI7TKUq02R9KDMEeHsf6ZBQjjdqN02TXpTGf4mbo9P+hDKvy/ 6JL5hX1gaMNmLl7BWrMd3LxARpHt7oA+e4m/PVuHBB+FRxy+vtnQMnX5ECV6pDrOqmxP Udxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=LcJ9YLp/HnhaFoVwJUPEwp1GB9VeIpLXiZA+ZjSsV4Q=; b=dN6YUnHiy9Xs6vHHIVOFLVjOOf9R0EFcebb4VWbk87BjXzJ7QiRU0llRhBF26CAAJQ tA2dQ9rr40xvI6XU9zH6M3kVKx9L//HHXrS735tdKuwe/N7DkbV4BVV5syvw6Gh9m3Bu 45oRR+VsUYHPcWkz0RBIH8+EaznF/Y/sCnfHwQAS5vi/FpR7pWW15Np9AYTPkk3NArtN 4Q2GJcfCQK6DVa3l93O3pT4O6QG7YX3xdyiVUTOVlrJI6s0doCQnq683lE7Y+Zsost+Y UtWBZa2Cj01AFfHV05VGzc+AWuJla/soe3SRSlSGGsIo/eBgZkYF14zOcXH5250Uhso7 EAXg== X-Gm-Message-State: AOAM530wgrcqfGu6JFMBoBJuEtUzU4S5JzUz7/7w60HTr5Jy99hBh77I ONLJ1SnRABL7l5bGyuujQdWnf+Ta X-Google-Smtp-Source: ABdhPJxpwghdNplZA5jDXl47eNiVXOdn8Mq2lVc+4tS5iSpRe8xa1OANmRsUMh6viR7UGM4MJtK+Og== X-Received: by 2002:a1c:3c82:: with SMTP id j124mr27898881wma.155.1593601105499; Wed, 01 Jul 2020 03:58:25 -0700 (PDT) Original-Received: from krug ([89.180.158.80]) by smtp.gmail.com with ESMTPSA id r11sm6574539wmh.1.2020.07.01.03.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 03:58:24 -0700 (PDT) In-Reply-To: (Dario Gjorgjevski's message of "Wed, 01 Jul 2020 12:40:42 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182597 Archived-At: Dario Gjorgjevski writes: > Hi, > > I have found out that substring and flex completion ignore the implicit > trailing =E2=80=98any=E2=80=99 introduced by =E2=80=98completion-pcm--opt= imize-pattern=E2=80=99. This > is evident from the examples shown next. > > My Emacs version is 28.0.50, built on 2020-07-01 from commit e98ddd6fc1. > > Example 1 > =3D=3D=3D=3D=3D=3D=3D=3D=3D > > (completion-substring-all-completions "f" (list "f") nil 1) > > and > > (completion-flex-all-completions "f" (list "f") nil 1) > > both result in > > (#("f" 0 1 (face completions-common-part completion-score 0.0)) . 0) > > whereas I would expect a completion score of 1. Is it the fact that the completion-score is 0 that causes the earlier problems you experienced? > Example 2 > =3D=3D=3D=3D=3D=3D=3D=3D=3D > > (completion-substring-all-completions "fo" (list "fo") nil 1) > > results in > > (#("fo" 0 1 (face completions-common-part completion-score 0.5) 1 2 > (face (completions-first-difference completions-common-part))) . 0) > > whereas I would again expect a completion score of 1. > > Proposed Solution > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > I propose that we make the implicit trailing =E2=80=98any=E2=80=99 explic= it in > =E2=80=98completion-substring--all-completions=E2=80=99. > > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index d2c3f9045e..a598b1d1fd 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3585,10 +3585,12 @@ that is non-nil." > (pattern (if (not (stringp (car basic-pattern))) > basic-pattern > (cons 'prefix basic-pattern))) > - (pattern (completion-pcm--optimize-pattern > - (if transform-pattern-fn > - (funcall transform-pattern-fn pattern) > - pattern))) > + (pattern (append > + (completion-pcm--optimize-pattern > + (if transform-pattern-fn > + (funcall transform-pattern-fn pattern) > + pattern)) > + '(any))) ; make implicit `any' explicit > (all (completion-pcm--all-completions prefix pattern table pred= ))) > (list all pattern prefix suffix (car bounds)))) >=20=20 > > > This fixes the problem and seems to perform well from my testing. > However, I have no idea if I am overlooking something, so please let me > know. You analysis is good and it does reveal a quirk somewhere. However, for now, completion scores are relative things, i.e. they an absolute value has no meaning by its own. I can therefore understand that "t" disappears from your completion list (goes to the very end) given that something else has non-zero score, like "footrix". But does the problem also manifest itself with two-character completions? I.e. is the 0.5 perfect match for "fo" (in the example you gave) ever surpassed by another, presumably less good, match? So I'd have to look better. Either - The bug is where you say it is, and the fix should go where you say it does. - Some numeric adjust should be made to the algorithm completion-pcm--hilit-commonality.