From unknown Sat Jun 21 10:25:49 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#42149 <42149@debbugs.gnu.org> To: bug#42149 <42149@debbugs.gnu.org> Subject: Status: Substring and flex completion ignore implicit trailing =?UTF-8?Q?=E2=80=98any=E2=80=99?= Reply-To: bug#42149 <42149@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:25:49 +0000 retitle 42149 Substring and flex completion ignore implicit trailing =E2=80= =98any=E2=80=99 reassign 42149 emacs submitter 42149 Dario Gjorgjevski severity 42149 normal tag 42149 patch fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 01 06:40:52 2020 Received: (at submit) by debbugs.gnu.org; 1 Jul 2020 10:40:52 +0000 Received: from localhost ([127.0.0.1]:52339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqaAd-0003Rc-Nm for submit@debbugs.gnu.org; Wed, 01 Jul 2020 06:40:52 -0400 Received: from lists.gnu.org ([209.51.188.17]:44714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqaAb-0003RT-Iw for submit@debbugs.gnu.org; Wed, 01 Jul 2020 06:40:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqaAb-0003zg-BQ for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:40:49 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:34344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqaAZ-0000Mw-Nw for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:40:49 -0400 Received: by mail-ed1-x534.google.com with SMTP id a8so17969277edy.1 for ; Wed, 01 Jul 2020 03:40:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=sdBEkW8ufO3ye+rbEhngaOqzSA/9w68Vb9jXRNAweBw=; b=HyntS1z+IZ4S6nTbvdUVvM8yCVuquMZsRZHbnlDJWqbnEj9QIhIUT1js8ulLe6Tn+O 2RfbW3KXJjzatKFkSQ7VlQ6hsqKOqX8G6NvNSRL2Ux8MdUU8+4JbEB/xbK8cuFvRhxac UC4+a1UjilMrHe/J15DA9vgq2Icuxn7iR4UkI0Djx1ehxCROTUwQR0o5CODFVOcnvAk/ q+8S76yrwqsjjl9+Qt1yYdHRleFtsLBA2E7X551JsSG+/w2DlSzG/ynLn0xalUnV6Y5D Qt43Vtp2IquB9h/OiUiH+Hf162xHYphUmP1bUjMF+I68XD5ce9jjgVGzLj3WgcbSK2lU YzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=sdBEkW8ufO3ye+rbEhngaOqzSA/9w68Vb9jXRNAweBw=; b=HwAgA4tLcYb8ZWfRCPL0XnhhRQZZkrNhJ4JhN+oZiFCJwMI5oQWKYbrb5XHNiiDFrr 1JevHAwD03fEQ6uoj268GmtLfiDrJL/rhCAtmK2GfvPHnWxegZ2lI3UupvszZP0e5wzi dH42wYjg+b0LjoQ/DjlMjMICoR9oqeSZpijhkagEA/KqxO6v81v7BLFKtQF7vVVNl17x 846B9ZkoowaFAlf5wG2raKxZ8duHiU6SJnqmxKxcfBuM3Lc6kQLkZKZh6Hz4x0Dy4HXn 95n5w2V2zbUX+lBYG0yKzMv6PPBhkakzslPeoe7uHXT6w+IT5pO1+t1WQ5ZU3grVKxiX Tkyw== X-Gm-Message-State: AOAM5324tG/88glrfrXrRDU99SpPQJ6mDIKNmPuvooOwMVApxSilOHjX bZyxHkcou0hVLTD3vJko+JqtoDiR X-Google-Smtp-Source: ABdhPJx9jMacHveX7GAfG2yYol0OTfmZZdhjYQmEb7IXRLuBoEGEt84oG4zyIPIwm/9Br11Bi/WN/A== X-Received: by 2002:a05:6402:3049:: with SMTP id bu9mr14462357edb.232.1593600045038; Wed, 01 Jul 2020 03:40:45 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.115.99]) by smtp.gmail.com with ESMTPSA id f17sm4197954ejr.71.2020.07.01.03.40.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Jul 2020 03:40:44 -0700 (PDT) From: Dario Gjorgjevski To: bug-gnu-emacs@gnu.org Subject: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Date: Wed, 01 Jul 2020 12:40:42 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=dario.gjorgjevski@gmail.com; helo=mail-ed1-x534.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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--optim= ize-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. 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 explicit= in =E2=80=98completion-substring--all-completions=E2=80=99. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=completion-substring--all-completions.diff Content-Description: Make implicit trailing `any' explicit in `completion-substring--all-completions' 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)))) --=-=-= Content-Type: text/plain 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. Best regards, Dario -- dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 01 06:58:34 2020 Received: (at 42149) by debbugs.gnu.org; 1 Jul 2020 10:58:34 +0000 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 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 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) 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) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: Date: Wed, 01 Jul 2020 11:58:22 +0100 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 01 Jul 2020 12:40:42 +0200") Message-ID: <87o8ozsdrl.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 01 07:03:30 2020 Received: (at 42149) by debbugs.gnu.org; 1 Jul 2020 11:03:30 +0000 Received: from localhost ([127.0.0.1]:52377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqaWX-00045Q-R4 for submit@debbugs.gnu.org; Wed, 01 Jul 2020 07:03:30 -0400 Received: from mail-wr1-f50.google.com ([209.85.221.50]:36699) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqaWX-00045C-2p for 42149@debbugs.gnu.org; Wed, 01 Jul 2020 07:03:29 -0400 Received: by mail-wr1-f50.google.com with SMTP id k6so23359804wrn.3 for <42149@debbugs.gnu.org>; Wed, 01 Jul 2020 04:03:29 -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=ZN2zfyQr5gI/cr8jhIzIq6UOMYk41O6BDjDqmgILs2c=; b=oq3fcEGVtr6NycHGsu9+y9MSbwGzwQj9FOTEUMZOQwTkycbQSqJH5RD7Zx4QuZi0sI GcegYFLyNXHF0FMQdOPDVlVYMKou2W0ozSk3neHOABGcgBqctelvcE8e7QAw4rRYs8LP MHiuHDiYhv/lSny6u9diaQ+CsQMYNqMq12GLQuJAwBBa35h93NB8I6oBtiaKvuJV5/om j9AJ/b98fZmUHeocNGO9TBsp3t7Q95mpqJ7NRHKpPlmokUJ9UWetnk5CFZOaxVao4I+3 9PKguIktWklEZShHO53k35zIL0JQRoTXZvqxsFNQ2xbMjwRMvb399bYZiuBC+RZP+sTT Tf9Q== 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=ZN2zfyQr5gI/cr8jhIzIq6UOMYk41O6BDjDqmgILs2c=; b=kPLPnQQIV0lrE1rgvH5QNerVPlXZPRSTwup1MW+CupGRRku8KCazHavxXK7rcOQVok 0nRZ55mmUt9LlDJ46jOyJIDzsbOYIT3Nq/AsvENU6fQRQ7NoMGkSgSyyjayC+AqQfFbA ZAOpDcKcdBxC91TZBqNKSGJP2KlLb38bexyBhnamJg14loQZj1qqbT7f41bsQDw4gUCO V29Rl/qsglW3a8JmEmyJWLFs8aNDImBbMRTk51dtEvGd6pcckSf2M7J18p/rjdl2fp9Y 3c89G89UZkAurEIRff+09lMhDMJnC326J85gLY3fyGOSK2oAjgtW2UsTkmrx8Pq/c80M IUCA== X-Gm-Message-State: AOAM533672tVy1liBaC/o+NcD6aaYp7x2nd550fTz1NnQ5aSV4otGQOy OoHZvvZALLJlzubKWw3DfPrntx/f X-Google-Smtp-Source: ABdhPJysSB30FPGfd/375WR7T0eKL9GHhJ7iGgO4svhVdOnMPtxBPrsBj8r+x51KKsM+nCbP3JY+MA== X-Received: by 2002:adf:9148:: with SMTP id j66mr24091058wrj.311.1593601402995; Wed, 01 Jul 2020 04:03:22 -0700 (PDT) Received: from krug ([89.180.158.80]) by smtp.gmail.com with ESMTPSA id c5sm6659587wmb.24.2020.07.01.04.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 04:03:22 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: Date: Wed, 01 Jul 2020 12:03:20 +0100 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 01 Jul 2020 12:40:42 +0200") Message-ID: <87k0znsdjb.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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--o= ptimize-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. > > > > 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) > > > 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? Answering my own question, the answer seems to be "no". (completion-substring-all-completions "fo" (list "f" "fo" "foot") nil 1) (#("fo" 0 1 (face completions-common-part completion-score 0.5) 1 2 (face (completions-first-difference completions-common-part))) #("foot" 0 1 (face completions-common-part completion-score 0.25) 1 2 (face (completions-first-difference completions-common-part))) . 0) But indeed there is the problem of the 1-long. And the problem is that _every_ completion gets 0. (completion-substring-all-completions "f" (list "f" "fo" "foot") nil 1) (#("f" 0 1 (face completions-common-part completion-score 0.0)) #("fo" 0 1 (face completions-common-part completion-score 0.0) 1 2 (face completions-first-difference)) #("foot" 0 1 (face completions-common-part completion-score 0.0) 1 2 (face completions-first-difference)) . 0) I still don't know what the proper fix this, just adding some information I think is relevant. Thanks, Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 01 07:10:55 2020 Received: (at 42149) by debbugs.gnu.org; 1 Jul 2020 11:10:55 +0000 Received: from localhost ([127.0.0.1]:52409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqadj-0004I2-66 for submit@debbugs.gnu.org; Wed, 01 Jul 2020 07:10:55 -0400 Received: from mail-ed1-f51.google.com ([209.85.208.51]:42764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqadg-0004Hl-JR for 42149@debbugs.gnu.org; Wed, 01 Jul 2020 07:10:53 -0400 Received: by mail-ed1-f51.google.com with SMTP id z17so19273902edr.9 for <42149@debbugs.gnu.org>; Wed, 01 Jul 2020 04:10:52 -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; bh=DawbKwjJIbd0oiPoB76N2VjbRgjtBs+eh64fDEzxELo=; b=kq++42H/4so68jMgAOC5I4ZUt4Y3Dmk4OMFLbSz6qEtC6SuiDqSeJABiMFBQRAkelm wxAM40YXR7iZhPOswupH3JqbiR7IEbc6v4M77LXdL5OzLude64iBxjOY9BA0faapG2Uf 5I+BwTsJ4GZrjDYxY9GH4zq+dZzhIqWEUSFNI2alyEh9mbGtdR0vdbS9uGG4Z38QD1Hc kw0yuOe91pKCU77ExSyu+LhwqrXU1hSupJUYlv4Zn2IJzGkqO+WFepFGHiDsMVL/gh2d cY21sDROf0/ggnLrvGhN5hUGsY/wO5MyOxG6cGWwjUCrSW3uK8bRVxGkN6ZUMFaiYN7R +5YA== 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; bh=DawbKwjJIbd0oiPoB76N2VjbRgjtBs+eh64fDEzxELo=; b=oMbrilI/oDqV7kdMcAp6awUIzesukeNxD+jI1p2eDSrrkRBjEsjQCv8E4/WFkG7CAS etPZ87Wx50OUoKkmpHhEgNWi3uUkS8eeg0rWJKVurEFUIrf4WbRa0yTje3qf45iVBffK NH466jqGPFfnr1VS/AkxeAVmJJiuZJhX1qbw8AFgExi/mPlIVqgdo8eiPVG7bUz2aaEW T3udGKfeaVuianhDJbqboF2DEAHFdlMsGdWBd0s2jEUc3HJdu4LknWKwXFc3Z9eI8ken HHKwy0nx83ooPLNrfE2Dh3r8EmKbRtTgp84HVozPm5qhXno7M/jwM0xx6xwryctM3CE3 x37w== X-Gm-Message-State: AOAM5316lCu7Wq8zwK+lFExhgyvShjDjlDm5Ph4Bf044CmfeAIyJgnZo 4ri4r1iqe/VIV2/SpnSymNgEpGKc X-Google-Smtp-Source: ABdhPJybXTrPOUXPMdDxSKApTr4AwrohIUf22B2WpPV3ePe6GDn8MEJ0rwNMvoyZ7h0jLJO/OQKrUg== X-Received: by 2002:aa7:cdca:: with SMTP id h10mr14875826edw.285.1593601846184; Wed, 01 Jul 2020 04:10:46 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.115.99]) by smtp.gmail.com with ESMTPSA id mf24sm4348059ejb.58.2020.07.01.04.10.45 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Jul 2020 04:10:45 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> Date: Wed, 01 Jul 2020 13:10:44 +0200 In-Reply-To: <87k0znsdjb.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Wed, 01 Jul 2020 12:03:20 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Jo=C3=A3o, > I still don't know what the proper fix this, just adding some > information I think is relevant. Indeed the problem is that they all get a completion score of 0, and I would expect the exact match to get a score of 1. You=E2=80=99re right that we can also modify the algorithm of =E2=80=98completion-pcm--hilit-commonality=E2=80=99. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=completion-pcm--hilit-commonality.diff Content-Description: Modify the algorithm of =?utf-8?Q?=E2=80=98completion-pcm--hilit-commonali?= =?utf-8?Q?ty=E2=80=99?= diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index d2c3f9045e..e1f1ffed1c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3251,6 +3251,9 @@ one-letter-long matches).") (update-score (lambda (a b) "Update score variables given match range (A B)." + (add-face-text-property a b + 'completions-common-part + nil str) (setq score-numerator (+ score-numerator (- b a))) (unless (or (= a last-b) @@ -3264,19 +3267,10 @@ one-letter-long matches).") flex-score-match-tightness))))) (setq last-b b)))) - (funcall update-score start start) (while md - (funcall update-score start (car md)) - (add-face-text-property - start (pop md) - 'completions-common-part - nil str) + (funcall update-score start (pop md)) (setq start (pop md))) - (funcall update-score len len) - (add-face-text-property - start end - 'completions-common-part - nil str) + (funcall update-score start end) (if (> (length str) pos) (add-face-text-property pos (1+ pos) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This modification also solves the issue (and simplifies the code a little bit), but I=E2=80=99m not sure of unwanted side effects. Best regards, Dario --=20 dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 25 09:39:26 2020 Received: (at control) by debbugs.gnu.org; 25 Aug 2020 13:39:26 +0000 Received: from localhost ([127.0.0.1]:60799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAZAc-0007qz-7h for submit@debbugs.gnu.org; Tue, 25 Aug 2020 09:39:26 -0400 Received: from mail-yb1-f181.google.com ([209.85.219.181]:42754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAZAD-0007oE-SX for control@debbugs.gnu.org; Tue, 25 Aug 2020 09:39:02 -0400 Received: by mail-yb1-f181.google.com with SMTP id a34so7156260ybj.9 for ; Tue, 25 Aug 2020 06:39:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=o63n6F2FJ7VUVAWfKOvWE1DjLOiP9YUq1BO0mGtLGxg=; b=qM9RywcHFmqjKoUFVcl48qCprnmucLdvZka9x2rrE40EzrEzCO8/rDJD3EhfSuz2w1 3lracWXhC0ipymrd1eB8pbmOGDtpBdUfS+5+DWA/LZyU8YbXBH1MPGCzvIzdZiFjRqFh Xrd9KgquMi/KLRS85x9IYxn1GIXMDhtA/5WE/0YZ2YSaAIkqGeDOKsPILdjKKUtUsqdl 6xSg/79g6qvSVas1ecWkpjgLx8cMnJS8u5ZGdUy7BrdvhgJOZ1CBurvuprTzkX5xrq45 sWkpr0OyhwUXEELnALGlgGhAyhzn9RgORXV+Kq32PiljNn34n/Ha6wLfDJOmpNchexXZ lMtg== X-Gm-Message-State: AOAM531RuLwflQgDn7NNl1MPjoMVP2KqjLDll6JLrOPBUALwbi2mN4bP OFVoX+5MxUJGZ26B8YPHIeODr5JM3ML5DOAsdy+cvdOm X-Google-Smtp-Source: ABdhPJzTHDjdKix0ExGC5y0oMHrxjg+PhQPE9m+9Bu9P7RAX2B+AJUgxXfYotR92jM3ID5+RA4p+rt74ycIyfKuJtCI= X-Received: by 2002:a5b:410:: with SMTP id m16mr13877942ybp.309.1598362736328; Tue, 25 Aug 2020 06:38:56 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 25 Aug 2020 06:38:56 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Tue, 25 Aug 2020 06:38:56 -0700 Message-ID: Subject: To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 42149 + patch thanks Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stefankangas[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.219.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.219.181 listed in wl.mailspike.net] 2.0 BLANK_SUBJECT Subject is present but empty 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 42149 + patch thanks Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.219.181 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.219.181 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (stefankangas[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 BLANK_SUBJECT Subject is present but empty -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different tags 42149 + patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 05:05:40 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 09:05:40 +0000 Received: from localhost ([127.0.0.1]:51923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFZZM-0005D0-3y for submit@debbugs.gnu.org; Tue, 08 Sep 2020 05:05:40 -0400 Received: from mail-ej1-f48.google.com ([209.85.218.48]:45692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFZZK-0005Co-Hf for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 05:05:38 -0400 Received: by mail-ej1-f48.google.com with SMTP id i26so21384699ejb.12 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 02:05:38 -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=WvewSlWhJmVm6oK9QAodTxpzz09K+hNh65qLu+minqc=; b=tP5hrjYX9H9DJFTqLZvdrawYbj4TFS8UzTiwNkDUZztj3iwXgzd2FVLpPOlWwT6Ihh +Fx0ggK2EQ32hOqIN0WWaZSy9QTXYJ3kbtrMX2ZNaAKM0NtVYh17OBO/RC0wzpZKDbJf 7Eme+gMFdBeyxhxnllPrWouA75thkXNVjB36VYjFAMVsaaWA1HTwRobUeUF2+xG394fM szI4eQ9LkAcvAk+O2/nYPW5vjSx0LPeQ2miFXRiBaewHOAPHtnfiXCJu2zR6ZX9V8Q2/ QkSXB2wp/1WPW5copEjDoXqsTS39BO34/v+nzZXp/9NXBKS/8pjQKJx86hwkZ6LDb5cT ShoQ== 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=WvewSlWhJmVm6oK9QAodTxpzz09K+hNh65qLu+minqc=; b=UMLQ8IXuLrfy0sZ/FFE304k5D5TBPhMLB2YiDWHv5epoSBKU0AiRnCRx2GnYJ8hXC7 f2KCmnarWTC8hzV4Jspwr8bSQ7qmLIatoPvZX+1qt0oC+w5LMJo3WuF9jgrj8uxwx7OD VbfBZatKZ2S9Py7v3mQ01njZbyK4WuTpNPkUmZpn9MxE5lzVmmoTCWoL2RNb5ME1bH62 rFfURWnC5SLgxbj/eQkhmuA/mmNC3UL1oyDkuWVQBc+8FzqoO5rWzgobAZ4E3eMMe7CS Z/cjXb9s1zU5IYXTR4ix19HJIqEdaHmZGscgcHMd6eAMUqbW/BSSevbNwsMTu/MUNwbu ldJA== X-Gm-Message-State: AOAM530c1DDNVg06xhJCIXoGAyfWxdVqwWVylhAbQhCpk62+g33SSBiv PQ4bilvuykYeu6+o6q8LFD0mWRBMdvUNAA== X-Google-Smtp-Source: ABdhPJyH8P+CLaXy4hic6FxzQSHKZrkQBTd9gZEmeTu+zmk9D7/uBZNRmq27sBEHGaqhudYnbFiYKQ== X-Received: by 2002:a17:907:72c5:: with SMTP id du5mr25836595ejc.469.1599555932423; Tue, 08 Sep 2020 02:05:32 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id dh3sm17231406edb.84.2020.09.08.02.05.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Sep 2020 02:05:31 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> Date: Tue, 08 Sep 2020 11:05:30 +0200 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 01 Jul 2020 13:10:44 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Jo=C3=A3o, hi everyone, Is there any progress on this? Best regards, Dario --=20 dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 05:30:29 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 09:30:29 +0000 Received: from localhost ([127.0.0.1]:51974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFZxM-0005qB-W1 for submit@debbugs.gnu.org; Tue, 08 Sep 2020 05:30:29 -0400 Received: from mail-io1-f49.google.com ([209.85.166.49]:32948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFZxL-0005pu-Ai for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 05:30:27 -0400 Received: by mail-io1-f49.google.com with SMTP id r25so5371244ioj.0 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 02:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s8DO6QfQH9Bnesww3I+uicpXD8ADekAM8JOTnK2COCk=; b=mCJQRozK6e6bx9sK+7irFUZbyLjDdDOp3BKtmKp5VU4vlh7wQtvyyJv1mi5mtit2pr ocvqdAAu3YnxCRJC1Je4IN4EfJH7qZj1JdxEydC4wdW8tKqT0PCIPBxZ0oOpi+jV3P/p TS9Y7tlz72hoROp1mwtI/Q/gMR9PSCL92pf3B+QWYtmakmtH+rqrEuLKgLJKaJFRDeRe IS6g4G+qy7DzJimRXXEYu7ByeKrNmummjWLPUnN4IvHVr9J+ABIPQLklTnsynnFg1+OU xLLRxr5L8rXk92MuoULa2uBmUnnbGvFqlCEpe74AmpRKNcDBYBSG/Nxwxbdory2eEJPi Tqbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s8DO6QfQH9Bnesww3I+uicpXD8ADekAM8JOTnK2COCk=; b=tz34PLJ/0fCMkXfOg1YZVxPqa3X42yLeNmfzUmv/EtrwGSM07u9aadP173VbtGkTQq 1+/U413Wri3JdCsR31hhhGsa3Sp9qzUqvd22wE0Lbkw1JlTorX02l+djePKJggU2OzeA 9g5KgESniyQkfzXYxF+YMXozMuNdhPKIgaNms9N2MgLiqKx1dbM9Lw1YZFdV/yVtk2mo a4Sz/bzGi7a/Qd/4sHTcDR4dup0/OaeumnSYSFZK8yvIU331aizqsIkgKekjqC2HiFRo apz/V4VYsKaqKFvUOX5MUQ3J5cRHmX8JXymRLIyDunCQqNO92eoaC9W4G2gpfyHN1PgH 139g== X-Gm-Message-State: AOAM532oaFMquN6rDsg4HFHS3lEi+5ztgfKjtqBEMGUZDxczjarvwh0K ThRf5XCMzMs6k4l7G3TBM55dQPU4R2NpETuyYVA= X-Google-Smtp-Source: ABdhPJwMWMNZHpnWIC4acBBRMqPLXSgDqX9//9o5QWimnr0ecwe9JAMl5Zxl7ShozvqL8PrzY5czlIRtbrVU0PcBvHE= X-Received: by 2002:a02:734f:: with SMTP id a15mr12602869jae.120.1599557421537; Tue, 08 Sep 2020 02:30:21 -0700 (PDT) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Tue, 8 Sep 2020 10:30:10 +0100 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: multipart/alternative; boundary="000000000000e89e6305aec9fb57" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000e89e6305aec9fb57 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Sep 8, 2020 at 10:05 AM Dario Gjorgjevski < dario.gjorgjevski@gmail.com> wrote: > Hi Jo=C3=A3o, hi everyone, > > Is there any progress on this? I don't think so. Could you (re)state the use case where this matters? That helps prioritize it. Jo=C3=A3o --000000000000e89e6305aec9fb57 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Sep 8, 2020 at 10:05 AM Dario Gjorgjevski <dario.gjorgjevski@gmail.com> wrote:=
Hi Jo=C3=A3o, h= i everyone,

Is there any progress on this?

I don&= #39;t think so. Could you (re)state the use case where this matters?
<= div>That helps prioritize it.

Jo=C3=A3o
--000000000000e89e6305aec9fb57-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 05:44:56 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 09:44:56 +0000 Received: from localhost ([127.0.0.1]:51980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFaBM-00069c-7I for submit@debbugs.gnu.org; Tue, 08 Sep 2020 05:44:56 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:41900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFaBK-00069Q-Sg for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 05:44:55 -0400 Received: by mail-ed1-f49.google.com with SMTP id ay8so15322617edb.8 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 02:44:54 -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=zSeykUOcN/wsPI6dZU9HFqbILT7cA0PZOrtY2TqyVt0=; b=qRqD3Lhdphx0ceSYAWqBC7xq7uXHAHxX4LY9Nf7QAhylm9Acy2y7UpMtKao5uoUy7Z 1WeOAKLJjbBtqRkoTuP5JHXifRAjDNvUrICfJv8f2VJZwP6MaLXJ2GQxXqCZ+gJ60hGI wPThdzK+H30NSE5Scps/OUkYQlONcDkp/bhKZuf0xjrvLv/IhJafu+Znyd2jjtkkjXNn O25+ff4vwqn6MywtdDBnLrM1v+vaZuvQY20UKHlGscVQtNZd3zPhoG83j3tQ3bLGn9V6 sZkzinOopdSwwkJUhq/1+y1JqGbCOmBflt6HTBImWBxFIQ9nGjtR3nTj6YvRLjWXXxVH jw9Q== 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=zSeykUOcN/wsPI6dZU9HFqbILT7cA0PZOrtY2TqyVt0=; b=EB6+zmXgdGBIgxf05loXjiQrXszv7hnTeMEsXDE1kBFka035paB5q1uT9XTS5dGWn0 TMvX1OkznOahBBOsLWcqYmAJgePSTwsROIAyYar6w/LSVqQ9/jOrQFmle8PFV14UQ0h/ 1WanLJ96ttOP6iLoURJJnAHocTAuBcDUfyJ4CVZwhzCaZEZYgjslpXm+BINh5EAgQHqn pgLTjtdEG4XzraukCrH6vNAWiFpsGOabiZl1EqTvcG59Gps2cDH6I1pBmx1wK5gggvEc qIIi13o3O5VwvOGXpHPZni69UMwWB5tgidUiSyUsqa2nwDRVRJll/i7O5ZyiY370WhsY 8wdQ== X-Gm-Message-State: AOAM531+JBBbHMbv1C/W1JbdJBcFoROcve6pOnyPIDBI4UKFzpdgYwCY aO7LI6FRG6NabMCri7mUdq3zl/qYz9v37Q== X-Google-Smtp-Source: ABdhPJyqABu59JtDzKREtbyWme4SO4xIpzJsAwABQe92Vl282Dghvm6WSvcg9AXqkHEC72B1AWwCPQ== X-Received: by 2002:a05:6402:2c3:: with SMTP id b3mr26302154edx.213.1599558288697; Tue, 08 Sep 2020 02:44:48 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id 35sm1277646edg.71.2020.09.08.02.44.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Sep 2020 02:44:48 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> Date: Tue, 08 Sep 2020 11:44:47 +0200 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Tue, 8 Sep 2020 10:30:10 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > I don't think so. Could you (re)state the use case where this matters? > That helps prioritize it. Hi Jo=C3=A3o, My use case is very simple: I have a directory which, among others, contains files named 1, 2, etc. It=E2=80=99s really annoying that C-x C-f = 2 RET does not find 2 but instead finds some other file containing 2 in its name. Also, I can=E2=80=99t start an R process by doing M-x R RET. (You need to = have R and ESS installed for this, of course.) Best regards, Dario --=20 dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 06:08:49 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 10:08:49 +0000 Received: from localhost ([127.0.0.1]:52062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFaYT-0000Wy-1J for submit@debbugs.gnu.org; Tue, 08 Sep 2020 06:08:49 -0400 Received: from mail-il1-f171.google.com ([209.85.166.171]:39042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFaYR-0000Wi-3I for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 06:08:47 -0400 Received: by mail-il1-f171.google.com with SMTP id u20so5977750ilk.6 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 03:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V6dr4S3ILyv3GSsWWupwxV/yFiXt96Pt4aFuam7HwR4=; b=Z1PxjHeCp126YRbitbLNlEhEXXkfxkos2FkS44HxUxLiy+aIV5SZ/zoW/qyE/1rW8d e9Q540ocKlxvPAU6bHL3q9OJhECHX4bG2IIBR/ud7fMChRlbn9C2pr5cbWIZDFhXwf8C dCYbU1S3d29fnfJs4R6OMXastCzDSOq856vzyl6Rx2wp27BKxbk6ope+nnlsPRqg1HOO Tl4zKHpBQHTh23Fo5s4M2lFhIynkKibm7tBx7335swMcXnZs6WuVy5sQ2LrM4a0lsxMI lUHoVM0buD4yeUx7K341GaF8ezbV3Hn/3p5UYZ1knk6xFjYHaPIQAaPoeqm07M3BuNB2 0XKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V6dr4S3ILyv3GSsWWupwxV/yFiXt96Pt4aFuam7HwR4=; b=XQ4A0Ra61/yiEbcafpmZnwUQE7h+EVp6UpbuLTZmd79fmtqP2ch0vELHUFMekI10Dy L7JVdd0gekUbjgJqDKWc8z+zeQMjyL+4HCG/m8AQ6G/AX0w9KH/PAM8vtLlPQVWGSyRG asawbKtBala1HPyHfO8ml9CEqFuG7+k/lKdumoNZ8vUDvYLvLyGYTYLJyxOxP3kEdCmp hUwGew6Ed1hSp5HBgCi50AvEJWthb3b+T3alEqL87ocNG+PGc4UkthWmhwZ6wK+cwt7B w27Nlt2S5a/L08GB4HhLiiMiUam2uyZTFiIJ48g8sESDLQfSBbS2RoZMfGxGXZiGSS93 jxRw== X-Gm-Message-State: AOAM532PvTYbR/rzwT/5Mw4VC2axylWIWPX+cDY4R9rGSf0PD286/Qan NEwLSPYlcdtfdXEbPlWw1wbfIw7YNeENhZZFGfs= X-Google-Smtp-Source: ABdhPJyQBB4efdCdl5oyWSfekfNeSZ5Wp5uJuju2KStdZisJK3opaV6TYmMvkLw8eETHVrpaBaaXQRjaV/R5va5VRk0= X-Received: by 2002:a92:d482:: with SMTP id p2mr23189961ilg.9.1599559721442; Tue, 08 Sep 2020 03:08:41 -0700 (PDT) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Tue, 8 Sep 2020 11:08:26 +0100 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: multipart/alternative; boundary="000000000000fe64c905aeca84ec" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000fe64c905aeca84ec Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Sep 8, 2020 at 10:44 AM Dario Gjorgjevski < dario.gjorgjevski@gmail.com> wrote: > > I don't think so. Could you (re)state the use case where this matters? > > That helps prioritize it. > > Hi Jo=C3=A3o, > > My use case is very simple: I have a directory which, among others, > contains files named 1, 2, etc. It=E2=80=99s really annoying that C-x C-= f 2 RET > does not find 2 but instead finds some other file containing 2 in its > name. > Is this is vanilla emacs, or are you using some icomplete-mode or fido-mode? I.e. can you post the entire Emacs -Q recipe? > Also, I can=E2=80=99t start an R process by doing M-x R RET. (You need t= o have > R and ESS installed for this, of course.) Same question. If you're using, say, fido-mode, you can probably fix this by typing M-j instead of RET in these one-letter completion cases. Or even C-u M-j, if that doesn't work. Jo=C3=A3o --000000000000fe64c905aeca84ec Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Sep 8, 2020 at 10:44 AM Dario Gjorgjevski <dario.gjorgjevski@gmail.com&g= t; wrote:
> I= don't think so. Could you (re)state the use case where this matters? > That helps prioritize it.

Hi Jo=C3=A3o,

My use case is very simple: I have a directory which, among others,
contains files named 1, 2, etc.=C2=A0 It=E2=80=99s really annoying that C-x= C-f 2 RET
does not find 2 but instead finds some other file containing 2 in its
name.

Is this is vanilla emacs, or are = you using some icomplete-mode or fido-mode?
I.e. can you pos= t the entire Emacs -Q recipe?
=C2=A0
Also, I can=E2=80=99t start an R process by doing M-x R RET.=C2=A0 (You nee= d to have
R and ESS installed for this, of course.)

=
Same question. If you're using, say, fido-mode, you can probably f= ix this by typing
M-j instead of RET in these one-letter completi= on cases. Or even C-u M-j, if that
doesn't work.

Jo=C3=A3o
--000000000000fe64c905aeca84ec-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 07:13:02 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 11:13:02 +0000 Received: from localhost ([127.0.0.1]:52192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbYb-0004SU-Vu for submit@debbugs.gnu.org; Tue, 08 Sep 2020 07:13:02 -0400 Received: from mail-ed1-f44.google.com ([209.85.208.44]:44136) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbYZ-0004Ry-MP for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 07:13:00 -0400 Received: by mail-ed1-f44.google.com with SMTP id b12so15535685edz.11 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 04:12:59 -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; bh=rOC7/44urFxnQ5dYxErtty4/ikoCcFFXFbVTf3h6INU=; b=Ee97H74vQ5/1JojubKvQX1fC4PhQIGernx4cT2XuJIMBO37hT0Jj9rf0+t0a8zI2MV g8Id8H+jEOdlmD7a64U9XUUU0zIVn2aD9q65ZnXCqUFTykw2CwWMLv43g7Yaf5egqHDf on9mcaYbmEAs53RRF+b2toqeqTrGWZLkgf/MoFT6Ftg4Od8OsBLyVyX0j6Bj2EBHftzD jCgvNbI6HnCdS4b8KHopH9nlNsS1lwNEE+6nhdPfCdAnhvwAAQb2EiBufBcCN2OlCP/G HcEloZBLu4/TxdYqvvxlMgCe0qjoMDvL0iFjWjpmN8Jx4f/0jQxnTgLS7eesgvuJzsHa q2dA== 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; bh=rOC7/44urFxnQ5dYxErtty4/ikoCcFFXFbVTf3h6INU=; b=uEZwNaQuM1hRUyrGfGqRT19zF5omSWZvt98sx6Ib1oBIi5l/XvGxcKOt4adWIc6R7u ynlRzvs0IramBNvzFNe4cDDsj9kF0ZTUKPamdgbcECOAYFIiZHC0VfKYn92NeFwijMtT N07nDOXblXiIjCjI5uvAOhv/EDS8l6BI0JF/atErTsyfyuyx0qUw/tuQt9jyD+yiux0l xKSnrXuUtRHUrGV/0744ATMiKEiKHmfyODTTeRzt1cZbz0OQxZUpnS0SA9wSjDmu0ltc vxW5qmBxCSUGCY/g3UVKA7HIk0zTxzT+BQRpj0bNzVkUngSh+Op3Fq+xkPw4FGAf2NPC UleQ== X-Gm-Message-State: AOAM5302VJCAj1EqML8VSdgAfjAtkBWX0arVyVRGDos0uoM2w4HqNpvA vwH2Gy4gKdlqplrZrOwhidbRiK0oo/BtmA== X-Google-Smtp-Source: ABdhPJz0IpGxb3buioe0uYImory+igKbyIlSvt6vIVNbaip2GP/dwRWN4rxCar99C/JJAWcPmOlzRw== X-Received: by 2002:a05:6402:48a:: with SMTP id k10mr11941917edv.22.1599563573528; Tue, 08 Sep 2020 04:12:53 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id lz22sm16914616ejb.98.2020.09.08.04.12.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Sep 2020 04:12:52 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> Date: Tue, 08 Sep 2020 13:12:51 +0200 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Tue, 8 Sep 2020 11:08:26 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Is this is vanilla emacs, or are you using some icomplete-mode or > fido-mode? > I.e. can you post the entire Emacs -Q recipe? It is really simple to reproduce. 0. Run =E2=80=98emacs -Q=E2=80=99 in a directory with two files: =E2=80=9C1= =E2=80=9D and =E2=80=9Cfoo1=E2=80=9D. 1. Enable fido-mode. 2. C-x C-f 1 RET. Emacs will open =E2=80=9Cfoo1=E2=80=9D even though I would expect it to ope= n =E2=80=9C1=E2=80=9D as that is an exact match. But, I really think this is a pointless discussion. The issue *is not caused by fido-mode* but by the mechanism of substring (and therefore, flex) completion. You can also trigger it without fido-mode by invoking minibuffer-force-complete-and-exit. (completion-flex-all-completions "1" '("1" "11" "1122") nil 1) (completion-substring-all-completions "1" '("1" "11" "1122") nil 1) Both return completely the nonsensical result of (#("1" 0 1 (face completions-common-part completion-score 0.0)) #("11" 0 1 (face completions-common-part completion-score 0.0) 1 2 (face completions-first-difference)) #("1122" 0 1 (face completions-common-part completion-score 0.0) 1 2 (face completions-first-difference)) . 0) (Why are all the completion-score values 0?) Applying the attached patch changes the result to (#("1" 0 1 (face completions-common-part completion-score 1.0)) #("11" 0 1 (face completions-common-part completion-score 0.5) 1 2 (face completions-first-difference)) #("1122" 0 1 (face completions-common-part completion-score 0.25) 1 2 (face completions-first-difference)) . 0) which I hope you would agree makes a lot more sense. > M-j instead of RET in these one-letter completion cases. Or even C-u > M-j, if that doesn't work. Sure, but my muscle memory opposes that. Best regards, Dario --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=completion-substring--all-completions.diff Content-Transfer-Encoding: quoted-printable Content-Description: Add explicit trailing =?utf-8?B?4oCYYW554oCZ?= to substring completion diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 6deb1eb077..cfcf0fdccb 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3581,6 +3581,7 @@ that is non-nil." (if transform-pattern-fn (funcall transform-pattern-fn pattern) pattern))) + (pattern (append pattern '(any))) ; explicit trailing =E2=80=98any=E2=80= =99 (all (completion-pcm--all-completions prefix pattern table pred))) (list all pattern prefix suffix (car bounds)))) =20 --=-=-= Content-Type: text/plain -- dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 07:22:51 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 11:22:51 +0000 Received: from localhost ([127.0.0.1]:52210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbi7-0006sc-DQ for submit@debbugs.gnu.org; Tue, 08 Sep 2020 07:22:51 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]:52428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbi5-0006sO-32 for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 07:22:50 -0400 Received: by mail-wm1-f50.google.com with SMTP id q9so16926139wmj.2 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 04:22:49 -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=iKj4wLNE4yJAwBuh1mqWblWJwCUO7O7krd19J2F0118=; b=CqXIknxjP70sL6yUA5VbpMUeveyBYsJAhblca/MLKgKBQTkEmLgNeFX66tkqZ137FN DXmpkgvoiLtPhcVL8xLjjAu/8DmlF6kBeFfUxsaump6VoPZK8qGwCMmoPh4GI+szsglZ gBxdnJ8lHwK4VdQQfvqfv37D4NjSyVtL8Cgp1BAifZ7KGM7/8SllehsXP55IToBALaW5 OE2ExLN6w6miOM1J9zVWomJL0ghNBI0CVhh2EzyTEiksFdPraRWxstgl6M53n6hSkEyb K/QAliJOoPo1d2NtdQbkCV4sLZO0qIrClj8IhyVUkKEvug4Rr0sSiRbzUjoOtg9Sxnuz TBsQ== 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=iKj4wLNE4yJAwBuh1mqWblWJwCUO7O7krd19J2F0118=; b=aZq8X0WzWF6ufsmZqAUgbk8hv73taupf7FbPg/krkobWio66FHtdlcAJO7CcITYs2m Xzn+AQnUjl9/AQGqHoeH3guT2zuLZVBsptgY6XBdWhzT8c4j3hvXLZbJybk+6spitzVu CpIl2UJqrp3wtxsl+QC7KKGkkjL+JLAzpcqWx2utAzRUKXbMTidN0yLHMmUx9E6U1NnI /NnZqnXVx2/rV2/iro2MDAg0j9bJaGDnvIaOQqWgooxidozMj5FcQikTqsFgbP41b34Y uFT3F6DjgjCrDVyB1lfM7Ey9ApRIxmgqJa7dnm38DsmodSBihgTh+U9qTx2FvCo+Oyll /uYA== X-Gm-Message-State: AOAM533IiUg1khmBHl8zVIobVwBB0jWCvnZR2l8UjIFtEn+d2DA7Glr0 78pv9GRRFrj+CiPWInV4dxzGEOwZjPqeEQ== X-Google-Smtp-Source: ABdhPJxrIuxbGpI9576zsb5xpiGF2TAKbigwAsIDn4UH4h5JFPf/JR3tgCMEhb3uq3zlX6fHeFFPVg== X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr3869322wmh.152.1599564162941; Tue, 08 Sep 2020 04:22:42 -0700 (PDT) Received: from krug ([89.180.149.6]) by smtp.gmail.com with ESMTPSA id l10sm31437962wru.59.2020.09.08.04.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 04:22:41 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> Date: Tue, 08 Sep 2020 12:22:39 +0100 In-Reply-To: (Dario Gjorgjevski's message of "Tue, 08 Sep 2020 13:12:51 +0200") Message-ID: <87sgbsv7gg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dario Gjorgjevski writes: >> Is this is vanilla emacs, or are you using some icomplete-mode or >> fido-mode? >> I.e. can you post the entire Emacs -Q recipe? > > It is really simple to reproduce. > > 0. Run =E2=80=98emacs -Q=E2=80=99 in a directory with two files: =E2=80= =9C1=E2=80=9D and =E2=80=9Cfoo1=E2=80=9D. > 1. Enable fido-mode. > 2. C-x C-f 1 RET. > > Emacs will open =E2=80=9Cfoo1=E2=80=9D even though I would expect it to o= pen =E2=80=9C1=E2=80=9D as that > is an exact match. But, I really think this is a pointless > discussion. It's not. Before, you hadn't mentioned fido-mode. As I told you, I need to assess the priority of this bug, in terms of whom it affects and to what intensity. > The issue *is not caused by fido-mode* but by the mechanism of substring > (and therefore, flex) completion. Obviously, I'm not disputing that in any way. >> M-j instead of RET in these one-letter completion cases. Or even C-u >> M-j, if that doesn't work. > > Sure, but my muscle memory opposes that. I'm sorry, but that's the only workaround I can think of. Bear in mind that, when using fido-mode, you need to be aware of that shortcut anyway in some situations where the text you want to input is not among the completions. C-c C-w to write a new file would likely be the most prominent example. To summarize, I believe this isn't a very common case, and it is easily circumvented with the workaround I gave you. I of course acknowledge this bug report as a bug. Maybe you can try making a patch for Emacs that fixes it and test it. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 07:30:56 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 11:30:56 +0000 Received: from localhost ([127.0.0.1]:52225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbpv-0007we-TH for submit@debbugs.gnu.org; Tue, 08 Sep 2020 07:30:56 -0400 Received: from mail-ej1-f44.google.com ([209.85.218.44]:40183) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbpu-0007po-Fe for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 07:30:54 -0400 Received: by mail-ej1-f44.google.com with SMTP id z22so21968136ejl.7 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 04:30:54 -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=FDraoWIe11QmxUDcOai5LpmiM762JQen672H/tnLk/4=; b=SbRTF+m9UOkx62GNPB4sUCYB5oXcEVcOAh9E9qrm+ZoboZrgnBI1daWwjjKCtyx89y ywagjrNx/5p751W5zfc8Le977yzMhRzt8uDxpk2dBSYjyiRZEzXjLpzG8G6Oyq/ctJN4 GPiwIci5ZEl2Z/h9QRBS2OOTkPpiD6PO/5buzcDUpWIDQISeWdqxQ55Ft5K8kWrDwHoG FLWU7GRJ36+yfAJw3gbmLpgdxXbbS5qY7mHmFif4ZtnogAmDU/ZUlovuXzgBZZ1ZrX99 lkXQlLAzQKWuRByBDWQ2GX/v3dL1KLms1BiBtdXtOuMR2k8PB8tDPj/JIWC02nelihWM L7PA== 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=FDraoWIe11QmxUDcOai5LpmiM762JQen672H/tnLk/4=; b=Id7FsM5kDMYMzW33CUmNrFZCYJ7sp3lXNcg+f2fLCOXXK47x3WFiPwM+f9pBlWnW+v EoPqPLgv7bHaUzdPqa+b1tlqqzVLnNz8+rnbUVH9p6t96U8da/maNtNdsClt6BmozXph 0KbgXVl+teSt0DHa13WZfxHakb3F5Dk9F4dgIOqBbwCo9NijJS5NOvmW6QpcooJBj42t uTxmwvQipkbcI/b+rHuzRQIof3AXMuK+2MAnFPNTT6Qwq9pVfZCBoWV4eSbojZTWUOiv 2M9eHO6VygehrecYfYVVL1W9ChPpVtMuYXzJl2e2JL0xr7BchBO4/iCJHJWQNhvQjMGO 01BQ== X-Gm-Message-State: AOAM531s8oemHcPbOi/zzOgW8d0SVqJWCQr2O0tZ+bwfAdPUzre7y+/H Jw6j9Neza36dlv8lfqLyLG9pm8kUHWMaXg== X-Google-Smtp-Source: ABdhPJx+gels/mi7AJ/PA+l6ZPaSMfR3/KF2p9hOCpS8hQTy8SmSivL6WG8OZnOjx/xee9AS1XIr9w== X-Received: by 2002:a17:906:2f02:: with SMTP id v2mr24055478eji.465.1599564648093; Tue, 08 Sep 2020 04:30:48 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id z23sm17401351eja.29.2020.09.08.04.30.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Sep 2020 04:30:47 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Tue, 08 Sep 2020 13:30:46 +0200 In-Reply-To: <87sgbsv7gg.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Tue, 08 Sep 2020 12:22:39 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > To summarize, I believe this isn't a very common case, and it is easily > circumvented with the workaround I gave you. I of course acknowledge > this bug report as a bug. Maybe you can try making a patch for Emacs > that fixes it and test it. Thanks, I=E2=80=99ll look into it some more and submit a patch. To be honest, it seems that the issue is also exhibited by completion-pcm-all-completions, so the best place to fix it would be completion-pcm--hilit-commonality. Best regards, Dario --=20 dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 08 07:32:53 2020 Received: (at 42149) by debbugs.gnu.org; 8 Sep 2020 11:32:53 +0000 Received: from localhost ([127.0.0.1]:52241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbrp-0000ry-JL for submit@debbugs.gnu.org; Tue, 08 Sep 2020 07:32:53 -0400 Received: from mail-io1-f44.google.com ([209.85.166.44]:34842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFbrm-0000rS-Rp for 42149@debbugs.gnu.org; Tue, 08 Sep 2020 07:32:52 -0400 Received: by mail-io1-f44.google.com with SMTP id r9so16703441ioa.2 for <42149@debbugs.gnu.org>; Tue, 08 Sep 2020 04:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q1S+Fkd3XhdFyr/aXOmy3fmXDU8DuMxv2Me4WkINapE=; b=Rnp/ciGrw+a3Vlrr+a+JJFPL7JtaS657ClBzlIq8qy49bpkNr4BaqqlNPZC/qgdc2K SLuAXgrNR6YqesSHKX6KjfH4RXqyCvSyflG/+f5YBsLVS1UesTyT8za2EoT8Vk5mMVRT 9sQTsLIlILz3sk2sHFSElZiJyzFc1FKA13ffj87356Z2m/7mMBQpTzw4Tu7QPXLPZOxO cC5vjlFjJS2Hm7ueWmoGeuTUXi3uFokIPPF7dQVXZ4ulVOIbzSL5KJE5Ex/4xIfljNs6 0crkcB/L2DrNKSpHR+R5UEa+xkpRCuno8v8UaBEUtwS+9fQ5jQxLiMNCZsAtk0K8TAho 1xEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q1S+Fkd3XhdFyr/aXOmy3fmXDU8DuMxv2Me4WkINapE=; b=NS7Hlk5qTXMn8MajSoQfZdHy1olUd8jHw4eur9TwwIs5hsOHnGPdd0xSxDD8yF4/1L b3momgkpaD4vx2Lc3BuVU+gmYTW65V4cD53BJx6+ZjIv6AGSHYgSQP5jco3aI71tAFzf nPE8RAK3lc/fnRydKyTIYJnQJAOvMRd6f/Basb6XxZmJrLQ6TzC1/xB/vcfOJsEDGHMK GhPZZxmu9OrK9ExTGjjPYZS1R3aSfpfAFT8uRi6h+LUjLJS4ahMDOO8ZETPg/f7bd2bv C427MggGe4ECfeCFpf3YEZivLgF1OuBTAIf/nNuMB+cXdcmQJlrlB48Uu/5hRzjfpXBV 1EIg== X-Gm-Message-State: AOAM531WnALH3aP4SDAl/i1azHvF88SxNwR6nvi26mo0+W7/2bPxrBuc /vSLLAGtiPHMkjG8i/JILHAGA9rR9+v8E4BNJ58= X-Google-Smtp-Source: ABdhPJxaUitY29WjDleU9wQyYQGy6oBU1dOCVkqYhQusem1l6jQnHY8zhuOr+1dWnwxZvXRTdCJUCetd2Ayq1GnA9zw= X-Received: by 2002:a05:6602:2f88:: with SMTP id u8mr20351175iow.175.1599564765290; Tue, 08 Sep 2020 04:32:45 -0700 (PDT) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Tue, 8 Sep 2020 12:32:31 +0100 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski , Stefan Monnier Content-Type: multipart/alternative; boundary="000000000000a164ec05aecbb13a" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000a164ec05aecbb13a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Sep 8, 2020 at 12:30 PM Dario Gjorgjevski < dario.gjorgjevski@gmail.com> wrote: > > To summarize, I believe this isn't a very common case, and it is easily > > circumvented with the workaround I gave you. I of course acknowledge > > this bug report as a bug. Maybe you can try making a patch for Emacs > > that fixes it and test it. > > Thanks, I=E2=80=99ll look into it some more and submit a patch. > > To be honest, it seems that the issue is also exhibited by > completion-pcm-all-completions, so the best place to fix it would be > completion-pcm--hilit-commonality. > Sounds good. I'm adding Stefan Monnier to this conversation as he is expert in these matters. Jo=C3=A3o --000000000000a164ec05aecbb13a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Sep 8, 2020 at 12:30 PM Dario Gjorgjevski <dario.gjorgjevski@gmail.com> wrote:=
> To summari= ze, I believe this isn't a very common case, and it is easily
> circumvented with the workaround I gave you.=C2=A0 I of course acknowl= edge
> this bug report as a bug.=C2=A0 Maybe you can try making a patch for E= macs
> that fixes it and test it.

Thanks, I=E2=80=99ll look into it some more and submit a patch.

To be honest, it seems that the issue is also exhibited by
completion-pcm-all-completions, so the best place to fix it would be
completion-pcm--hilit-commonality.
=C2=A0
Sounds good. I'm adding Stefan Monnier to this conversation
=
as he is expert in these matters.

Jo=C3=A3o
--000000000000a164ec05aecbb13a-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 06:17:45 2020 Received: (at 42149) by debbugs.gnu.org; 9 Sep 2020 10:17:45 +0000 Received: from localhost ([127.0.0.1]:57283 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFxAf-0006KU-3v for submit@debbugs.gnu.org; Wed, 09 Sep 2020 06:17:45 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:37162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFxAd-0006KG-FC for 42149@debbugs.gnu.org; Wed, 09 Sep 2020 06:17:44 -0400 Received: by mail-ed1-f45.google.com with SMTP id n22so2085264edt.4 for <42149@debbugs.gnu.org>; Wed, 09 Sep 2020 03:17:43 -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; bh=oI4gUcmTxMV/SEiBa3dyQ9CELWW9mckdQCqUuTZbBNg=; b=dK7273OUBrDf41+NuwMd2aYb/aV4xs8+O7ta9kHVOYqbiR5TchYKYZ13ozT49LKPs8 72Rwd5/E7wEH/mb4QjO7iieBQosl1kBF2g0kmY8uPAX+o6/o1OhCvmQGl1+JY1b7SY3Q J0UCnoYP9OKlNQQCx+K/cl++B3iiahIz/p69g34TnoCidlmaW4nsnwvM0rb3BbJ2Knnd 2WepYweOyab8mzwQ7P45ko/A4sdKM0xvhjHxzEvXB1osyc+EEbvhJriGqGjWWs0tgV+Y wGEPZFnJ8NuIZZhSAg1AciNlNIkAX8Fh9CqYC53jUJ/fr9LbNMBZ7U2iVcLyOZTuDDxD HKEw== 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; bh=oI4gUcmTxMV/SEiBa3dyQ9CELWW9mckdQCqUuTZbBNg=; b=U1q4H2Jo0GYMESREeC4Kx6lnOa7r+kvWRa8nBQi+GlkcfoRLhlDmySy2WAxi4P6QQB 0JEGQNTha9Ui1lacfIwidKnCj126TgVllgd8KMkuvWU3KW3KvsBzRj042E56psiI4IPd pVLMaqy6z1rnpv8uunHyePVE0gJUd+63mnK6zHVfLLZ7tE8B2HG0bV2Go7rVNkcb77yh rAk3VYSSJWiKEENNVpDIhnKZRhyGHBAMLv8bEJWoaMknnwzUu2VVCYJ2Idpje4sJYKL+ bDg/dDK/o6BnFOTJU/8tKPAhbWHCTf9SI/vYgSW4LLXr8DxyRSI9RPytbnhQngKdgw0Q FnUQ== X-Gm-Message-State: AOAM531AlZIIKIHx4oioqVN5gRyfkcwiy+yMxPlGTeVOyl+B2CAt/ip1 NRv97JqUzF4eGQEKzJZZ9QlL/4DYAo83Rg== X-Google-Smtp-Source: ABdhPJwSLB7oLEWVFBn1uXRDu7EEjlmOPJqnYdo7LRj1fWBl9+ojONxS3ubDe5jD1caj/p5IatwQKg== X-Received: by 2002:a05:6402:1710:: with SMTP id y16mr3467085edu.197.1599646657362; Wed, 09 Sep 2020 03:17:37 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id v6sm1676533edj.59.2020.09.09.03.17.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Sep 2020 03:17:36 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Wed, 09 Sep 2020 12:17:34 +0200 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Tue, 8 Sep 2020 12:32:31 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Jo=C3=A3o, hi Stefan, Please find attached a patch that fixes this issue and optimizes the scoring in PCM completion a bit. As far as I can tell, this works fine and can be merged, but please have a look and do some testing yourself. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Fix-and-optimize-scoring-in-PCM-completion.patch Content-Transfer-Encoding: quoted-printable Content-Description: Fix (and optimize) scoring in PCM completion >From 8699e72f92524da8041f63949cf29858caded4a5 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Wed, 9 Sep 2020 12:10:52 +0200 Subject: [PATCH] Fix (and optimize) scoring in PCM completion MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/minibuffer.el (completion-pcm--hilit-commonality): Fix scoring to also include the last part of the query string. This was especially evident for single-character query strings, e.g., =E2=80=98(completion-flex-all-completions "1" '("1" "foo1") nil 1)=E2=80=99= would match both "1" and "foo1" with a completion-score of 0. This adjustment makes the completion-score of "1" be 1 and of "foo1" by 0.25. See also bug#42149. Furthermore, some optimizations are done. --- lisp/minibuffer.el | 78 ++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 62a33f3e2d..7fa132f3c5 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3191,17 +3191,20 @@ one-letter-long matches).") (when completions (let* ((re (completion-pcm--pattern->regex pattern 'group)) (point-idx (completion-pcm--pattern-point-idx pattern)) - (case-fold-search completion-ignore-case)) + (case-fold-search completion-ignore-case) + (score-numerator (float (apply #'+ (mapcar (lambda (part) + (if (stringp part) + (length part) + 0)) + pattern))))) (mapcar (lambda (str) - ;; Don't modify the string itself. + ;; Don't modify the string itself. (setq str (copy-sequence str)) (unless (string-match re str) (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) (md (match-data)) - (start (pop md)) - (end (pop md)) (len (length str)) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" @@ -3237,47 +3240,40 @@ one-letter-long matches).") ;; (SUM_across_i(hole_i_contrib) + 1) * len ;; ;; , where "len" is the string's length. - (score-numerator 0) - (score-denominator 0) - (last-b 0) - (update-score - (lambda (a b) - "Update score variables given match range (A B)." - (setq - score-numerator (+ score-numerator (- b a))) - (unless (or (=3D a last-b) - (zerop last-b) - (=3D a (length str))) - (setq - score-denominator (+ score-denominator - 1 - (expt (- a last-b 1) - (/ 1.0 - flex-score-match-tight= ness))))) - (setq - last-b b)))) - (funcall update-score start start) + (full-match-start (pop md)) + (full-match-end (pop md)) + (leading-hole-start (pop md)) + (leading-hole-end (pop md)) + (match-start leading-hole-end) + (score-denominator 0)) (while md - (funcall update-score start (car md)) - (add-face-text-property - start (pop md) - 'completions-common-part - nil str) - (setq start (pop md))) - (funcall update-score len len) + (let ((hole-start (pop md)) + (hole-end (pop md))) + (add-face-text-property + match-start hole-start + 'completions-common-part + nil str) + (unless (=3D hole-start hole-end) + (setq + score-denominator (+ score-denominator + 1 + (expt + (- hole-end hole-start 1) + (/ 1.0 flex-score-match-tightness)= )))) + (setq match-start hole-end))) (add-face-text-property - start end + match-start full-match-end 'completions-common-part nil str) - (if (> (length str) pos) - (add-face-text-property - pos (1+ pos) - 'completions-first-difference - nil str)) - (unless (zerop (length str)) - (put-text-property - 0 1 'completion-score - (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + (when (> len pos) + (add-face-text-property + pos (1+ pos) + 'completions-first-difference + nil str)) + (put-text-property + 0 1 + 'completion-score + (/ score-numerator (* len (1+ score-denominator))) str)) str) completions)))) =20 --=20 2.17.1 --=-=-= Content-Type: text/plain Best regards, Dario -- dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 07:38:14 2020 Received: (at 42149) by debbugs.gnu.org; 9 Sep 2020 11:38:14 +0000 Received: from localhost ([127.0.0.1]:57552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFyQX-0002Cb-U8 for submit@debbugs.gnu.org; Wed, 09 Sep 2020 07:38:14 -0400 Received: from mail-ed1-f42.google.com ([209.85.208.42]:45648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFyQU-0002CM-82 for 42149@debbugs.gnu.org; Wed, 09 Sep 2020 07:38:12 -0400 Received: by mail-ed1-f42.google.com with SMTP id l17so2261732edq.12 for <42149@debbugs.gnu.org>; Wed, 09 Sep 2020 04:38:10 -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=8xXXjVUiJyqSm36dRRIqUkSQ9d1QOmUTMjOxc8kd3+E=; b=mBa3MgGp2mDAdWFQRt7pB8sElJQbOw75sC1jOqG95kQxSTHS4Tw9HgCmhjf9FlP2sz jFv6oUutik8Nq56zU/CTiBOcfiNo8XoHhyASxfeexdccTr2shJ6TJSsJKZjzKJsHDqv7 07v+nzrDF5DX3aCUHnomhfwcC4vW7/TYPn6u9QTviuHovYESqyB+HLknohjEXTCxKcfR 2mA1TvSPGEk9x/eoMNDO1q6jJFOMVO8i+kYa7ffz2o0SnVnXNuXQNz/eCwvd6PtqcEAC q0+s72nTKtRZgcbMkpd5FNOQFFt5O5OVfeuzUCeV6mFRAVaJgHj8vVM5oTW9Mk9G2BB7 L/Zw== 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=8xXXjVUiJyqSm36dRRIqUkSQ9d1QOmUTMjOxc8kd3+E=; b=NHISpAjjqd3vbXp3STjii33ByAR4IawyKKza/dUbJA7OU/0W3QwUp3+oMDuCwqKX3M DXn+pqCRihyEr/hes4RUhNnuX/L3hRsdwhHPggD6vNCX3fbsTD4yoy3jMlpnQkteCvs9 Ga2Z1a5W1n8woTj0fGn4FPSdkre/w4BPo6WhxX4VZilg6YScxxSrSPg3btxRFXCM8BuM aX1N/av1NOlyVwImDP0cFWx1mFNC+Qg6Y/wBHtgg+BlH5RyhHlzCA8k9Js2tlfi+ZJJs 9hH70FTSL4pfYd70Nk5deLaBb+UhvTwV+R4Awva2rVzbQF7WGvXKvsw+MBrrxMNX7Rfc zMZQ== X-Gm-Message-State: AOAM5334Afp5Y+0eQgmLN6tJ/DxOc0UV6NI5tquFc7qxTy0jTFC+l+vF gR8HDC1qfBKOSLDbrUmdawFxaMLiTK/0mQ== X-Google-Smtp-Source: ABdhPJw9WRuYHRBvGd4gBgZ2YRsvXI8YZOST02S/iLvTBm39VJqvJ0/kfrvZDKan6WxkPnP3ATNzPw== X-Received: by 2002:a05:6402:1805:: with SMTP id g5mr3459927edy.135.1599651484077; Wed, 09 Sep 2020 04:38:04 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id j8sm1952209ejj.91.2020.09.09.04.38.03 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Sep 2020 04:38:03 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Wed, 09 Sep 2020 13:38:02 +0200 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 09 Sep 2020 12:17:34 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Jo=C3=A3o, hi Stefan, Unfortunately, I found some bugs in the patch I shared above. While it works well for substring and flex completion (with the minor caveat of ignoring the point=E2=80=99s position which I will take care of), it breaks under vanilla PCM completion. I will try to fix it. Best regards, Dario --=20 dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 09:13:41 2020 Received: (at 42149) by debbugs.gnu.org; 9 Sep 2020 13:13:41 +0000 Received: from localhost ([127.0.0.1]:57839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFzuu-0007CP-O4 for submit@debbugs.gnu.org; Wed, 09 Sep 2020 09:13:41 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:36322) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFzur-0007CC-SQ for 42149@debbugs.gnu.org; Wed, 09 Sep 2020 09:13:39 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3857F805F3; Wed, 9 Sep 2020 09:13:32 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 8BD298025A; Wed, 9 Sep 2020 09:13:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1599657210; bh=zEagamj7KMb1xGxSofv6bpKtz3pGGlp5RFG/gGa1DHs=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=OhETjldkRaSBO2yUaTvWehXi3Yu4VjPYZl1S+GWNXfOXIW2MgVO7cAy9Ok6k9oHnr 6D7Xxjs00qZ9/WzxWvso5J/Xy+JZxPdqCWsg6esSPN2t80PBMeaaBIlOvqbEe8/fpt FuqxEOPCwklX5PlkwCS3rY0q5ohQDhdLVXuIgzXJnVasC8hqrfTgtRlPIPUgU4Agfj Kes6dFpbbjDPXI5FI+GlwboHQuzzQvI1Vlm0U8C95LVT2RYHcJhTIF13bD7NLlMb8g tAJVSU9DWBIcJi7VulSCanJfepvH4l7o3T0Lz1hUwqPWjfd8hvswmGANh5jelErLoP sOOW8w0ujAzIg== Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4B1131206E3; Wed, 9 Sep 2020 09:13:30 -0400 (EDT) From: Stefan Monnier To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Wed, 09 Sep 2020 09:13:29 -0400 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 09 Sep 2020 13:38:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.067 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?windows-1252?B?Sm/jbyBU4XZvcmE=?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Unfortunately, I found some bugs in the patch I shared above. While it > works well for substring and flex completion (with the minor caveat of > ignoring the point=E2=80=99s position which I will take care of), it brea= ks > under vanilla PCM completion. I will try to fix it. BTW, this code sorely needs tests, so when you find a bug (either in the original code or in changes you introduced temporarily), if you could add corresponding tests, that would be a great help. Stefan "yes, the very one to blame for the lack of those tests" From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 10 07:26:46 2020 Received: (at 42149) by debbugs.gnu.org; 10 Sep 2020 11:26:46 +0000 Received: from localhost ([127.0.0.1]:37379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGKiz-0005r1-DZ for submit@debbugs.gnu.org; Thu, 10 Sep 2020 07:26:46 -0400 Received: from mail-ej1-f45.google.com ([209.85.218.45]:35300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGKiu-0005qk-4u for 42149@debbugs.gnu.org; Thu, 10 Sep 2020 07:26:44 -0400 Received: by mail-ej1-f45.google.com with SMTP id u21so8165100eja.2 for <42149@debbugs.gnu.org>; Thu, 10 Sep 2020 04:26:40 -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; bh=C9edxbuDvnZK9zOKiJ8Q5jVbSzN1op1xeBdWymbq0WI=; b=OJg4w8Cgw5YZ56VzIr/xF2ppk8ZwNVVqLxZfjIiasdR2JOQDmnzQmLqrL7cAdeG3b7 RbhXPIWD5RmSN3u4muAYiOzbBnklPknv3Q4ty/CeM78MBGk39gW30/0dSD3LU7G6ZzuG 8BL6+clfu++3kNLnq8I+2SIQ2CljpJVPfAVqhUqq1mtK4DwvNgrKf0Cl8MIMXHB/dHIq 7ptte0R6rekadSQEPGPfF0TrYRmcIoHd56ofrwVlhzANjb0jYfFjcUXjoiA1u29w1UnV 0lQ3kF9oss7ciOBV/DuFrdkW0yUCVrJ0Q4/EGt0UPVX3dZgRmS/eGPZxH3k1WEh77jpJ FWfQ== 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; bh=C9edxbuDvnZK9zOKiJ8Q5jVbSzN1op1xeBdWymbq0WI=; b=RuKjQIpfRKN0Fx1tSxV7Lux0Oi970M++RtvaY9V3tjL/LQ8WJZ+OeI8evWeNZAIHIb jw4XmDy6JG8xuGfH9FIVxcf/F4hWkNX+odM0nUAaIZocGqI+DSfCD/mYtUIAQqdBkCxS Js2Kdjf5D/r9XNtq4LgDr7LwILHQTzR2n+0XvKIKbw7DglI2/eGaGYl0X6vkpn7z+hTH IAQNplmvABCpm+aepa1EzK3XsF89+W8SYI8XzX+sp6X0+p5XGRUjEuFXsxjuiQKD6BWN KjyU6d9MXMMMgLEOmWHiUDXSR68+EWlU9CNqMaUOt31uWkgSW+8IWfk85mQKEpKds6NY vaKQ== X-Gm-Message-State: AOAM531Cmpc27VRbUGdSJsixB6hkehMCEmEBUbB8HHB7UHHY5iQiyHj0 kx7eLdnjWoqybGzWwkYsV12Xdih7jN9JXQ== X-Google-Smtp-Source: ABdhPJzXqAAZsDLWWSb2ihTKUZPsUq9Hf6WfCnld5wO0b5KVwZrkBUunx+t82m9Wbdh+YlPXtumpAg== X-Received: by 2002:a17:906:c830:: with SMTP id dd16mr8554866ejb.196.1599737194011; Thu, 10 Sep 2020 04:26:34 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.32]) by smtp.gmail.com with ESMTPSA id y6sm7176582edj.50.2020.09.10.04.26.32 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Sep 2020 04:26:33 -0700 (PDT) From: Dario Gjorgjevski To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Thu, 10 Sep 2020 13:26:31 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 09 Sep 2020 09:13:29 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > BTW, this code sorely needs tests, so when you find a bug (either in > the original code or in changes you introduced temporarily), if you > could add corresponding tests, that would be a great help. Hi Stefan, hi Jo=C3=A3o, Thanks a lot. I managed to iron out the bugs in a way that I=E2=80=99m hap= py with. It seems to work well with everything I tested so far, and I went ahead and added some tests. Please have a look. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Fix-and-optimize-scoring-in-PCM-completion.patch Content-Transfer-Encoding: quoted-printable Content-Description: Fix (and optimize) scoring in PCM completion >From 21ca47a2208ed7e154d1110f74f12c63bdd28262 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Wed, 9 Sep 2020 12:10:52 +0200 Subject: [PATCH] Fix (and optimize) scoring in PCM completion MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/minibuffer.el (completion-pcm--hilit-commonality): Fix scoring to also include the last part of the query string. This was especially evident for single-character query strings, e.g., =E2=80=98(completion-flex-all-completions "1" '("1" "foo1") nil 1)=E2=80=99= would match both "1" and "foo1" with a completion-score of 0. This adjustment makes the completion-score of "1" be 1 and of "foo1" by 0.25. Furthermore, fix =E2=80=98completions-first-difference=E2=80=99 and =E2=80=98completions-common-part=E2=80=99 sometimes overlapping. See also = bug#42149. Furthermore, some optimizations are done. (completion-pcm--optimize-pattern): Turn all terminating symbols, instead of only =E2=80=98point=E2=80=99, into an implicit =E2=80=98any=E2= =80=99. This removes trailing holes which affect the scoring adversely when someone is, e.g., completing =E2=80=9Cli-pac*=E2=80=9D with PCM completion. (completion-pcm--count-leading-holes): New function. (completion-pcm--match-size): New function. * test/lisp/minibuffer-tests.el (completion-pcm-all-completions-test, completion-substring-all-completions-test, completion-flex-all-completions-test): Regression tests. --- lisp/minibuffer.el | 112 +++++++++++++++++------------- test/lisp/minibuffer-tests.el | 127 ++++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 48 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 62a33f3e2d..33e0bc67a2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3104,13 +3104,15 @@ or a symbol, see `completion-pcm--merge-completions= '." (while p (pcase p (`(,(or 'any 'any-delim) point . ,rest) (setq p `(point . ,rest))) - ;; This is not just a performance improvement: it also turns - ;; a terminating `point' into an implicit `any', which - ;; affects the final position of point (because `point' gets - ;; turned into a non-greedy ".*?" regexp whereas we need - ;; it the be greedy when it's at the end, see bug#38458). - (`(,(pred symbolp)) (setq p nil)) ;Implicit terminating `any'. (_ (push (pop p) n)))) + ;; Remove terminating symbols at the end and turn them into an + ;; implicit `any'. This is not just a performance improvement: it + ;; also turns a terminating `point' into an implicit `any', which + ;; affects the final position of point (because `point' gets + ;; turned into a non-greedy ".*?" regexp whereas we need it the be + ;; greedy when it's at the end, see bug#38458). + (while (and n (symbolp (car n))) + (pop n)) (nreverse n))) =20 (defun completion-pcm--pattern->regex (pattern &optional group) @@ -3187,21 +3189,32 @@ one large \"hole\" and a clumped-together \"oo\" ma= tch) higher than the latter (which has two \"holes\" and three one-letter-long matches).") =20 +(defun completion-pcm--count-leading-holes (pattern) + "Count the number of leading holes in PATTERN." + (length (seq-take-while #'symbolp pattern))) + +(defun completion-pcm--match-size (pattern) + "Return the match size of PATTERN." + (apply #'+ + (mapcar + (lambda (part) (if (stringp part) (length part) 0)) + pattern))) + (defun completion-pcm--hilit-commonality (pattern completions) (when completions (let* ((re (completion-pcm--pattern->regex pattern 'group)) (point-idx (completion-pcm--pattern-point-idx pattern)) - (case-fold-search completion-ignore-case)) + (case-fold-search completion-ignore-case) + (num-leading-holes (completion-pcm--count-leading-holes pattern= )) + (score-numerator (float (completion-pcm--match-size pattern)))) (mapcar (lambda (str) - ;; Don't modify the string itself. + ;; Don't modify the string itself. (setq str (copy-sequence str)) (unless (string-match re str) (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) (md (match-data)) - (start (pop md)) - (end (pop md)) (len (length str)) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" @@ -3237,47 +3250,50 @@ one-letter-long matches).") ;; (SUM_across_i(hole_i_contrib) + 1) * len ;; ;; , where "len" is the string's length. - (score-numerator 0) + (full-match-start (pop md)) + (full-match-end (pop md)) + (match-start) (score-denominator 0) - (last-b 0) - (update-score - (lambda (a b) - "Update score variables given match range (A B)." - (setq - score-numerator (+ score-numerator (- b a))) - (unless (or (=3D a last-b) - (zerop last-b) - (=3D a (length str))) - (setq - score-denominator (+ score-denominator - 1 - (expt (- a last-b 1) - (/ 1.0 - flex-score-match-tight= ness))))) - (setq - last-b b)))) - (funcall update-score start start) + (hilit (lambda (match-start match-end) + (add-face-text-property + match-start match-end + 'completions-common-part + nil str) + ;; Maybe move `pos' away so we don not end up + ;; putting `completions-first-difference' over + ;; text that actually matches. + (when (and (>=3D pos match-start) (< pos match-en= d)) + (setq pos match-end))))) + ;; Make sure that leading holes are explicitly discarded. + ;; Trailing holes are taken care of by + ;; `completion-pcm--optimize-pattern'. + (if (zerop num-leading-holes) + (setq match-start full-match-start) + (dotimes (_ (1- (* 2 num-leading-holes))) + (pop md)) + (setq match-start (pop md))) (while md - (funcall update-score start (car md)) + (let ((hole-start (pop md)) + (hole-end (pop md))) + (funcall hilit match-start hole-start) + (unless (=3D hole-start hole-end) + (setq + score-denominator (+ score-denominator + 1 + (expt + (- hole-end hole-start 1) + (/ 1.0 flex-score-match-tightness)= )))) + (setq match-start hole-end))) + (funcall hilit match-start full-match-end) + (when (> len pos) (add-face-text-property - start (pop md) - 'completions-common-part - nil str) - (setq start (pop md))) - (funcall update-score len len) - (add-face-text-property - start end - 'completions-common-part - nil str) - (if (> (length str) pos) - (add-face-text-property - pos (1+ pos) - 'completions-first-difference - nil str)) - (unless (zerop (length str)) - (put-text-property - 0 1 'completion-score - (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + pos (1+ pos) + 'completions-first-difference + nil str)) + (put-text-property + 0 1 + 'completion-score + (/ score-numerator (* len (1+ score-denominator))) str)) str) completions)))) =20 diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 5da86f3614..a473fec441 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -104,5 +104,132 @@ nil (length input)) (cons output (length output))))))) =20 +(ert-deftest completion-pcm-all-completions-test () + ;; Point is at end, this does not match anything + (should (equal + (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 3) + nil)) + ;; Point is at beginning, this matches "barfoobar" + (should (equal + (car (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 0)) + "barfoobar")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; One fourth of a match and no match due to point being at the end + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "RO" '("RaOb") nil 1))) + (/ 1.0 4.0))) + (should (equal + (completion-pcm-all-completions + "RO" '("RaOb") nil 2) + nil)) + ;; Point is at beginning, but `completions-first-difference' is + ;; moved after it + (should (equal + (get-text-property + 1 'face + (car (completion-pcm-all-completions + "f" '("few" "many") nil 0))) + 'completions-first-difference)) + ;; Wildcards and delimiters work + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("list-packages") nil 7)) + "list-packages")) + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("do-not-list-packages") nil 7)) + nil))) + +(ert-deftest completion-substring-all-completions-test () + ;; One third of a match! + (should (equal + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)) + "barfoobar")) + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3))) + (/ 1.0 3.0))) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Substring match + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 4)) + "customize-group")) + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 5)) + nil)) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-substring-all-completions + "jab" '("dabjobstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 3))) + 'completions-first-difference))) + +(ert-deftest completion-flex-all-completions-test () + ;; Fuzzy match + (should (equal + (car (completion-flex-all-completions + "foo" '("hello" "world" "fabrobazo") nil 3)) + "fabrobazo")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-flex-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Another fuzzy match, but more of a "substring" one + (should (equal + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4)) + "customize-group-other-window")) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4))) + 'completions-first-difference)) + (should (equal + (get-text-property + 15 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 9))) + 'completions-first-difference))) + (provide 'completion-tests) ;;; completion-tests.el ends here --=20 2.17.1 --=-=-= Content-Type: text/plain Best regards, Dario -- dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 14 04:22:22 2020 Received: (at 42149) by debbugs.gnu.org; 14 Oct 2020 08:22:22 +0000 Received: from localhost ([127.0.0.1]:50002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kSc3B-0005iH-AQ for submit@debbugs.gnu.org; Wed, 14 Oct 2020 04:22:22 -0400 Received: from mail-ej1-f41.google.com ([209.85.218.41]:32998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kSc38-0005i3-M3 for 42149@debbugs.gnu.org; Wed, 14 Oct 2020 04:22:20 -0400 Received: by mail-ej1-f41.google.com with SMTP id c22so3640250ejx.0 for <42149@debbugs.gnu.org>; Wed, 14 Oct 2020 01:22:18 -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; bh=BHa7UoQ8hOJrbsmjFnULLSOjNf+626kcWrG0KDPHiBY=; b=gq7+Rw3M3JsmRXKNYtB/eAjz1mwHeEsST8xy+nINP0OXHo610kvoo/K9TmsTm/q2B8 UneujoXQUgY4V2A1moOwWQBWF/PitaD3iQqbSs7iMLRBc0cV0+4HHet2u0hmImzPrA1Z VJDhsBAItMgTg5ngEKZoxLPL65QvHs1kDfXWbD471gesPULnN8u/sZHBrb53uu1F+6IX ck/gWGh5u8Xyg1Zti8W0r/zX/RuAIKaoIOpkkDeL/8JxHguTkt4zRRhxEfvviUL+gemU tBNar6ElEm/sGwBJwPb197yiuZvMM3TShmd2jufeog8g75zE0Rx8PLNBPzfXAvy//TP2 e7rA== 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; bh=BHa7UoQ8hOJrbsmjFnULLSOjNf+626kcWrG0KDPHiBY=; b=CPNmI1uG3W1qilEEZQxj7eBHnNeVOSwrIFcwx3oFKklqHYjJqrHPkYdrY45mFpLQWw fVDMrdEyeyaAZUOavRHnBH3bVF8JOoMyfciEuWfdvOy4QbAbs//DV80RczTufrERVtEL Y/WMz8bzJ6eZdLwVoR4c81PsIPvwiQtbmfFtyoszq2a8oZf2hZUZo1esmoxgsk/BBZOt DbUFZNIgWWqXWsC1fPl8GFbc0oG4Dj2sOrMQL2+2KvoZ4cQoRV7dExvjE2dT23LUXHoX cyWi0xRGx8RqT7YMybxp/bPVzQd974vxG0yY58P1cZc0OnWsnsymry4ekKPvNih1kojh uP7Q== X-Gm-Message-State: AOAM531Q34oAW1yy3S99rRZL1y+j/qkGER8GxA3JqSV0WDeANQVJlgsB q1a+NZhmleGiDWAOblGtZXpuAzspohUsKg== X-Google-Smtp-Source: ABdhPJwIayxkmnL4gw+NvT/NISvNiZgOiIdW4Kmi0BeU5sz4jKWYiUAOGW9QQJPZQtMLZxjF6ivvpg== X-Received: by 2002:a17:906:f201:: with SMTP id gt1mr3858763ejb.229.1602663732330; Wed, 14 Oct 2020 01:22:12 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.120.73]) by smtp.gmail.com with ESMTPSA id p2sm1258186ejd.34.2020.10.14.01.22.10 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Oct 2020 01:22:11 -0700 (PDT) From: Dario Gjorgjevski To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Wed, 14 Oct 2020 10:22:09 +0200 In-Reply-To: (Dario Gjorgjevski's message of "Thu, 10 Sep 2020 13:26:31 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Stefan, hi Jo=C3=A3o, I rebased my patch on top of the fix introduced for bug#41705 and confirmed that it does not cause a regression. Have you been able to look into it? Please let me know if you think there=E2=80=99s something mi= ssing or if I should add additional tests. I am attaching the patch below. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Fix-and-optimize-scoring-in-PCM-completion.patch Content-Transfer-Encoding: quoted-printable Content-Description: Fix (and optimize) scoring in PCM completion >From e1d07804aeb155a5ff3b6a1c410ec757269a43d3 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Wed, 14 Oct 2020 10:06:40 +0200 Subject: [PATCH] Fix (and optimize) scoring in PCM completion MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/minibuffer.el (completion-pcm--hilit-commonality): Fix scoring to also include the last part of the query string. This was especially evident for single-character query strings, e.g., =E2=80=98(completion-flex-all-completions "1" '("1" "foo1") nil 1)=E2=80=99= would match both "1" and "foo1" with a completion-score of 0. This adjustment makes the completion-score of "1" be 1 and of "foo1" by 0.25. Furthermore, fix =E2=80=98completions-first-difference=E2=80=99 and =E2=80=98completions-common-part=E2=80=99 sometimes overlapping. See also = bug#42149. Furthermore, some optimizations are done. (completion-pcm--optimize-pattern): Turn multiple consecutive occurrences of =E2=80=98any=E2=80=99 into just a single one. (completion-pcm--count-leading-holes): New function. (completion-pcm--match-size): New function. * test/lisp/minibuffer-tests.el (completion-pcm-all-completions-test, completion-substring-all-completions-test, completion-flex-all-completions-test): Regression tests. --- lisp/minibuffer.el | 99 +++++++++++++++----------- test/lisp/minibuffer-tests.el | 127 ++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 42 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 427636e866..38bb4d0785 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3110,6 +3110,7 @@ or a symbol, see `completion-pcm--merge-completions'." (while p (pcase p (`(,(or 'any 'any-delim) point . ,rest) (setq p `(point . ,rest))) + (`(any any . ,rest) (setq p `(any . ,rest))) ;; This is not just a performance improvement: it turns a ;; terminating `point' into an implicit `any', which affects ;; the final position of point (because `point' gets turned @@ -3193,21 +3194,32 @@ one large \"hole\" and a clumped-together \"oo\" ma= tch) higher than the latter (which has two \"holes\" and three one-letter-long matches).") =20 +(defun completion-pcm--count-leading-holes (pattern) + "Count the number of leading holes in PATTERN." + (length (seq-take-while #'symbolp pattern))) + +(defun completion-pcm--match-size (pattern) + "Return the match size of PATTERN." + (apply #'+ + (mapcar + (lambda (part) (if (stringp part) (length part) 0)) + pattern))) + (defun completion-pcm--hilit-commonality (pattern completions) (when completions (let* ((re (completion-pcm--pattern->regex pattern 'group)) (point-idx (completion-pcm--pattern-point-idx pattern)) - (case-fold-search completion-ignore-case)) + (case-fold-search completion-ignore-case) + (num-leading-holes (completion-pcm--count-leading-holes pattern= )) + (score-numerator (float (completion-pcm--match-size pattern)))) (mapcar (lambda (str) - ;; Don't modify the string itself. + ;; Don't modify the string itself. (setq str (copy-sequence str)) (unless (string-match re str) (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) (md (match-data)) - (start (pop md)) - (end (pop md)) (len (length str)) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" @@ -3243,47 +3255,50 @@ one-letter-long matches).") ;; (SUM_across_i(hole_i_contrib) + 1) * len ;; ;; , where "len" is the string's length. - (score-numerator 0) + (full-match-start (pop md)) + (full-match-end (pop md)) + (match-start) (score-denominator 0) - (last-b 0) - (update-score - (lambda (a b) - "Update score variables given match range (A B)." - (setq - score-numerator (+ score-numerator (- b a))) - (unless (or (=3D a last-b) - (zerop last-b) - (=3D a (length str))) - (setq - score-denominator (+ score-denominator - 1 - (expt (- a last-b 1) - (/ 1.0 - flex-score-match-tight= ness))))) - (setq - last-b b)))) - (funcall update-score start start) + (hilit (lambda (match-start match-end) + (add-face-text-property + match-start match-end + 'completions-common-part + nil str) + ;; Maybe move `pos' away so we don not end up + ;; putting `completions-first-difference' over + ;; text that actually matches. + (when (and (>=3D pos match-start) (< pos match-en= d)) + (setq pos match-end))))) + ;; Make sure that leading holes are explicitly discarded. + ;; Trailing holes are taken care of by + ;; `completion-pcm--optimize-pattern'. + (if (zerop num-leading-holes) + (setq match-start full-match-start) + (dotimes (_ (1- (* 2 num-leading-holes))) + (pop md)) + (setq match-start (pop md))) (while md - (funcall update-score start (car md)) + (let ((hole-start (pop md)) + (hole-end (pop md))) + (funcall hilit match-start hole-start) + (unless (=3D hole-start hole-end) + (setq + score-denominator (+ score-denominator + 1 + (expt + (- hole-end hole-start 1) + (/ 1.0 flex-score-match-tightness)= )))) + (setq match-start hole-end))) + (funcall hilit match-start full-match-end) + (when (> len pos) (add-face-text-property - start (pop md) - 'completions-common-part - nil str) - (setq start (pop md))) - (funcall update-score len len) - (add-face-text-property - start end - 'completions-common-part - nil str) - (if (> (length str) pos) - (add-face-text-property - pos (1+ pos) - 'completions-first-difference - nil str)) - (unless (zerop (length str)) - (put-text-property - 0 1 'completion-score - (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + pos (1+ pos) + 'completions-first-difference + nil str)) + (put-text-property + 0 1 + 'completion-score + (/ score-numerator (* len (1+ score-denominator))) str)) str) completions)))) =20 diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 5da86f3614..a473fec441 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -104,5 +104,132 @@ nil (length input)) (cons output (length output))))))) =20 +(ert-deftest completion-pcm-all-completions-test () + ;; Point is at end, this does not match anything + (should (equal + (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 3) + nil)) + ;; Point is at beginning, this matches "barfoobar" + (should (equal + (car (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 0)) + "barfoobar")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; One fourth of a match and no match due to point being at the end + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "RO" '("RaOb") nil 1))) + (/ 1.0 4.0))) + (should (equal + (completion-pcm-all-completions + "RO" '("RaOb") nil 2) + nil)) + ;; Point is at beginning, but `completions-first-difference' is + ;; moved after it + (should (equal + (get-text-property + 1 'face + (car (completion-pcm-all-completions + "f" '("few" "many") nil 0))) + 'completions-first-difference)) + ;; Wildcards and delimiters work + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("list-packages") nil 7)) + "list-packages")) + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("do-not-list-packages") nil 7)) + nil))) + +(ert-deftest completion-substring-all-completions-test () + ;; One third of a match! + (should (equal + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)) + "barfoobar")) + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3))) + (/ 1.0 3.0))) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Substring match + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 4)) + "customize-group")) + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 5)) + nil)) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-substring-all-completions + "jab" '("dabjobstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 3))) + 'completions-first-difference))) + +(ert-deftest completion-flex-all-completions-test () + ;; Fuzzy match + (should (equal + (car (completion-flex-all-completions + "foo" '("hello" "world" "fabrobazo") nil 3)) + "fabrobazo")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-flex-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Another fuzzy match, but more of a "substring" one + (should (equal + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4)) + "customize-group-other-window")) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4))) + 'completions-first-difference)) + (should (equal + (get-text-property + 15 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 9))) + 'completions-first-difference))) + (provide 'completion-tests) ;;; completion-tests.el ends here --=20 2.17.1 --=-=-= Content-Type: text/plain Best regards, Dario -- dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 14 04:40:07 2020 Received: (at 42149) by debbugs.gnu.org; 14 Oct 2020 08:40:07 +0000 Received: from localhost ([127.0.0.1]:50017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kScKN-000693-2C for submit@debbugs.gnu.org; Wed, 14 Oct 2020 04:40:07 -0400 Received: from mail-io1-f49.google.com ([209.85.166.49]:33273) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kScKK-00068N-Oa for 42149@debbugs.gnu.org; Wed, 14 Oct 2020 04:40:05 -0400 Received: by mail-io1-f49.google.com with SMTP id r4so4149247ioh.0 for <42149@debbugs.gnu.org>; Wed, 14 Oct 2020 01:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7WL6XVTvzXvOHZ9Z2fRiWuvFwv2i3OXHuz385T5JLF8=; b=WSaCiDxo95JDj3pWnlElm1oE4LdVf94izMh9tAL68cDb3GJ2CcwV/9upRCA2q1IYVk qp1WB1s6orHBqx9wV2uyTMnez/FAoV+yQzBj/daHTpsHidJhvtKaTLnThGhxaSXQ4+UG feNlbO3rBWiXZTph+JtvfspxPXzw/cR0y1rs3xH5xqf34YwII0EN4R3h7jTMXzw2EWzu Y/10unwaWebz9Ozqkg18/SXobwJxMQAd3C+anSU21XaBMLwFCrvW/DYYfLE99xATexYC wqBjCs01A+yrshcmeV/xMzK0ROKE+S7FOmos3HMtnFoHkEvWrpzr+s2ks16+F8Q5FTTl ctcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7WL6XVTvzXvOHZ9Z2fRiWuvFwv2i3OXHuz385T5JLF8=; b=bOxeavlY27GqaMubpmY6JmzrG6j4zogdR49LmruNInq57Y2xlaxkx9/coMJkyPvTt1 imU2oD9WaSU4SwnC2ba8WONfZofMZ4v9uz4tc9XzzswIs0+sX/jaDJK1KMhdYrmCXVjJ g2YeaGK1v3db8UeiC6i5GWyUpMy6FgdSVe4GGQDabKJHIYOFHraIaGA0ms7T8Xr6OmSm eqxaCi3YZ3/ZVLxWY4xxKBsC52yjN9ATQfGw9W67qGFCQoH26tEEI/K+cjEKjcjPKCjS WpH6LojF4tdZLkxS8EwuSdpd5FuPXpGG33eyCclJY1AuAFCI46+j27rWLz7vAXZ6BENf LMOg== X-Gm-Message-State: AOAM533AxoX+HNsBdF5MkT/DeDXJnWJJDM/A5VKvrlLxtXujvtTb/Pzv qp1m5u/1bfrroBN/7eTrjmJCFVpcZ7g4D9/ncCs= X-Google-Smtp-Source: ABdhPJw7nvZjs6cxTb95jYsAOMc9B+K0fbGDubDK0Dfl8MIghTJHsyroCA8eh9sHw+Bwv97IbiK4qAw9CVH5H7R+30U= X-Received: by 2002:a05:6602:2354:: with SMTP id r20mr2081988iot.165.1602664798912; Wed, 14 Oct 2020 01:39:58 -0700 (PDT) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 14 Oct 2020 09:39:47 +0100 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: multipart/alternative; boundary="0000000000000885d905b19d7afa" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000000885d905b19d7afa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Dario, Sorry for the delay in handling this. I haven't had time to look into it in detail, which I must do since it is reasonably complex. However it looks good on the surface and from what I remember your original bug report holds water. I have two questions and a nitpick: 1. Question: if I compile and/or evaluate the changes to the test/lisp/minibuffer-tests.el file but _don't_ compile the changes to the lisp/minibuffer.el file, will they expose this bug and this bug only? In other words, will I get exactly the same failures that you describe originally in this issue and will that fact be apparent in the failure message(s)? 2. Question: are the changes to completion-pcm--optimize-pattern an optimization or does the fix above depend on them? If the former, could you make it a separate commit? 3. Nitpick: the commit message is broadly according to the format, but I find it hard to parse its intentions. Though conventions vary, I usually like to format the commit message like in this example which separates the what, the why and the how. "Fix the thing imperatively because racecar (bug#12345) Before, when the user did foo the system stupidly behaved bar. Now it's much better, it does baz. I fixed this by doing quux and quzz * file (function): use more intense quuxing." Jo=C3=A3o --0000000000000885d905b19d7afa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Dario,

S= orry for the delay in handling this.

I haven&#= 39;t had time to look into it in detail, which I must do since
it= is reasonably complex.=C2=A0 However it looks good on the surface
and from what I remember your original bug report holds water.
<= div>
I have two questions and a nitpick:

=
1. Question: if I compile and/or evaluate the changes to the
test/lisp/minibuffer-tests.el file but _don't_ compile the change= s
to the lisp/minibuffer.el file, will they expose this bug and t= his
bug only?=C2=A0 In other words, will I get exactly the s= ame failures
that you describe originally in this issue and = will that fact be
apparent in the failure message(s)?
<= div>
2. Question: are the changes to completion-pcm--optimize= -pattern
an optimization or does the fix above depend on them?=C2= =A0 If the
former, could you make it a separate commit?

3. Nitpick: the commit message is broadly according to= the
format, but I find it hard to parse its intentions. Tho= ugh
conventions vary, I usually like to format the commit me= ssage
like in this example which separates the what, the why= and
the how.

"Fix the thing im= peratively because racecar (bug#12345)

Before, whe= n the user did foo the system stupidly behaved
bar. Now it's = much better, it does baz.

I fixed this by doing qu= ux and quzz

* file (function): use more intens= e quuxing."

Jo=C3=A3o


--0000000000000885d905b19d7afa-- From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 14 05:02:01 2020 Received: (at 42149) by debbugs.gnu.org; 14 Oct 2020 09:02:01 +0000 Received: from localhost ([127.0.0.1]:50053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kScfY-0008LX-S2 for submit@debbugs.gnu.org; Wed, 14 Oct 2020 05:02:01 -0400 Received: from mail-ed1-f47.google.com ([209.85.208.47]:41048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kScfX-0008GP-3Q for 42149@debbugs.gnu.org; Wed, 14 Oct 2020 05:01:59 -0400 Received: by mail-ed1-f47.google.com with SMTP id l24so2303347edj.8 for <42149@debbugs.gnu.org>; Wed, 14 Oct 2020 02:01:59 -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=R6nlBstWMOTXQdXU4cr4D2DCxy7TUfL+lBgI0koozvo=; b=iRmEK+pTwviCQN4bVAjlk9AvVG910uWDN3japOJRaGddWBq33RE+zakO/iY+mGNjJk SJV/GOn9Mm7EcosAk7f7SIqFtHnTDWDGqfBP+k2ywSE8foMPDufsuVz4woZTpSz03+ef uf1dZqHhQDnNDRgNg1EcruUeyxVOXACvt4pbQI558SVbFL7Z1WO6j7w1hVS3jT4Mm9UW XZSN6jLXBmUg/i4rzDeI5zEFz2oaszqiEDM61KBi/9oDQ5AAPT35iUJ9j2j028lK0Yb7 8eGXOb849Kj5DqY9hlJjvpPKIgx9sEzUnKLBpFsvSKURRH56rAAKoQKnDFQ6K0rIP7eS /9lw== 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=R6nlBstWMOTXQdXU4cr4D2DCxy7TUfL+lBgI0koozvo=; b=nmaq8m/rxS79VWUg+C1euRM+Jj6nodYlCPL5I9n6vLggePf0jPMnj16mAQO+2vyrql wwFQLkGZGVBCnzV5iUW4CO6KqXI0+Rx5b1gAQx4INyrKIl3ab8eNtudupk09QV+Z1K5A rhqJHtoPySQHFGkVtLWPmwZG3MD1MTySLgky/qcXKujOp1avSU+E8tpqEtr0FTzECspk SUSetSegBDfO/uwhzvuJ4WFK9voGOH4YcTNEFcj0TWE+TXg88ojkNu2wbJBwJptXj60U dLpDK2WvLBDsM+7VntNM0jYV5t+8fjHVdsk2AXRbD8hyVQUGneHeNxDqYlT5lIu5i7UV a1Yg== X-Gm-Message-State: AOAM531xmuCm1FYlc9az8jwT7k3wbqUbqvdCPG7+MFgkmyQWXcMMYkCQ /E1/BXSU35bgqnqhJRJL7BE53sDcOnub0A== X-Google-Smtp-Source: ABdhPJwqnisNBnFHYTFDAWoA3+hY5CeCqEhteBibTcL46ktV/DFTthSSzZBA5EWnKUzL4dOrqcxYZg== X-Received: by 2002:aa7:c2ca:: with SMTP id m10mr3911491edp.255.1602666112878; Wed, 14 Oct 2020 02:01:52 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.120.73]) by smtp.gmail.com with ESMTPSA id d12sm1291379ejt.105.2020.10.14.02.01.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Oct 2020 02:01:52 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Wed, 14 Oct 2020 11:01:51 +0200 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Wed, 14 Oct 2020 09:39:47 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Jo=C3=A3o, > Sorry for the delay in handling this. No problem; it=E2=80=99s not a very critical bug after all, just an annoying one. > 1. Question: if I compile and/or evaluate the changes to the > test/lisp/minibuffer-tests.el file but _don't_ compile the changes > to the lisp/minibuffer.el file, will they expose this bug and this > bug only? In other words, will I get exactly the same failures > that you describe originally in this issue and will that fact be > apparent in the failure message(s)? Yes. As for how apparent they=E2=80=99ll be, well, I guess that=E2=80=99s = up to ERT. You will get something along the lines of (ert-test-failed ((should (eql (get-text-property 0 'completion-score (car ...)) 1.0)) :form (eql 0.0 1.0) :value nil)) Which says that the =E2=80=98completion-score=E2=80=99 was 0 but should hav= e been 1, as indicated in the bug report. Of course, some of the tests are more general tests for the sake of catching regressions. > 2. Question: are the changes to completion-pcm--optimize-pattern > an optimization or does the fix above depend on them? If the > former, could you make it a separate commit? Unfortunately, the fix loosely depends on them. Without them, having multiple consecutive =E2=80=9C*=E2=80=9D would mess up the PCM scoring. > 3. Nitpick: the commit message is broadly according to the > format, but I find it hard to parse its intentions. Though > conventions vary, I usually like to format the commit message > like in this example which separates the what, the why and > the how. Thanks for both the remark and the useful example. I will fix it and come back with a new patch. Best regards, Dario --=20 dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 15 10:25:19 2020 Received: (at 42149) by debbugs.gnu.org; 15 Oct 2020 14:25:19 +0000 Received: from localhost ([127.0.0.1]:56141 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kT4By-0007dU-Uf for submit@debbugs.gnu.org; Thu, 15 Oct 2020 10:25:19 -0400 Received: from mail-ed1-f41.google.com ([209.85.208.41]:39903) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kT4Bx-0007dD-2o for 42149@debbugs.gnu.org; Thu, 15 Oct 2020 10:25:17 -0400 Received: by mail-ed1-f41.google.com with SMTP id t21so3293461eds.6 for <42149@debbugs.gnu.org>; Thu, 15 Oct 2020 07:25:17 -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; bh=iATF0ADaNr+N1YgWVZumKdQ+jA/QmwfUIKIoA4eOYJc=; b=br+TuSD0qfacyMCkFBLZvY0NENKatyf2e3TW2+bsKOrMuquj1vScHnT2pljLOCSQeM jTIylr7V23MSKdN8CBJ1QtljrR5DukiND+lZvHmvpZK8fA8Z1KeNquIw/D9w0dbRZfep BECGa+w8p+CzcSZ8xmYg7ma1h5GCrakGEhA9a6Q4MaDVQ5sSJrM/qHzoHDrkFleq07k/ M8QVsVQ8MkLE4djII3tfP53zH05BNwrLIa5gXMOUmp2bTUqpNhpWrTK0aMuCjQASE+Bi CYJwm4bmGWdezpN3UPojp4zSL4AdWtWwmsr5e6dG2XZiXW+7uBCojrjdvTKEoXvtGUCC inGw== 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; bh=iATF0ADaNr+N1YgWVZumKdQ+jA/QmwfUIKIoA4eOYJc=; b=OMKePTVRHVb0ZmaFEb/7BVGMEJNczc97HlEvY4YK7SE51nMvJBCJhQiomgG3lV6GUN 6bXBLiR1y2ZanzryhVUE5oYw3SklI9k11XVyBibe37K+qdWrhYUXdk+2dbAJ7sJw6P3D VT9xN8nOe+7qNLTRYnMpI73ox+iXDIIbaX6TgMCEhusCicoQjLgNplprS8KbCNMv29rB 6UVO9xQIwqje1YdteMbOwdvoA4fpG7oHag7+LytEOitgpDViHBVae0+RoPQhXCuBCtsu c6qp3yYNu5fjL3nvA/ILLoI2NRnR6LVTePKKNArQNA4wEO81MYJGW/bM3T4CewGOE13k zPTA== X-Gm-Message-State: AOAM5307JVAwcrzR+JHsKBKyipaQZLdHhyyo7Eot3+l9JK+xr9XLk90s ps/NAkSQa+9bqVP32L7SLwq9ltMvA/znng== X-Google-Smtp-Source: ABdhPJyLOUrE1wrQb5a/xeYdlHgo6uxwXCNpDUkFTq4LPUL/SJir94AqwdqXHlxlln8VpWkFnvPrrg== X-Received: by 2002:aa7:d781:: with SMTP id s1mr4811949edq.102.1602771910930; Thu, 15 Oct 2020 07:25:10 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.121.18]) by smtp.gmail.com with ESMTPSA id i4sm1697949ejz.62.2020.10.15.07.25.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Oct 2020 07:25:09 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Thu, 15 Oct 2020 16:25:08 +0200 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 14 Oct 2020 11:01:51 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Jo=C3=A3o, hi Stefan, Please find attached a patch with an edited commit message. It should be better. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Fix-PCM-scoring-ignoring-last-part-of-query-string.patch Content-Transfer-Encoding: quoted-printable Content-Description: Fix PCM scoring ignoring last part of query string >From 59c4b64e830bef4258dba06e77e674f33b603918 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Wed, 14 Oct 2020 10:06:40 +0200 Subject: [PATCH] Fix PCM scoring ignoring last part of query string MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit This issue is especially evident for single-character query strings, e.g., (completion-flex-all-completions "1" '("1" "foo1") nil 1) would match both "1" and "foo1" with a completion score of 0, whereas they should have completion scores of 1 and 0.25 respectively. See also bug#42149. Furthermore, =E2=80=98completions-first-difference=E2=80=99 and =E2=80=98completions-common-part=E2=80=99 would sometimes overlap depending= on the position of point within the query string. The former is fixed by correcting the part of =E2=80=98completion-pcm--hilit-commonality=E2=80=99 responsible for looping= over the holes in the query string. The latter is fixed by explicitly moving the position of =E2=80=98completions-first-difference=E2=80=99 in case an o= verlap with =E2=80=98completions-common-part=E2=80=99 is detected. * lisp/minibuffer.el (completion-pcm--hilit-commonality): Correctly loop over the holes in the query string; detect overlaps of =E2=80=98completions-first-difference=E2=80=99 with =E2=80=98completions-co= mmon-part=E2=80=99; pre-compute the numerator. (completion-pcm--optimize-pattern): Turn multiple consecutive occurrences of =E2=80=98any=E2=80=99 into just a single one. (completion-pcm--count-leading-holes): New function. (completion-pcm--match-size): New function. * test/lisp/minibuffer-tests.el (completion-pcm-all-completions-test, completion-substring-all-completions-test, completion-flex-all-completions-test): Regression tests. --- lisp/minibuffer.el | 99 +++++++++++++++----------- test/lisp/minibuffer-tests.el | 127 ++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 42 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 427636e866..38bb4d0785 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3110,6 +3110,7 @@ or a symbol, see `completion-pcm--merge-completions'." (while p (pcase p (`(,(or 'any 'any-delim) point . ,rest) (setq p `(point . ,rest))) + (`(any any . ,rest) (setq p `(any . ,rest))) ;; This is not just a performance improvement: it turns a ;; terminating `point' into an implicit `any', which affects ;; the final position of point (because `point' gets turned @@ -3193,21 +3194,32 @@ one large \"hole\" and a clumped-together \"oo\" ma= tch) higher than the latter (which has two \"holes\" and three one-letter-long matches).") =20 +(defun completion-pcm--count-leading-holes (pattern) + "Count the number of leading holes in PATTERN." + (length (seq-take-while #'symbolp pattern))) + +(defun completion-pcm--match-size (pattern) + "Return the match size of PATTERN." + (apply #'+ + (mapcar + (lambda (part) (if (stringp part) (length part) 0)) + pattern))) + (defun completion-pcm--hilit-commonality (pattern completions) (when completions (let* ((re (completion-pcm--pattern->regex pattern 'group)) (point-idx (completion-pcm--pattern-point-idx pattern)) - (case-fold-search completion-ignore-case)) + (case-fold-search completion-ignore-case) + (num-leading-holes (completion-pcm--count-leading-holes pattern= )) + (score-numerator (float (completion-pcm--match-size pattern)))) (mapcar (lambda (str) - ;; Don't modify the string itself. + ;; Don't modify the string itself. (setq str (copy-sequence str)) (unless (string-match re str) (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) (md (match-data)) - (start (pop md)) - (end (pop md)) (len (length str)) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" @@ -3243,47 +3255,50 @@ one-letter-long matches).") ;; (SUM_across_i(hole_i_contrib) + 1) * len ;; ;; , where "len" is the string's length. - (score-numerator 0) + (full-match-start (pop md)) + (full-match-end (pop md)) + (match-start) (score-denominator 0) - (last-b 0) - (update-score - (lambda (a b) - "Update score variables given match range (A B)." - (setq - score-numerator (+ score-numerator (- b a))) - (unless (or (=3D a last-b) - (zerop last-b) - (=3D a (length str))) - (setq - score-denominator (+ score-denominator - 1 - (expt (- a last-b 1) - (/ 1.0 - flex-score-match-tight= ness))))) - (setq - last-b b)))) - (funcall update-score start start) + (hilit (lambda (match-start match-end) + (add-face-text-property + match-start match-end + 'completions-common-part + nil str) + ;; Maybe move `pos' away so we don not end up + ;; putting `completions-first-difference' over + ;; text that actually matches. + (when (and (>=3D pos match-start) (< pos match-en= d)) + (setq pos match-end))))) + ;; Make sure that leading holes are explicitly discarded. + ;; Trailing holes are taken care of by + ;; `completion-pcm--optimize-pattern'. + (if (zerop num-leading-holes) + (setq match-start full-match-start) + (dotimes (_ (1- (* 2 num-leading-holes))) + (pop md)) + (setq match-start (pop md))) (while md - (funcall update-score start (car md)) + (let ((hole-start (pop md)) + (hole-end (pop md))) + (funcall hilit match-start hole-start) + (unless (=3D hole-start hole-end) + (setq + score-denominator (+ score-denominator + 1 + (expt + (- hole-end hole-start 1) + (/ 1.0 flex-score-match-tightness)= )))) + (setq match-start hole-end))) + (funcall hilit match-start full-match-end) + (when (> len pos) (add-face-text-property - start (pop md) - 'completions-common-part - nil str) - (setq start (pop md))) - (funcall update-score len len) - (add-face-text-property - start end - 'completions-common-part - nil str) - (if (> (length str) pos) - (add-face-text-property - pos (1+ pos) - 'completions-first-difference - nil str)) - (unless (zerop (length str)) - (put-text-property - 0 1 'completion-score - (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + pos (1+ pos) + 'completions-first-difference + nil str)) + (put-text-property + 0 1 + 'completion-score + (/ score-numerator (* len (1+ score-denominator))) str)) str) completions)))) =20 diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 5da86f3614..a473fec441 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -104,5 +104,132 @@ nil (length input)) (cons output (length output))))))) =20 +(ert-deftest completion-pcm-all-completions-test () + ;; Point is at end, this does not match anything + (should (equal + (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 3) + nil)) + ;; Point is at beginning, this matches "barfoobar" + (should (equal + (car (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 0)) + "barfoobar")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; One fourth of a match and no match due to point being at the end + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "RO" '("RaOb") nil 1))) + (/ 1.0 4.0))) + (should (equal + (completion-pcm-all-completions + "RO" '("RaOb") nil 2) + nil)) + ;; Point is at beginning, but `completions-first-difference' is + ;; moved after it + (should (equal + (get-text-property + 1 'face + (car (completion-pcm-all-completions + "f" '("few" "many") nil 0))) + 'completions-first-difference)) + ;; Wildcards and delimiters work + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("list-packages") nil 7)) + "list-packages")) + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("do-not-list-packages") nil 7)) + nil))) + +(ert-deftest completion-substring-all-completions-test () + ;; One third of a match! + (should (equal + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)) + "barfoobar")) + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3))) + (/ 1.0 3.0))) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Substring match + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 4)) + "customize-group")) + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 5)) + nil)) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-substring-all-completions + "jab" '("dabjobstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 3))) + 'completions-first-difference))) + +(ert-deftest completion-flex-all-completions-test () + ;; Fuzzy match + (should (equal + (car (completion-flex-all-completions + "foo" '("hello" "world" "fabrobazo") nil 3)) + "fabrobazo")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-flex-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Another fuzzy match, but more of a "substring" one + (should (equal + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4)) + "customize-group-other-window")) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4))) + 'completions-first-difference)) + (should (equal + (get-text-property + 15 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 9))) + 'completions-first-difference))) + (provide 'completion-tests) ;;; completion-tests.el ends here --=20 2.17.1 --=-=-= Content-Type: text/plain Best regards, Dario -- dario.gjorgjevski@gmail.com :: +49 1525 8666837 % gpg --keyserver 'hkps://hkps.pool.sks-keyservers.net' \ \`> --recv-keys '744A4F0B4F1C9371' --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 20 15:39:58 2020 Received: (at 42149) by debbugs.gnu.org; 20 Nov 2020 20:39:58 +0000 Received: from localhost ([127.0.0.1]:44390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgDCH-0005sj-Ty for submit@debbugs.gnu.org; Fri, 20 Nov 2020 15:39:58 -0500 Received: from mail-pf1-f182.google.com ([209.85.210.182]:34089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgDCF-0005sS-Us for 42149@debbugs.gnu.org; Fri, 20 Nov 2020 15:39:57 -0500 Received: by mail-pf1-f182.google.com with SMTP id w6so9019160pfu.1 for <42149@debbugs.gnu.org>; Fri, 20 Nov 2020 12:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qcUwjrbqSjL/az9ETFHoQRFThaCyoOd/zFS0d2wB5Ko=; b=tjW94WPBpNfxQCbpv41Bnd5ty5O04vH3T/vMcWg9rTiO5wUJ0KP56oBHIVeV/ewauc WWetUNm3qEBEftGaxvvK1m3ap7YDKrGqLyXCwURwVNI0EymzQxZg5+z29BmoOFjPuhGn a3Tx6yWKtmRfyn4p+HGD+AD6o9t++5Xsf3NbFoEAeKnRtXkBt4pWnPYOvHqDJddWJ7fq fMLlYAulSCeziUvU+BZPnMSXdcVwhDkZusBQdHKs546Yd5cqp8KSaGV1bkoFj+1VlNXm DoQ+ExZ4/WJeT6dfoNJfmyOPvlPOz5nSU1PICVQYm3+YOak3lqwRFJbKE25mK0nJxXVv bmsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qcUwjrbqSjL/az9ETFHoQRFThaCyoOd/zFS0d2wB5Ko=; b=lWAcR3ImmUtiA+EPQbeaoSioCodVs9pq+/0oUmTdatsPihqx5MBqEQLKQ+T7CIOdup sm2zsNNZjFD1golK1TD7lY9/VJnspEv/tWTK4MWI2SAMQYr+KhilHe3/wmjjW48j8EtX p1/GCwIhBx1mwMSSc7UjA7As2nJmVoDoUn6DQvoaAYDmtNXZXd3hSEE6VGCzL2ehwPyN aQmlpARUXZ45ZWAPmJtBBZn51a3CRLe/Ya/eS4q4Dg/N2hoM9jZXbxPKr3thybOBh3dV BzA1HsXVSpyDygZ9GRKGtTSrZ7ljRUyECgi1+G93JmHKdVGoSP5x9/V+NyQoL8pzRB+J hTnw== X-Gm-Message-State: AOAM530K7/erp8zJFh9ETuV8Tg2Rh6OjAOhj6WMU/ozEdx+bk3NQ99ES XnpUGTLfxzJf3I0QkJHJUh8TtQ9C9M3QIvYo7ZM= X-Google-Smtp-Source: ABdhPJzp/OMgKoEJsT+TF/VjprHHDwir6thrIDw4jES7LJRyvsxs+vobPHGiq0aDmSnR6JwfpS/jObgOIteEIwnXsv0= X-Received: by 2002:a17:90a:4881:: with SMTP id b1mr12302267pjh.32.1605904790109; Fri, 20 Nov 2020 12:39:50 -0800 (PST) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> In-Reply-To: From: Dario Gjorgjevski Date: Fri, 20 Nov 2020 21:39:13 +0100 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Just a friendly bump. Best regards, Dario -- $ keyserver=hkps://hkps.pool.sks-keyservers.net $ keyid=744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 20 16:28:14 2020 Received: (at 42149) by debbugs.gnu.org; 20 Nov 2020 21:28:14 +0000 Received: from localhost ([127.0.0.1]:44436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgDx0-00075S-0w for submit@debbugs.gnu.org; Fri, 20 Nov 2020 16:28:14 -0500 Received: from mail-io1-f41.google.com ([209.85.166.41]:36540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgDwx-00075C-AB for 42149@debbugs.gnu.org; Fri, 20 Nov 2020 16:28:12 -0500 Received: by mail-io1-f41.google.com with SMTP id i18so11437232ioa.3 for <42149@debbugs.gnu.org>; Fri, 20 Nov 2020 13:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XsuXqExyPBVgVInwM0ladQcAB9X9mIwqR4dsyv2TyOY=; b=Iijf+VzixwIvNnrmki5IqxT39CRjkWn5n9ScuQ7pSAWK4YXCECbyh7Q2INbtxrvZ8u 6Lb7nTMMRECW/sTlp1QU3HyBj5prrVTtqRe0lr7LcItYD9CJ7AsNtIZ5CzbdKge87jlI fvoM0qYFwhWOM5ENUOZarnfgDk2RVj9ncGeYGDv2TAF95qmvzjwxaV6Cp0kqDrdrzdRf U4YLajvaOce1kXhbmifJ5wXzXxdlNgSzUA2hh/g0z8Gn/hVVDGkPJsTTXuFW2Q2eUZZt tmQ1+S5190bBe8I2O6/kRovchiYMnxpbVSplV7zIt8ziPt60JgUrhDOdoGCPnG/Z9wfT 3ubQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XsuXqExyPBVgVInwM0ladQcAB9X9mIwqR4dsyv2TyOY=; b=iDuMc4EImNqw97KF/oqT0EIkaDPpKYB0lwtVIzeT960yDKIvNAQKyFIdXyfKuBsES9 JEjOQ1fCxeDJv5p8dOG6PbQkOfkxuRy9y0qsCjrObx1IKvlPYZy35Dyl/bK4qZccL6iy Qx16cKOebs4MtIGtiyuTmE03SC1yJP4OmxeHmwWOI2k35frRBQFpgxd+OqllLyHJMxfD 6nQJZpHRkuDFAgZWFrLqZZ0ESE/ddxnkhgAfy3CsRpdJabAxDvwY4Ww9LdLyY7iL6Lwd SuLlRVpHASx/w+L19q7Sq+uQYMT2qQ8yOtVxxt74XYk0gquDrmSCZfsAlgOO4oxP8A/r gfmQ== X-Gm-Message-State: AOAM530D8wAK4BqPwAcDWUKCizyk/wBGnX8MvRp+lNFJJy+rek65k8yP 3LAMI8g//O025Jue+csifXxww5F0EvzS+2DkTOA= X-Google-Smtp-Source: ABdhPJz5Z1vEmh/8bdojManz0u1wvk9th1IYtQR8abBIkTf06RQT032qHsXdg2FttCl5tkqwwKSlyt+lF9gaS+HaH34= X-Received: by 2002:a05:6602:22c2:: with SMTP id e2mr28223176ioe.156.1605907685698; Fri, 20 Nov 2020 13:28:05 -0800 (PST) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Fri, 20 Nov 2020 21:27:54 +0000 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: multipart/alternative; boundary="00000000000025eefa05b4908542" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --00000000000025eefa05b4908542 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Indeed, sometimes a bump is needed. I'll have a good look as soon as possible. Jo=C3=A3o On Fri, Nov 20, 2020 at 8:39 PM Dario Gjorgjevski < dario.gjorgjevski@gmail.com> wrote: > Just a friendly bump. > > Best regards, > Dario > > -- > $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net > $ keyid=3D744A4F0B4F1C9371 > $ gpg --keyserver $keyserver --search-keys $keyid > --=20 Jo=C3=A3o T=C3=A1vora --00000000000025eefa05b4908542 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Indeed, sometimes a bump is needed.=C2=A0 I'll ha= ve a good look
as soon as possible.

Jo=C3=A3o

On Fri, Nov 20, 2020 at 8:39 PM Dario Gjorgjevski <<= a href=3D"mailto:dario.gjorgjevski@gmail.com">dario.gjorgjevski@gmail.com> wrote:
Ju= st a friendly bump.

Best regards,
Dario

--
$ keyserver=3Dhkps://hkps.pool.sks-keyservers.net
$ keyid=3D744A4F0B4F1C9371
$ gpg --keyserver $keyserver --search-keys $keyid


--
Jo=C3=A3o T=C3=A1vora
--00000000000025eefa05b4908542-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 24 19:02:04 2020 Received: (at 42149) by debbugs.gnu.org; 25 Nov 2020 00:02:04 +0000 Received: from localhost ([127.0.0.1]:33444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khiG4-0007GZ-6t for submit@debbugs.gnu.org; Tue, 24 Nov 2020 19:02:04 -0500 Received: from mail-io1-f48.google.com ([209.85.166.48]:34908) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khiFy-0007Fx-KR for 42149@debbugs.gnu.org; Tue, 24 Nov 2020 19:02:03 -0500 Received: by mail-io1-f48.google.com with SMTP id i9so372308ioo.2 for <42149@debbugs.gnu.org>; Tue, 24 Nov 2020 16:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sN+fRfvfRlhVilHghQVT98/cdfZ4XuEmFkP4Azz0TX0=; b=VjrZFy0bVINCMvju8wFN3v4laONlPYRjiYyLV4VcmzCzI2TStf7yW13zJprgNA06ML 3Sq4VekBhG6RcxhbYA7d2Wb0SKmleg2o2wmeyhJ0J8gf1ZzkC/kbKihR9FdU4bajkrAN 2ejahVLxjQ+x1vIOaOxitlp9/Edjsus7zefxDJ0gGwdPkCMqt/E74AY2ec4wHPRWX+Pv WrJ5l1Q4ViLDwN1xhNRMRyuKnOV7JpVDb+kbDpXCm1BucplXYwpFccaZk9xpF1lqOjT8 unOQBe3riIObsam/cjg1Y0Ogc7u7RvUQslf5ZyWhVnkS/8CBIW4qoXI8gHMWgC+o1/wW sAQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sN+fRfvfRlhVilHghQVT98/cdfZ4XuEmFkP4Azz0TX0=; b=ISNyxFi9hKfh67yhs7JZCuRQPQt/9Bjs5oBUdKrpeKv6VGq7yJWgR5zaF0eLzlPpTe 2dezK7ZoPw/LYnoVNfevo/bOjthuTVHhvQTuZUxvM06Jd40EDLFdDB2njLsVuMeVuwaW teX0eEtSX26FJFh7UQYpZqHs4ySKP7l3lxMPTwXhDZ1HJcsBuL2b77ZiGEJyT/txrTKB kZLgtUK3wBsfbi1HikCjgSW5VQCrTc5GKzvPCRsBTAYt0jAVuqkk1pwrnzPfzC09Btzt 9U6XTcNEP38ybDYGIKkiEUIYXUnsiptfL2llJa5v4MuosBQ7kupdU3EE+FMVg/slC5jn KJBQ== X-Gm-Message-State: AOAM532n1P74wpEaOI26VyLNZP+LPud8udb5iDA2P7uDFyGYBTZRuZYx /IOnlQidg/9alovrG2jYlzatpTA4qrumfmu1hS0= X-Google-Smtp-Source: ABdhPJy5Ve74DXziOhYk/swF8Fcz3lFbDB80LqMYpcfF/DxWAxCGI0hKxLaJRxKYPOCtB5IstVT8YNMkJTDJUFgMORw= X-Received: by 2002:a6b:750c:: with SMTP id l12mr642948ioh.57.1606262512864; Tue, 24 Nov 2020 16:01:52 -0800 (PST) MIME-Version: 1.0 References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 25 Nov 2020 00:01:41 +0000 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: multipart/alternative; boundary="0000000000007ecf5405b4e32269" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000007ecf5405b4e32269 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Dario, I took a better look at your patch finally, but I still don't understand it fully. Don't worry, I will soon. First thing I looked at was the tests you provided, which are very welcome. I restructured them, creating instead 13 small tests instead of just 3 tests that currently fail. Like this I can see exactly what's failing and what's not. 6 of the new tests fail, 7 pass. Tomorrow I'll look at your patch and why it (probably) fixes the 6 failures. The branch I'm doing this work in is called: scratch/bug-42149-funny-pcm-completion-scores I'm the author of one of the commits there and credit you as "Co-author". If you'd rather reverse that, let me know. Jo=C3=A3o On Fri, Nov 20, 2020 at 9:27 PM Jo=C3=A3o T=C3=A1vora wrote: > Indeed, sometimes a bump is needed. I'll have a good look > as soon as possible. > > Jo=C3=A3o > > On Fri, Nov 20, 2020 at 8:39 PM Dario Gjorgjevski < > dario.gjorgjevski@gmail.com> wrote: > >> Just a friendly bump. >> >> Best regards, >> Dario >> >> -- >> $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net >> $ keyid=3D744A4F0B4F1C9371 >> $ gpg --keyserver $keyserver --search-keys $keyid >> > > > -- > Jo=C3=A3o T=C3=A1vora > --=20 Jo=C3=A3o T=C3=A1vora --0000000000007ecf5405b4e32269 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Dario,

I took a better lo= ok at your patch finally, but I still
don't understand it ful= ly.

Don't worry, I will soon.=C2=A0 Firs= t thing I looked at
was the tests you provided, which are very we= lcome.
I restructured them, creating instead 13 small tests
<= /div>
instead of just 3 tests that currently fail.

=
Like this I can see exactly what's failing and what's
not.=C2=A0 6 of the new tests fail, 7 pass.=C2=A0

Tomorrow I'll look at your patch and why it (probably)
fixes the 6 failures.

The branch I'm doing th= is work in is called:

scratch/bug-42149-funny-pcm-= completion-scores

I'm the author of one of the= commits there and credit
you as "Co-author".=C2= =A0 If you'd rather reverse that, let
me know.

Jo=C3=A3o

On Fri, Nov 20, 2020 at 9:27 PM Jo=C3=A3= o T=C3=A1vora <joaotavora@gmail.= com> wrote:
Indeed, sometimes a bump is needed.=C2=A0 I'll= have a good look
as soon as possible.

<= div>Jo=C3=A3o

On Fri, Nov 20, 2020 at 8:39 PM Dario Gjorgjevski &l= t;dario.gj= orgjevski@gmail.com> wrote:
Just a friendly bump.

Best regards,
Dario

--
$ keyserver=3Dhkps://hkps.pool.sks-keyservers.net
$ keyid=3D744A4F0B4F1C9371
$ gpg --keyserver $keyserver --search-keys $keyid


--
Jo=C3=A3o = T=C3=A1vora


--
Jo=C3=A3o T=C3=A1vora
--0000000000007ecf5405b4e32269-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 25 03:22:52 2020 Received: (at 42149) by debbugs.gnu.org; 25 Nov 2020 08:22:52 +0000 Received: from localhost ([127.0.0.1]:34160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khq4i-0000Zi-GL for submit@debbugs.gnu.org; Wed, 25 Nov 2020 03:22:52 -0500 Received: from mail-ed1-f43.google.com ([209.85.208.43]:40391) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khq4f-0000ZR-JN for 42149@debbugs.gnu.org; Wed, 25 Nov 2020 03:22:51 -0500 Received: by mail-ed1-f43.google.com with SMTP id d18so1597574edt.7 for <42149@debbugs.gnu.org>; Wed, 25 Nov 2020 00:22:49 -0800 (PST) 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=IhsrFnLG8taAmDaH8Ut/gmn4TEuzHBMpn2MsDGW9MGI=; b=TWTbQEWtAQJpqWoVVkIzXBsGK5BPLPPOGNDk5LkTAcu8t26mGvs6ZGbe5BatVKZTV2 5GKKhY1bmhjSz8sFQiqhktWj5LnEyWSCEgjsOaGw5PcehBlzTD6R14axsstFqL3i1BM5 Nq+JrmikV1IAEKK4reFSzBopbWgsloPbHdnkxIf0ppSL13bDjLA9PIWtgExwf041PyTE C7/O42RZVbhTPe1Dq7lCPDgylLWeMW7jLP5F32IzppFaberluhZbD0zhYNkNf4AKsR2L q1hauWTiV6PFj3uyUiaE9BuhomvPMaDsElr8Vs6J2T2Yvnc5Cv0ph1Sm8UcIfm2rGk/T +dsA== 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=IhsrFnLG8taAmDaH8Ut/gmn4TEuzHBMpn2MsDGW9MGI=; b=Lk1Hhf1IDRY1uuj2wLTDr+qkwYJ/wcoxwd3bSA/cnjmxkA5gmc7A9GQyzNzPACcIz2 v+BRsNqSVdZu8zRExEKztUGv7Kn0PvyKN9VesgfNAtmdmIR5r4ri1NDoee0z7oFP0UOb YDUveA+nxhA/jRZ+eHQVP/K9eCDdoAK1geTeBiSogkySzGXMOOTY/9oyRnekHYy3ZAid WQIMHYV+SmXqkRhijiOxUJWS0ah6sjftgkbfjfTCVguVb6san6exFMZ3WsCrB2szkj3j 0loaRtd0gonUfqjrquK7SUykbVKDVhjIEMuxLbVzPa04yjVeU/dJuN4xg5E91mhxiUER KSUg== X-Gm-Message-State: AOAM532nQervxDbl+ptJ24d8+4F9KqWQEhlGXDvx/MJN5CyZ5CziOpBx ewsqu+ywSy9mrrEg5QL4nOP+bLjBjkM= X-Google-Smtp-Source: ABdhPJzNXVa8dNTukeHMTQEIZ6wGm+yGCKECzZEfXH6vCvCMYQtsXGeVNzUC8E5tz2qGIYchj22j7g== X-Received: by 2002:a05:6402:160f:: with SMTP id f15mr2404513edv.56.1606292563359; Wed, 25 Nov 2020 00:22:43 -0800 (PST) Received: from ZALANDO-31298 ([79.140.123.81]) by smtp.gmail.com with ESMTPSA id y24sm749798edt.15.2020.11.25.00.22.42 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Nov 2020 00:22:42 -0800 (PST) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> Date: Wed, 25 Nov 2020 09:22:41 +0100 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Wed, 25 Nov 2020 00:01:41 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Jo=C3=A3o, > I took a better look at your patch finally, but I still > don't understand it fully. Thanks a lot. I think the best way to see what=E2=80=99s going on is to ta= ke the =E2=80=98completion-pcm--hilit-commonality=E2=80=99 function and, ironi= cally, do some printf() debugging. In the current implementation, if you insert (message "String: %s" str) in the initial lambda and (message "Found match [%d, %d]" a b) in =E2=80=98update-score=E2=80=99 and then you try the example from the comments (completion-flex-all-completions "foo" '("fabrobazo" "fbarbazoo" "barfoobaz") nil 3) you will see it prints String: fabrobazo Found match [0, 0] [2 times] Found match [0, 1] Found match [4, 5] Found match [9, 9] String: fbarbazoo Found match [0, 0] [2 times] Found match [0, 1] Found match [7, 8] Found match [9, 9] String: barfoobaz Found match [0, 0] [2 times] Found match [3, 4] Found match [4, 5] Found match [9, 9] Notice how the last matching character is *not processed* -- this is the essence of the bug. It=E2=80=99s easiest to see from =E2=80=98barfoobaz=E2= =80=99 where only [3, 4] (the =E2=80=98f=E2=80=99) and [4, 5] (the second =E2=80=98o=E2=80=99) ar= e processed, [5, 6] is nowhere to be seen. With my patch, the output becomes String: foobarbaz Found match [0, 1] Found match [1, 2] Found match [2, 3] String: fbarbazoo Found match [0, 1] Found match [7, 8] Found match [8, 9] String: barfoobaz Found match [3, 4] Found match [4, 5] Found match [5, 6] Which is all good. > Don't worry, I will soon. First thing I looked at > was the tests you provided, which are very welcome. > I restructured them, creating instead 13 small tests > instead of just 3 tests that currently fail. Thanks a lot once again, this is very appreciated. Admittedly, the tests weren=E2=80=99t very good and I wasn=E2=80=99t sure how to make them = better. > I'm the author of one of the commits there and credit > you as "Co-author". If you'd rather reverse that, let > me know. This is fine by me. Best regards, Dario --=20 $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net $ keyid=3D744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 25 07:23:13 2020 Received: (at 42149) by debbugs.gnu.org; 25 Nov 2020 12:23:13 +0000 Received: from localhost ([127.0.0.1]:34626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khtpJ-0000Li-CY for submit@debbugs.gnu.org; Wed, 25 Nov 2020 07:23:13 -0500 Received: from mail-io1-f52.google.com ([209.85.166.52]:46627) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khtpI-0000LW-5g for 42149@debbugs.gnu.org; Wed, 25 Nov 2020 07:23:12 -0500 Received: by mail-io1-f52.google.com with SMTP id r1so1898911iob.13 for <42149@debbugs.gnu.org>; Wed, 25 Nov 2020 04:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RziVHkx+OUKrrQ6HG8z8mcXiVspTk2mc49YTf3yjvEE=; b=RWd6abhg1g8dGKqQlHl1O6a3KvNMoau1Q9A8WgWsgRogNPPWur4B4QJaTLUtlGU8ka 9kMQDDItXWZAokfHvO901VKCacOsc3BTSnlM2fb+S2ykWUv9qzan/1ra5YWFGMQCq1UK Fes4h4fPlAtmW7j78Y3SXr07PGKuNjBikhEwrgQPqwscQ30IMlmirr7RaZfhFj8R2GD+ 8zbds6k0UiVC8WolBqZrLOm1FrVVU0z3YqhZdshEqjspoR1ScOtfgi2gFwnFPmKBO56v DwUwAyG1Cqto+KwWqstIf4EFFV+b7hbf73LNLZd8NSGxPHKyVMCJ/oG5JI5j4F+qZ5Cy pmEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RziVHkx+OUKrrQ6HG8z8mcXiVspTk2mc49YTf3yjvEE=; b=cmOPu7M/ErmeL9JvpaiJ9H18vhE5vYObaHXHXwM6KYEbTKA3P/BTpD/Oc5Kpgkx0PX cLfz+Ffp3lWm0mmx8dif9rbYl+/QaVjWFL0q7xjkXjoQ6lF0GYLGOo9d2cw2iAMydm0B FPftukB1wUMKQSTR1RGVU7ebHomHI05vvYH2YoKDo031qa09xYkbRCoLhPmGn8aXnnny SYeDOHqodDDjQp39SVA6VJ//5tpW/DP7wZpRIvdbvweND/6WCym9hMR2v29BXx79bgVD KUudRkha0UhIA8ojjIX0t4X4ChGHIOwDIfOLFLZYw+Flv6gg4xYtcIMDluC2EqI+DDDA w+Og== X-Gm-Message-State: AOAM530QchP3lrYHNPj/HDAad+Jp8zjEXKNiGXYZCLdL+UiolqLPXtCC f/aSOtJm1cwCqawj+WIECXAtz+/SZSFLjPfKSi0= X-Google-Smtp-Source: ABdhPJy3wl3okc0RMHLrG2wapLdlY2hKPhdu1o6Vg1jurr/3Y+jPELVOmKiJhkrRILjCL6gEV8ZSX49Dcz+XMbJI2Z0= X-Received: by 2002:a02:29c8:: with SMTP id p191mr2940880jap.71.1606306986523; Wed, 25 Nov 2020 04:23:06 -0800 (PST) MIME-Version: 1.0 References: <87sgbsv7gg.fsf@gmail.com> In-Reply-To: From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Wed, 25 Nov 2020 12:22:55 +0000 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: multipart/alternative; boundary="0000000000005500d005b4ed7d13" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000005500d005b4ed7d13 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Nov 25, 2020 at 8:22 AM Dario Gjorgjevski < dario.gjorgjevski@gmail.com> wrote: > > Don't worry, I will soon. First thing I looked at > > was the tests you provided, which are very welcome. > > I restructured them, creating instead 13 small tests > > instead of just 3 tests that currently fail. > Thanks a lot once again, this is very appreciated. Admittedly, the > tests weren=E2=80=99t very good and I wasn=E2=80=99t sure how to make the= m better. Maybe you misunderstood me. I didn't write any new tests, I used your code and split it up into multiple ert-deftests so that I could get a better idea of which assertions are failing. The tests you wrote seem decent (but if you have even better ones, I'm OK with that too :-) ) Jo=C3=A3o --0000000000005500d005b4ed7d13 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Nov 25, 2020 at 8:22 AM Dario Gjorgjevski <dario.gjorgjevski@gmail.com&= gt; wrote:

> > Don't worry, I will soon.=C2=A0 First thing= I looked at
> > was the tests you provided, which are very welcom= e.
> > I restructured them, creating instead 13 small tests
>= ; > instead of just 3 tests that currently fail.
> Thanks a lot on= ce again, this is very appreciated.=C2=A0 Admittedly, the
> test= s weren=E2=80=99t very good and I wasn=E2=80=99t sure how to make them bett= er.

Maybe you misunderstood me. I didn't write= any new tests, I used
your code and split it up into multiple er= t-deftests so that I could get
a better idea of which assertions = are failing.=C2=A0 The tests you wrote
seem decent (but if you ha= ve even better ones, I'm OK with that
too :-) )

Jo=C3=A3o
--0000000000005500d005b4ed7d13-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 25 08:28:05 2020 Received: (at 42149) by debbugs.gnu.org; 25 Nov 2020 13:28:05 +0000 Received: from localhost ([127.0.0.1]:34700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khuq5-00042k-8L for submit@debbugs.gnu.org; Wed, 25 Nov 2020 08:28:05 -0500 Received: from mail-ed1-f52.google.com ([209.85.208.52]:41065) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khupz-000429-QO for 42149@debbugs.gnu.org; Wed, 25 Nov 2020 08:28:04 -0500 Received: by mail-ed1-f52.google.com with SMTP id t9so2518351edq.8 for <42149@debbugs.gnu.org>; Wed, 25 Nov 2020 05:27:59 -0800 (PST) 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; bh=v6KPHM6RUlrJsg1TbOEN4EKC+hq3gFsmzTZXpYxzn0A=; b=O6HKSsY8jDngljxMapaJ4NEbhKBUtyDY+G8EJB+A0BAAnEs78xlHTfhvHjndLCCWqG sciAZErlRsVJauMq3xLeVbAw+T0dAwR8YglweerdP8ktN81uvh9QU6sGbUQnbaHKAqKL p+ri/PN+5p6UHV0flUcjCa6GSTpKMpCBX6ex+XUKjEjnsP9sp5jbpVU/+n2tC87X0OGo jztjWQ28V4uMGgT483T0UFJRUKXE8fNNyy4nk18PwXkbQfx6qsd9sXYtun8q6xChEiP+ Rh1GrLPzSP6Y0EBRV6YMhRCcW+FjAfzgcP+OFY6ZeY6pZkzIaoQkGOoZmr+Fskn2tp3c C9uQ== 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; bh=v6KPHM6RUlrJsg1TbOEN4EKC+hq3gFsmzTZXpYxzn0A=; b=r0heslztspyEdiaOhLkmLhFnMyCzs/9zW8XXC6EEZLr4qpd+Iv0NAcfCk94CAHvdDG 54v3ha1+z1auX/QWVHFzr+V3sLM5f7Qm8eUkLy9HB/vmD8sQ45g2CCUuZ5tUmsyrereP oSM3K7EO/eBN0PlMwZwl61V5dZgvpi0jfMrQeFZuyfarA0LhNBoU3eQ9vwk8/a6C4uCy x9EYMFRqbABdm1V/VfVkjyg4GIzFmnyQGGp0f4i3gRDS5QhCT8ftSnM/2pq4WvK/bztE rmLQ8XU6fGV+N1RjCAGtxrOYO1Ul0W85vMYtNg6WI7WbSRf461ksUaXroFVYHZMdUx/3 nquQ== X-Gm-Message-State: AOAM530uckNT3jn8C+RFTIhfmhbs7bP3+Va2CkT23+F7bDjgiCs9RaLM RHfuknHFuM3hRCswsZk4d15efx+4l3s= X-Google-Smtp-Source: ABdhPJyRMJKDszgs5xr6pxVJ9iov1UaYQYH854hD+zWsTfKhA+HvTk9GCpmYB9JTiYQrhqpKoOWpHA== X-Received: by 2002:aa7:c4c2:: with SMTP id p2mr3513033edr.371.1606310873461; Wed, 25 Nov 2020 05:27:53 -0800 (PST) Received: from ZALANDO-31298 ([79.140.123.81]) by smtp.gmail.com with ESMTPSA id n14sm1280512edw.38.2020.11.25.05.27.52 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Nov 2020 05:27:52 -0800 (PST) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> Date: Wed, 25 Nov 2020 14:27:51 +0100 In-Reply-To: (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vora=22's?= message of "Wed, 25 Nov 2020 12:22:55 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Maybe you misunderstood me. I didn't write any new tests, I used > your code and split it up into multiple ert-deftests so that I could get > a better idea of which assertions are failing. The tests you wrote > seem decent (but if you have even better ones, I'm OK with that > too :-) ) What I meant was bad about the tests I had written is precisely what you fixed -- the way they were structured. So, all is good. Best regards, Dario -- $ keyserver=hkps://hkps.pool.sks-keyservers.net $ keyid=744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 23 04:41:54 2020 Received: (at 42149) by debbugs.gnu.org; 23 Dec 2020 09:41:54 +0000 Received: from localhost ([127.0.0.1]:51969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ks0eX-0006TX-Rj for submit@debbugs.gnu.org; Wed, 23 Dec 2020 04:41:54 -0500 Received: from mail-wm1-f47.google.com ([209.85.128.47]:40364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ks0eT-0006Sn-Hx for 42149@debbugs.gnu.org; Wed, 23 Dec 2020 04:41:52 -0500 Received: by mail-wm1-f47.google.com with SMTP id r4so5530463wmh.5 for <42149@debbugs.gnu.org>; Wed, 23 Dec 2020 01:41:49 -0800 (PST) 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; bh=s+XUZU1dAyNu7HP4NhJrVFcevxPZCcnRWmnu6RtmXiY=; b=eeK1QMfFiQKJ2Dtfl+IuGFyXGBvrEzp8rx6KORjiGPn3VYIf7B1sx9onBJFWpoSZ6j hiuElyQ1fzjFnp6x7KoUx1iWXyd641dIDx86R8AMWlGG8agaVT+sZufkziVe6f3nkqR7 XmVYFy++isMjkpQBQzUAaHVnrQvbiTwRGKXG4MH+8LQpG5qXo/BjiNvs5boOwFdJNgt9 K31e0MpTcavCstjcaqYpsQ5eWcEScMqVxMFIcO0Ctzsq9jtb6qh2ONIBKxcVQg7naG9E qx3bJ69/bak4GDn8ci2PMEXo27GKw3Oc3mOKELdL1GG2yQCPh9NX5hcdAXpMKQFYue8S A2mw== 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; bh=s+XUZU1dAyNu7HP4NhJrVFcevxPZCcnRWmnu6RtmXiY=; b=BV3tVbsQ/rRiana043m58C9e1Hhhjpy/kShVltpEW8jVtVJFVBUIUYB9PWAynHIvVf GBsZTnxW1yYCCFXDWuqqd/sX81+kbO3C4P5jx9H30Q03mwJc/MhviFa4XIMMgZK8+zUU 2/xFY/SeJXekj4TKFOxX3Q+gSMLF+MNGjeMBO+4qs2zdlfz3nYU+znl8R35Ekfy8A7aT kDEAH/LI9TY2vCXz4cNoSSQQZ9NRGiyPw/rZksuVqlvl38EsFnuUpSTRXYvZqEpiKzgK BhkRzT44bLXYko2X84cCPUyRA+kMxg14ovfkuqj3C7TGntZjy2AjLq7fj+/wJ0OFGJ9O +9MA== X-Gm-Message-State: AOAM5322rEVFRGyxVb3TZLUBgxgNm/iEJ7Cxmt8DlckVoSKNAdx+xirn sxv1XfKNUO/DuYj0IKHNkEPqJG1A6q0= X-Google-Smtp-Source: ABdhPJw+bNQMUZv09wJUp+Ve/RT+B2D8sVQ7DuSVKMWICgon1UNaGYBtqu5ESPv7hYLSWAPvqSj4oQ== X-Received: by 2002:a7b:cb4f:: with SMTP id v15mr25644637wmj.123.1608716503321; Wed, 23 Dec 2020 01:41:43 -0800 (PST) Received: from ZALANDO-31298 (p200300e977215071246000c1866e550b.dip0.t-ipconnect.de. [2003:e9:7721:5071:2460:c1:866e:550b]) by smtp.gmail.com with ESMTPSA id u6sm36255142wrm.90.2020.12.23.01.41.42 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Dec 2020 01:41:42 -0800 (PST) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> Date: Wed, 23 Dec 2020 10:41:42 +0100 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 25 Nov 2020 14:27:51 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Has anyone had the time to look into this? Best regards, Dario -- $ keyserver=hkps://hkps.pool.sks-keyservers.net $ keyid=744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 27 15:08:17 2020 Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 20:08:17 +0000 Received: from localhost ([127.0.0.1]:33609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcKu-0004bQ-VY for submit@debbugs.gnu.org; Sun, 27 Dec 2020 15:08:17 -0500 Received: from mail-wr1-f43.google.com ([209.85.221.43]:46097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcKs-0004bC-1l for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 15:08:15 -0500 Received: by mail-wr1-f43.google.com with SMTP id d13so8789193wrc.13 for <42149@debbugs.gnu.org>; Sun, 27 Dec 2020 12:08:14 -0800 (PST) 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; bh=kuXDCwlHxICb9cVqSsci+N7jumVvN5yTexi6heah2hU=; b=g5vIA8FzW0bFoDlbT5LmCaXu/BwMXXq6akjz2D9DP/m/VHFcwckcstvfCZNWVKAk7H YeBdeEHvZ9JFna8942ehFbgsZjLBYwikpnhWmUo5GIPTLBQ2G+QBY+ijjPzEggJR48wu Y6pCpMFtf5oiEpJ8lcFUvu9/9stf8SCo5Gu2JBm/K7kxw4LD0vbqCyIclJB5aDig7pXT v/YwqAKBYKhjgugT2c49nYwbrhOgyxPPmStazQQDoxINMTDHHUKT40FxM9JVZM1kE8Fg E30S1oFH1eGprOoJFONR57D0GxjaLOuoUvkkg8zc+ZC5nWQjAKAlIct8tfrtbizBg5Ke OO1w== 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; bh=kuXDCwlHxICb9cVqSsci+N7jumVvN5yTexi6heah2hU=; b=DG0y0wqzYr47qGjN5NxKGjLvnnIP8L8/2uXLOwQXFLorxzFKgLohK0Xb9n2XkoibC/ AkdLmOtmaYQJ5BvKrddBEdKvE6PzEYrLHWrYtrgsTGKKzhEnFmn2uS+urlPg4kR1mF+8 ZfbcTV7ZSftoAr/C+R6NvV8H45NDBFWAeIpLtHS9UBbKkUI6UlTdNFvbCcofH6MFHTWT pfRhXNLHuK3cEzRDhcnHIesC51hWZARTMqFk1O7hTs1zure8CXueyIVLkWdd8oKTyaD4 TxdmvA62ObnCm14ieuju4RCHqSz8TsiJVsg7941dVZgiadUHHrt7zZnoxnNZwtmA/YvK jO0w== X-Gm-Message-State: AOAM531vkYeDxaGFV0baLjZIJ8mAvuxkmlQY+J0spO0nF1ti7Ges7Y1T wGnpgLt/rewMXGr6jAFrTREdZqoxBFA= X-Google-Smtp-Source: ABdhPJwmwr3eAjKTF6OZsLtOSLHQF1EEVMNV5+lDEuIHtd7/NxMO3ZChY/zB2AKwFmjf4fm14pwmew== X-Received: by 2002:adf:ef51:: with SMTP id c17mr38005610wrp.101.1609099687974; Sun, 27 Dec 2020 12:08:07 -0800 (PST) Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id r82sm16941427wma.18.2020.12.27.12.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Dec 2020 12:08:07 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> Date: Sun, 27 Dec 2020 20:08:04 +0000 In-Reply-To: (Dario Gjorgjevski's message of "Wed, 23 Dec 2020 10:41:42 +0100") Message-ID: <874kk7107v.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dario Gjorgjevski writes: > Hi, > > Has anyone had the time to look into this? > > Best regards, > Dario Hi Dario, After a long long delay, I've now looked at this in earnest. I can report that I think the problem lies somewhere completely different than what I think you patch addresses. Instead of reworking completion-pcm--hilit-commonality [1] I think we should take a better look at completion-pcm--optimize-pattern. In its current form, it will thus "optimize" the pcm patterns like so: 1 -> (completion-pcm--optimize-pattern (prefix "f" any point)) 1 <- completion-pcm--optimize-pattern: (prefix "f") whereas I think it shouldn't be optimizing away the "any". When I make it keep the any with this simple patch, _most_ of your tests start passing becasue completion-pcm--hilit-commonality starts doing the right thing, i.e. it starts working the way it was intented to work, considering a (potentially empty) hole in the back of the pattern form. This is that simple patch: diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7d05f7704e..637a29eaa0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3165,7 +3165,7 @@ completion-pcm--optimize-pattern ;; the final position of point (because `point' gets turned ;; into a non-greedy ".*?" regexp whereas we need it to be ;; greedy when it's at the end, see bug#38458). - (`(point) (setq p nil)) ;Implicit terminating `any'. + (`(point) (setq p '(any))) ;Implicit terminating `any'. (_ (push (pop p) n)))) (nreverse n))) However, I'm pretty sure Stefan will tell us to hold our horses with any changes to this, since it's used in many more mysterious ways that I can't fathom. So, maybe this is a smaller, safer change: diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7d05f7704e..cc2573db19 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3245,6 +3245,8 @@ flex-score-match-tightness (defun completion-pcm--hilit-commonality (pattern completions) (when completions + (unless (eq (car (last pattern)) 'any) + (setq pattern (append pattern '(any)))) (let* ((re (completion-pcm--pattern->regex pattern 'group)) (point-idx (completion-pcm--pattern-point-idx pattern)) (case-fold-search completion-ignore-case)) [1]: completion-pcm--hilit-commonality, which does seem to have a couple of superflous calls to the update-score local function) [2]: please Stefan: remind me for the 1000th time what "pcm" stands for From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 27 15:23:47 2020 Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 20:23:47 +0000 Received: from localhost ([127.0.0.1]:33645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcZv-0004zc-3B for submit@debbugs.gnu.org; Sun, 27 Dec 2020 15:23:47 -0500 Received: from mail-il1-f180.google.com ([209.85.166.180]:39700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcZt-0004zN-Px for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 15:23:46 -0500 Received: by mail-il1-f180.google.com with SMTP id q1so7916861ilt.6 for <42149@debbugs.gnu.org>; Sun, 27 Dec 2020 12:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=b2nEiuewuIOm04gnni5OMU133fzw11mNOSEs9ho4OWs=; b=YxIvJYMuI1+K+sfBmCSYw1BL9MiL1LsJRIL+I2vEStYGfZ9cnY1A5Pr+eXb6nN47W/ uqh2ts+LoFFV4XdzOH+uMA4puDWi/8UGJ0LBOJX+xWxPfu8jGCrFQODeil3oSaMPE8Pk 10ORtgbnwAKLK2xnhwHMAe1XvdX9UEl77kspAO/in/3FjXHuBRdI5yyKxBF+nnmHqLc8 RdH7mmEUOyGv1xttRbj9qxoh0DLdUOvXCdrD6PO7Lehrz+ha0pmlJJCQHa7B+TDXyrNM AQ6r3UHda5FEx5viJPtR1i97AnguA7y8ILT6SXFlB8TZEUHjh4qHkHKn2oJIeoiMmeQv X+kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=b2nEiuewuIOm04gnni5OMU133fzw11mNOSEs9ho4OWs=; b=Vp4Xb+hQP4caKjInYDo6WF6J3HOOj+M0LeD0yEGNXJq4R1HSL7CcqlAkEKfzQTwGtZ 7fbS0BvTrpFdGadwF9V/ofbKBETpjCTgIUcfF21KFmyDMppNCLZ73qCAiZGig/ND/vLB RjpSIdKEfUkPmsyrI+9+Nr9WRnkQQew8FcWu3njYSu79Y3F0vyA4ipT9l3PTVv2xdKO8 iWAJpkhHZJT6S2WKXj5Fq1+fEe+Ch83utsdOAH78UPMM+Qz3/FUTk2bgwS4IXOT9Hqw3 IT2yx6ZREkrtWpFsQxoEGo225+tuphZuZGrl+0/iN55T26PMNaTidYIGnwn20Cs9NJKZ y3PA== X-Gm-Message-State: AOAM532QD+va9g9I1T5Kc/VjuMl3/r+bkJPFYpKiL6+1xYf3vYsPGADD OW3cNPeBgWC8WrkYvLtvdsKnUWudiGkzRD8cSno= X-Google-Smtp-Source: ABdhPJyCx9xD8mCMpvkenGzJEbpPZsYJvMdVtLOIoj0+lJ2X8GPyOGQU+mmfAXrrXbDXDwJLYLorkVlgLE7BlXxFW80= X-Received: by 2002:a92:4089:: with SMTP id d9mr36836550ill.199.1609100620191; Sun, 27 Dec 2020 12:23:40 -0800 (PST) MIME-Version: 1.0 References: <87sgbsv7gg.fsf@gmail.com> <874kk7107v.fsf@gmail.com> In-Reply-To: <874kk7107v.fsf@gmail.com> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sun, 27 Dec 2020 20:23:28 +0000 Message-ID: Subject: =?UTF-8?Q?Re=3A_bug=2342149=3A_Substring_and_flex_completion_ignore_?= =?UTF-8?Q?implicit_trailing_=E2=80=98any=E2=80=99?= To: Dario Gjorgjevski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I'm sorry, I seem to have sent the previous reply prematurely. However, there was not much more to add except my signature and some more reporting on test results. Thanks, Jo=C3=A3o On Sun, Dec 27, 2020 at 8:08 PM Jo=C3=A3o T=C3=A1vora wrote: > > Dario Gjorgjevski writes: > > > Hi, > > > > Has anyone had the time to look into this? > > > > Best regards, > > Dario > > Hi Dario, > > After a long long delay, I've now looked at this in earnest. > > I can report that I think the problem lies somewhere completely > different than what I think you patch addresses. Instead of reworking > > completion-pcm--hilit-commonality [1] > > I think we should take a better look at > completion-pcm--optimize-pattern. In its current form, it will thus > "optimize" the pcm patterns like so: > > 1 -> (completion-pcm--optimize-pattern (prefix "f" any point)) > 1 <- completion-pcm--optimize-pattern: (prefix "f") > > whereas I think it shouldn't be optimizing away the "any". When I make > it keep the any with this simple patch, _most_ of your tests start > passing becasue completion-pcm--hilit-commonality starts doing the right > thing, i.e. it starts working the way it was intented to work, > considering a (potentially empty) hole in the back of the pattern form. > > This is that simple patch: > > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index 7d05f7704e..637a29eaa0 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3165,7 +3165,7 @@ completion-pcm--optimize-pattern > ;; the final position of point (because `point' gets turned > ;; into a non-greedy ".*?" regexp whereas we need it to be > ;; greedy when it's at the end, see bug#38458). > - (`(point) (setq p nil)) ;Implicit terminating `any'. > + (`(point) (setq p '(any))) ;Implicit terminating `any'. > (_ (push (pop p) n)))) > (nreverse n))) > > However, I'm pretty sure Stefan will tell us to hold our horses with any > changes to this, since it's used in many more mysterious ways that I > can't fathom. > > So, maybe this is a smaller, safer change: > > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index 7d05f7704e..cc2573db19 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3245,6 +3245,8 @@ flex-score-match-tightness > > (defun completion-pcm--hilit-commonality (pattern completions) > (when completions > + (unless (eq (car (last pattern)) 'any) > + (setq pattern (append pattern '(any)))) > (let* ((re (completion-pcm--pattern->regex pattern 'group)) > (point-idx (completion-pcm--pattern-point-idx pattern)) > (case-fold-search completion-ignore-case)) > > [1]: completion-pcm--hilit-commonality, which does seem to have a couple > of superflous calls to the update-score local function) > > [2]: please Stefan: remind me for the 1000th time what "pcm" stands for --=20 Jo=C3=A3o T=C3=A1vora From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 27 16:21:11 2020 Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 21:21:11 +0000 Received: from localhost ([127.0.0.1]:33674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktdTS-0006Ks-LO for submit@debbugs.gnu.org; Sun, 27 Dec 2020 16:21:11 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12171) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktdTN-0006K1-Jr for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 16:21:09 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A60A180A72; Sun, 27 Dec 2020 16:20:59 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 42E0C80241; Sun, 27 Dec 2020 16:20:58 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609104058; bh=Ryr6QCx8HrFFVap0t2RQ7csPGXttI7gOkgBkNGQVXZ4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=PM9kYj7lzQl7ZWAEr+K+MlXMwI3ID8cnXOF9cyDTq0JgqyljB/WNZ5YVGNm4//ZQ7 LVbp+Vx8JufEMrdVXWqy/XctAKy22wpaiZwM41s3wcPkyWBvMblWkHEic8Nk4Uu98r zCLeF+JeFmQGl3wHms0flKk3QjaVXAOWdGmVWmbFdmJo7xhGmYTaWGliCZBlbcmHLY sdQbe7GVfaSiZUr7HUuV+PachrI+uOS1lrw6wiPWEbIxP2ia2bbXMinrTHsQL1q7CP fmDBr4j3fJP801zv1p4I4lqiO2zkhM1uC7bcHjded3ZahdMj90X8FmQ8W+gStdfJJG W+ysUmmrxaxqQ== Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id ECA9D1204EA; Sun, 27 Dec 2020 16:20:57 -0500 (EST) From: Stefan Monnier To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <87sgbsv7gg.fsf@gmail.com> <874kk7107v.fsf@gmail.com> Date: Sun, 27 Dec 2020 16:20:49 -0500 In-Reply-To: <874kk7107v.fsf@gmail.com> (=?windows-1252?Q?=22Jo=E3o_T=E1vo?= =?windows-1252?Q?ra=22's?= message of "Sun, 27 Dec 2020 20:08:04 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.126 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > @@ -3165,7 +3165,7 @@ completion-pcm--optimize-pattern > ;; the final position of point (because `point' gets turned > ;; into a non-greedy ".*?" regexp whereas we need it to be > ;; greedy when it's at the end, see bug#38458). > - (`(point) (setq p nil)) ;Implicit terminating `any'. > + (`(point) (setq p '(any))) ;Implicit terminating `any'. There is always an implicit terminating `any`, and I'd really prefer to keep it implicit. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 27 16:45:25 2020 Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 21:45:25 +0000 Received: from localhost ([127.0.0.1]:33697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktdqu-0006wx-Vp for submit@debbugs.gnu.org; Sun, 27 Dec 2020 16:45:25 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktdqt-0006wi-9L for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 16:45:23 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9CD5D440915; Sun, 27 Dec 2020 16:45:17 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C84C14407DF; Sun, 27 Dec 2020 16:45:08 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609105508; bh=7wMMMhKYzzB9RaLh8wyPdFBRh5vUZpds/D4nh83jJ6c=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=e5HL5KW3prRnJjyFAr5WD/zL5/GC3W5nIBJ0d3ec9D1GDEVO3rvoy2Bdxj2tXJ68a iCwPG5XzAmkQCQTbGEggDIvrJv8hg3h5rmWqdsfLqPhgKR4ubQKXrfAyMiyd1V2buB /FYzoPnOaT7WpLkMigm6P8Am/PVCxvL0+t7Z9Yuw+BmdVbAFTJnAJepK7tednZUPdP vn9SoWC7cPGwtxnHRLWNNBJGDsuXCocIXeb+JuenViZ98iTf9qtiUuvYjw2XH1hWRU AFozH2Hf75XGDyX/Bw9v+qiwqU+CI8VUkdOWsJJkj1qbg9lEL2TkLMucuIAWzGKNBQ /P34TT0PgCsnQ== Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 67E5E120433; Sun, 27 Dec 2020 16:45:08 -0500 (EST) From: Stefan Monnier To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Sun, 27 Dec 2020 16:45:07 -0500 In-Reply-To: (Dario Gjorgjevski's message of "Thu, 15 Oct 2020 16:25:08 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.107 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?windows-1252?B?Sm/jbyBU4XZvcmE=?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Please find attached a patch with an edited commit message. It should > be better. [ Boy, we are really unacceptably slow at reviewing this. ] Thanks very much for your patch. It looks good to me, but I think it's important we find a fix with which Jo=C3=A3o agrees. > Furthermore, =E2=80=98completions-first-difference=E2=80=99 and > =E2=80=98completions-common-part=E2=80=99 would sometimes overlap dependi= ng on the > position of point within the query string. Could you point us at the corresponding test? [ And thanks so much for the tests, this is great! ] > The former is fixed by correcting the part of > =E2=80=98completion-pcm--hilit-commonality=E2=80=99 responsible for loopi= ng over the > holes in the query string. Is that done by treating the "leftover" from the string as if there was an additional match? That would correspond to the "implicit any" that terminates every pattern. > The latter is fixed by explicitly moving > the position of =E2=80=98completions-first-difference=E2=80=99 in case an= overlap with > =E2=80=98completions-common-part=E2=80=99 is detected. Did you (by any chance) figure out how/why the two end up overlapping? The fix you're using looks pretty "hackish" and introduces a non-trivial data flow for `pos`. Before using such an ad-hoc solution it'd be best to understand where the problem comes from (it might still be the better answer in the end, but it's hard to judge). > (completion-pcm--optimize-pattern): Turn multiple consecutive > occurrences of =E2=80=98any=E2=80=99 into just a single one. This is good (consecutive `any` can introduce serious performance bugs because of our backtracing regexp matcher). Other than improving performance, have you found other effects? > +(defun completion-pcm--count-leading-holes (pattern) > + "Count the number of leading holes in PATTERN." > + (length (seq-take-while #'symbolp pattern))) `seq-take-while` is not defined at this stage. Either: - (require 'seq), but that means `seq` will have to be preloaded, which will require negotiating with Eli. - Mark `seq-take-while` with a `;;;###autoload` cookie so it'll be loaded on demand. - Avoid using `seq-take-while` here. I vote for the the 2nd option. I think Jo=C3=A3o knows the scoring algorithm much more than I do, so I'll let him judge if the change is sound. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 04:30:45 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 09:30:45 +0000 Received: from localhost ([127.0.0.1]:34212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktorV-00056P-0N for submit@debbugs.gnu.org; Mon, 28 Dec 2020 04:30:45 -0500 Received: from mail-wr1-f49.google.com ([209.85.221.49]:46057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktorT-000566-0B for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 04:30:43 -0500 Received: by mail-wr1-f49.google.com with SMTP id d26so10745289wrb.12 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 01:30:42 -0800 (PST) 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=AmRGFeuGm8FWYyxk6XA3Lv/Wv5vpX46Pml+sbB8gtPI=; b=MnBJjBZgqg2GZCJmFdwR1n79AZgcvAND2XOm1fkeD0ITImj30TyI/ietSHco3eadwf W1u58Iw3WDkpRqzNYLgTzFazC/rHVBwzWtTEAaAlkLomS9uxMt34jj0fdqmTI1iS8xWx p1wOHFQ/21HGvjiYXLnHGeI+VvMUOKSEpJN8rytxIqaVa4/cfbd1KQuVXw5LK9lNH0G9 34DOYxIWcsc4dLwyhIMEhk+huE5uV4ztFJMpAlMnSuSjWRW7n/M03QTc66s13g3UjJ+M N6dEQvJLC5/HEGXBtamKzMfod4D5zc48SUGoWqVLgnX48ArxLOxeAChRTGN03aIpGzU+ 1CaA== 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=AmRGFeuGm8FWYyxk6XA3Lv/Wv5vpX46Pml+sbB8gtPI=; b=R4wwXUCtz4HpjxL9/W+pmJvD7IoYdvC+kpAZnWeNC7w7G1ybHQrBGF2AUlHCog1ejm 9c0uScPW52Jt/sUL4bECEKnYOji2uctXCELMN6XzfvivuIJfcsDcEquvvTcviMhG4ALo F9N+gNoMuw+QT8qTEkuFWFvYk4V2lNyijV5qCiBUa3UnxFrIqOauCLvFgQu1ryp7BXcn amyLUCAAa5KrwQkSYPjCKFCaaRs1I+7tYZTZOzi+PfljG6T3+V2rJuy7kQAulUzkpc6m qVVg6W7KUNURbRW1HUXz2lD8V47cggTFaFVHFEvMc+T9AdzESeTqaAOpkkw1AFfoXlTW KBmw== X-Gm-Message-State: AOAM531Hkdjqaa9CGy13lZn6SejWNDjjjqdFCOCDWdGc64fePm/n7E3h mMgm7AVrbMO10m3yzu+IfJ780MuarCY= X-Google-Smtp-Source: ABdhPJx+rJTiIljErxcuBPTUHGqvw95RAxoUQFjXWollTj8hmMQw4WJ/v+JCDiHU2HP5v2gqxV9v8g== X-Received: by 2002:adf:e64b:: with SMTP id b11mr49842101wrn.257.1609147836688; Mon, 28 Dec 2020 01:30:36 -0800 (PST) Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id u13sm55030417wrw.11.2020.12.28.01.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 01:30:35 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <874kk7107v.fsf@gmail.com> Date: Mon, 28 Dec 2020 09:30:33 +0000 In-Reply-To: (Stefan Monnier's message of "Sun, 27 Dec 2020 16:20:49 -0500") Message-ID: <875z4ml1l2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> @@ -3165,7 +3165,7 @@ completion-pcm--optimize-pattern >> ;; the final position of point (because `point' gets turned >> ;; into a non-greedy ".*?" regexp whereas we need it to be >> ;; greedy when it's at the end, see bug#38458). >> - (`(point) (setq p nil)) ;Implicit terminating `any'. >> + (`(point) (setq p '(any))) ;Implicit terminating `any'. > > There is always an implicit terminating `any`, and I'd really prefer to > keep it implicit. OK, but can you elaborate on why that is? Regardless, if you don't want to touch that funciton, I understand, it is used in more places than just completion-pcm--hilit-commonality, which really should be called completion--given-that-we-know-this-matches-tell-me-where-and-how-well (or maybe it should have a docstring, which I've done just now). I propose something around this simpler patch. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7d05f7704e..df4ec67e35 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3255,10 +3255,10 @@ completion-pcm--hilit-commonality (unless (string-match re str) (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) - (md (match-data)) - (start (pop md)) - (end (pop md)) + (md (cddr (match-data))) + (start 0) (len (length str)) + (end len) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" ;; flex-matches "fabrobazo", "fbarbazoo" and It seems to be passing your original report, but still failing some of your test assertions. However, i don't know if I agree with those test assertions. This is one of them. (ert-deftest completion-pcm-test-3 () ;; Full match! (should (eql (completion--pcm-score (car (completion-pcm-all-completions "R" '("R" "hello") nil 1))) 1.0))) I still don't know why this misses, but I do know that the scoring part of completion-pcm--hilit-commonality is not meant for the "bare" pcm completion style or substring completion style. It could, though. I'll take a better look at those cases. Anyway, I've pushed this simple fix (and some another fix to the test cases) to the working branch: scratch/bug-42149-funny-pcm-completion-scores which I've also rebased on top of origin/master by deleting/recreating. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 04:38:25 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 09:38:25 +0000 Received: from localhost ([127.0.0.1]:34218 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktoyu-0005Hl-RI for submit@debbugs.gnu.org; Mon, 28 Dec 2020 04:38:25 -0500 Received: from mail-wr1-f47.google.com ([209.85.221.47]:47026) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktoyr-0005HX-Pd for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 04:38:22 -0500 Received: by mail-wr1-f47.google.com with SMTP id d13so10758494wrc.13 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 01:38:21 -0800 (PST) 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=TxI+SAYdaG8ufFL2cqWiP8HzU4m5C01u9KmQX1445sw=; b=OBQW6aAH+F/L1NtctEfWxwD/ToZCCEliMF4rndZgSunsMiP8enyMk0TtghCoqFC9PK pqm7ElwSwuIGDgY1En3tP8TbCOl/i5iFA2NAk08z84Ttt3y2BbE7TrVIIE935m68P6eM 2RLjmz+++dp5/xkhK/50yPacqQMrnEZOpgS+nzBtwUi6vef3koCLbbSvzvKf1/vt0L1D BLl46bsPOZaUTKFevhNzrkAaR/KuR63KDxfvC6PNNix+1M0TU6L1GByeQMW+wBfkpXDp dz3lrBxihqqWRGaDjweC5llsGogbi5XgAkdtVDYO9tiAuG1VTCGc9LtVBy6PeCGe8gLb vwYA== 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=TxI+SAYdaG8ufFL2cqWiP8HzU4m5C01u9KmQX1445sw=; b=Md2EMR9fNdb/pyaumLOWNP5uIln2luNcUbQCksG7CcoUDGAW2nHMIbea4sZgjuIZs9 KL+Or9FAtv+mHfQC5GDCrojB6x0HYrwVPEk+z0v0301mLJ+N7du4dPsw0EyhdRi/vxEY OzvUXrAaESGVo03Kjuh6m41STcmi7/sVXYhYWJU+LshXMRTZUQ4oGbrvWMcKHvK6wUNx 2s6wYIXPGnl1NrFucBiikGAR9WWo1ZCwF05quftdOQIF9IKH8B8PzhOm6N3Hhd5mcn2q IyKV3POqK0uMX84Kok9sLNxW/lK6ArZbO45n2a5BrIFVABDN/MGrsfhFg+5AM5bdrF0C ZK9w== X-Gm-Message-State: AOAM532SxlLp9giqMgqd/KwAsSuOWsjorC834mbS3jK2NsxT5UAXyaxm BTIrwkY1bObcZDV7XFi2lw/Rgdpvabs= X-Google-Smtp-Source: ABdhPJwWPrAbKU6BDerI8lLfWfmUXryTotWaHxu7K6x1BN5g83qTW6hNDBIw8A6BGZnTn9ihkkbE9w== X-Received: by 2002:adf:cd8f:: with SMTP id q15mr48804182wrj.79.1609148295394; Mon, 28 Dec 2020 01:38:15 -0800 (PST) Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id x17sm54931513wro.40.2020.12.28.01.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 01:38:14 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Mon, 28 Dec 2020 09:38:13 +0000 In-Reply-To: (Stefan Monnier's message of "Sun, 27 Dec 2020 16:45:07 -0500") Message-ID: <871rfal18a.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> Please find attached a patch with an edited commit message. It should >> be better. > > [ Boy, we are really unacceptably slow at reviewing this. ] > > Thanks very much for your patch. > It looks good to me, but I think it's important we find a fix with which > Jo=C3=A3o agrees. Indeed, I'm very sorry to be a kill-joy here, the patch doesn't look very good to me. Last time I looked it was too complex for me to follow, touches many lines, and created unnecessary consing. I'm convinced the current algorithm in completion-pcm--hilit-commonality is fine for these 1-char edge cases, given that the assumptions hold. >> Furthermore, =E2=80=98completions-first-difference=E2=80=99 and >> =E2=80=98completions-common-part=E2=80=99 would sometimes overlap depend= ing on the >> position of point within the query string. > > Could you point us at the corresponding test? > [ And thanks so much for the tests, this is great! ] Yes, please use the latest tests that I've pushed to the scratch/bug-42149-funny-pcm-completion-scores branch. They are still your test, only discriminated into various ert-deftest. If you want, you can split and discriminate further. > I think Jo=C3=A3o knows the scoring algorithm much more than I do, so I'll > let him judge if the change is sound. I'm not aware that it's not sound, but I do believe it's too complex and not well understood. In constrast, I can understand the three-line fix I did earlier and which covers all of Darios's test cases for the flex completion style. Previously it was failing 7 cases, now it is only failing these 3. F completion-pcm-test-3 F completion-pcm-test-5 F completion-substring-test-4 Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 05:17:55 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 10:17:55 +0000 Received: from localhost ([127.0.0.1]:34254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktpb6-0006E4-BN for submit@debbugs.gnu.org; Mon, 28 Dec 2020 05:17:54 -0500 Received: from mail-ej1-f42.google.com ([209.85.218.42]:39677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktpb1-0006Do-LQ for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 05:17:51 -0500 Received: by mail-ej1-f42.google.com with SMTP id n26so13563089eju.6 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 02:17:47 -0800 (PST) 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=uVUiuA/iCAIqhPwq/v8P9V9lRr1t8ovR0xSCPUDBIXc=; b=q0p8NG3PVSN9pmyOIofxXqHBFS60zj6edCdIPbDSls459JkBrHwiGjWVZSSQhHwITF pSdxQlDhQw/47YTo/UyxwdTq6WSJZWD9m5VEFE6nWepXMob/sPkL8XWSsIL3/VV3Jemi 2uDb+apAIIaY6e1pCLyYs4JjCNm/zC011cWexo/wd/HAEC+SM35ROOXMHrufRY1Tlj7s 4bLQRT1TcWESN4HJYpLKWKDHSRYiYcsaqf9PzAPaShI11kQehz1r9IwRuWcT/jzIksLy B7g6dtffwJmYOdQDW3GSQZRVHkHo9cozGZ4cDfu41bl/Qi3dHOxIIWG7HjlTqv0zapf5 Bu3A== 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=uVUiuA/iCAIqhPwq/v8P9V9lRr1t8ovR0xSCPUDBIXc=; b=T11U/HPmmk1T++IIS828dxxSiGQekKG2AxDzkatXMEk+OdeZfEIHaD9U1lx6RkQ7ki YbPDOMgzgFdE0lgKRFfIuEBzbvZj/F3cJWWg6Uwg8MZtFBF1hO5/pWL/qnLLKuHLIJhN BZnDqAb5LPTgtkW0CPZG8+jwCplQa4e/1HyIl3vUNpENgQd9/IM4FVC0wIi4ATnUrR+F ZzVZZOW2kXg/kAay5ceZpJebFxluIevNGw4JQUKdwr2ePMjusvG9eitiCmvDKfckx/iG +9cMIxxv161xxSbQUAFWXHoTw5LZnu5iOUfpLoG75JCAFpKJhMoP8i+znRP9w2nCiYDK 5EHg== X-Gm-Message-State: AOAM532vibekQWs+xv7XBlJw05F4EYuXaPWaP30LYdhyoP5QWlWmdssn cooAuuZPC7Q/8NF01MifnVndJn6eL8I= X-Google-Smtp-Source: ABdhPJxT2keAZRDK9+ituqoqPtlw77JC2OiLTcUaG055UEX2DE4On8vpDOTgkF2ASTnwpgIwKv1dfQ== X-Received: by 2002:a17:906:4809:: with SMTP id w9mr40841875ejq.139.1609150661640; Mon, 28 Dec 2020 02:17:41 -0800 (PST) Received: from ZALANDO-31298 ([79.140.114.243]) by smtp.gmail.com with ESMTPSA id l1sm16806231eje.12.2020.12.28.02.17.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Dec 2020 02:17:41 -0800 (PST) From: Dario Gjorgjevski To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Mon, 28 Dec 2020 11:17:40 +0100 In-Reply-To: (Stefan Monnier's message of "Sun, 27 Dec 2020 16:45:07 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Stefan, > Thanks very much for your patch. > It looks good to me, but I think it's important we find a fix with which > Jo=C3=A3o agrees. Thanks likewise! >> Furthermore, =E2=80=98completions-first-difference=E2=80=99 and >> =E2=80=98completions-common-part=E2=80=99 would sometimes overlap depend= ing on the >> position of point within the query string. > > Could you point us at the corresponding test? That would be the test ;; Point is at beginning, but `completions-first-difference' is ;; moved after it (should (equal (get-text-property 1 'face (car (completion-pcm-all-completions "f" '("few" "many") nil 0))) 'completions-first-difference)) You can replace pcm with flex or substring, it doesn=E2=80=99t matter. >> The former is fixed by correcting the part of >> =E2=80=98completion-pcm--hilit-commonality=E2=80=99 responsible for loop= ing over the >> holes in the query string. > > Is that done by treating the "leftover" from the string as if there was > an additional match? That would correspond to the "implicit any" > that terminates every pattern. I believe the simplest way to summarize the issue with the current implementation is that it assumes the regex match is of the form ... (Where the s might be of length 0.) However, the trailing is not there and therefore the score is not updated correctly. Furthermore, it does nothing to actually ensure these assumptions in the presence of wildcards in the query string. >> The latter is fixed by explicitly moving >> the position of =E2=80=98completions-first-difference=E2=80=99 in case a= n overlap with >> =E2=80=98completions-common-part=E2=80=99 is detected. > > Did you (by any chance) figure out how/why the two end up overlapping? > The fix you're using looks pretty "hackish" and introduces a non-trivial > data flow for `pos`. Before using such an ad-hoc solution it'd be best > to understand where the problem comes from (it might still be the > better answer in the end, but it's hard to judge). `completions-first-difference' is put at the first position after point in the query string. However, the part of the query string *after* point might actually match there. I don=E2=80=99t see an easier solution. >> (completion-pcm--optimize-pattern): Turn multiple consecutive >> occurrences of =E2=80=98any=E2=80=99 into just a single one. > > This is good (consecutive `any` can introduce serious performance bugs > because of our backtracing regexp matcher). > Other than improving performance, have you found other effects? Yes, the presence of multiple consecutive wildcards invalidates the aforementioned assumption of completion-pcm--hilit-commonality that the match is of the form ... >> +(defun completion-pcm--count-leading-holes (pattern) >> + "Count the number of leading holes in PATTERN." >> + (length (seq-take-while #'symbolp pattern))) > > `seq-take-while` is not defined at this stage. > [...] > - Mark `seq-take-while` with a `;;;###autoload` cookie so it'll be > loaded on demand. > [...] Good catch, this should indeed be done. Best regards, Dario --=20 $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net $ keyid=3D744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 05:22:27 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 10:22:27 +0000 Received: from localhost ([127.0.0.1]:34258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktpfX-0006L7-Ao for submit@debbugs.gnu.org; Mon, 28 Dec 2020 05:22:27 -0500 Received: from mail-ej1-f45.google.com ([209.85.218.45]:41517) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktpfU-0006Ks-Q1 for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 05:22:25 -0500 Received: by mail-ej1-f45.google.com with SMTP id ce23so13573124ejb.8 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 02:22:24 -0800 (PST) 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=DhxKrL1CVPPsdRTFJb8FqPWPe2rAgdLNmgJbKZt3EAE=; b=sR4+lQinjI2Rf/H2CNU34Wvf4yFi1Xi8gk0lycDWgZeUelrRoQPk4UCwDCmugRkvsQ 3Bc/6oHCx6tsKQ1UbAooYKebIBlB/nKKrczI5ffCm/6fiw+Ug0aJ8KeobWIjtbMJBYvg AowCRU9eZyolYRxe8QKp9pefLcsAeLkg84lbPxOGpUWu1caeSJ/UUQnvp+Lmj300nIQA eQN0jV8X4LvobIcb9QUDOuNZnrMXx762bq8xYZf8E5rVxhqY+BHsoO0CXiMLOQ7c7bgh a0gXnWLstGuOQSPPwNKC4SPusdUpL0+nsq9wFby4lh7qInWWSalILHf6sbZgwOaZZwpO dFaw== 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=DhxKrL1CVPPsdRTFJb8FqPWPe2rAgdLNmgJbKZt3EAE=; b=J5nq3SNJIm96wtDe1Hxs7nGx4OMZ5YDNuzQKSXTEuFt5gSEfy5V9x6BwF/NxuNvnuk Vff2glReD+kPZryIjjz7jxNYeNr2Yvp4BICBUkHx5QY+dcA7uhdqeNjgcvMe8Xz8nfGT rcMdljN0uoab2Gx50U/uL7UzADHeBuF7y0O8P8nP7xddAt6u+Ordvhn1zRVNvnH7S57R pAjX7cG7RauN3rv+TOlrKcLwWqIqeGs11lt9ZWi1wpAH1c4vkO4xxPyjfq2UgMj0e6Y3 MZgU+av31f22j2N61FTJdJtGS6L70ixhHo60rFGfpB3yOOhasyGleWn0uHhDNyWv5szc 6FTw== X-Gm-Message-State: AOAM530c1m4trBl1BUy+9rQpXLS2sbkMht0PM1u3sOhTI9yTXlBdo+aS jprrD35SCIpOlACDzMTirPcASHVVvTY= X-Google-Smtp-Source: ABdhPJxMdXPcxEU3yItwYfy3zdAe7E8QLJ3N8HEaw45/xIAQfDmFv9/9akeF11jLAcAUYz73ZPGqMw== X-Received: by 2002:a17:907:9614:: with SMTP id gb20mr29441838ejc.406.1609150938998; Mon, 28 Dec 2020 02:22:18 -0800 (PST) Received: from ZALANDO-31298 ([79.140.114.243]) by smtp.gmail.com with ESMTPSA id ga37sm16099187ejc.96.2020.12.28.02.22.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Dec 2020 02:22:18 -0800 (PST) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> <871rfal18a.fsf@gmail.com> Date: Mon, 28 Dec 2020 11:22:18 +0100 In-Reply-To: <871rfal18a.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Mon, 28 Dec 2020 09:38:13 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Jo=C3=A3o, > Indeed, I'm very sorry to be a kill-joy here, the patch doesn't look > very good to me. It=E2=80=99s all fine, however... > Last time I looked it was too complex for me to follow, touches many > lines, and created unnecessary consing. I'm convinced the current > algorithm in completion-pcm--hilit-commonality is fine for these > 1-char edge cases, given that the assumptions hold. I very much disagree with this due to 1. the test cases and 2. the previous reply to Stefan where I tried to explain the shortcomings of the current implementation of completion-pcm--hilit-commonality. Also, could you point to the unnecessary consing? If anything, I believe my patch is faster than the current implementation. > I'm not aware that it's not sound, but I do believe it's too complex and > not well understood. In constrast, I can understand the three-line fix > I did earlier and which covers all of Darios's test cases for the flex > completion style. Previously it was failing 7 cases, now it is only > failing these 3. Making the `any' explicit was also the very first thing I suggested, but further testing pointed to problems it doesn=E2=80=99t solve, which are ind= eed parts of the tests that are failing. I can add more tests if you think that would help. Best regards, Dario --=20 $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net $ keyid=3D744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 06:35:10 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 11:35:11 +0000 Received: from localhost ([127.0.0.1]:34390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktqnu-0008KL-Gs for submit@debbugs.gnu.org; Mon, 28 Dec 2020 06:35:10 -0500 Received: from mail-wm1-f43.google.com ([209.85.128.43]:40366) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktqns-0008K3-IB for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 06:35:08 -0500 Received: by mail-wm1-f43.google.com with SMTP id r4so9564828wmh.5 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 03:35:08 -0800 (PST) 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=xIp6VH+/MCsh1D/21fuMlyFRGOSkUHQaZseFUTlAZhg=; b=MXY8KYvGWkblE1KoZJn80ghwK5daV0YqTPzCgsD9tF79BqMOKyds971kjHmQR6X7yh NozSp3lXRCuI8pzKigkR8BLGTg7BIJtu7I951lOR4CCqBUzc+gZibZTOzydm/lmFKAmC 3gJVdRMknmjrCJ58/c/GvBmkPFVwvV3Lmogw7XWRyDSHl01E20IsetK4Q0N6+tMcAgsv LPKYFiF0JkaJ543pDkVi9/++EWcjp4k2bK4X5synHc/M7CmlS/V/47D9/TBeYZuy7Obc x/nZiyegYXnlXOcQslmoUZkCDNMmztP3QZM1BYGJdvFOuJJWRxpSgFy5KA+tJilbDH6A Cfdw== 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=xIp6VH+/MCsh1D/21fuMlyFRGOSkUHQaZseFUTlAZhg=; b=C617WozIwvrIQs0vGcD2hygwcxOixMd8pKx5rADGLrpywIztZaNhe/b+NBpAN3xXEU YJGzo1rz1n2Sm+jdyGf3IHuPN86t3EaQdBMvVOSktnU3CtD+tGRH4KCVXjASvemVD31P 7kHV8y9xZ2imcpB8L4EtUSnYtT5vM6SUbovRlYWx6D/jS2Hct+/siCKe3WObTZallF8o AAMMJx5A4P0MdHYIWkoomDuHNMGzi+1+wjiuiRy986mf6AwUyn7jXWfkb11GPx8h7Bqg xrs2rf/MzRug3ZTgqn90k/cloeyj+L98gRye6Jwak2A6JnIzr6A6ukZNTpqcW50QQoqu VC4g== X-Gm-Message-State: AOAM5339WN5g7BhAmm86Bme42kZ3FzOiCDawD4jXrIci/Y+BME2G0AYq ajSgJrgH+y7NMn0uZZdaCQNi/XtCCbo= X-Google-Smtp-Source: ABdhPJwvF3DBrnru8CEjWETaotD4+m9wrr/prvmXxgfjnxnjebZEFmL+REtZWHha9gmrttfCLt92Cw== X-Received: by 2002:a1c:4843:: with SMTP id v64mr20148335wma.186.1609155302264; Mon, 28 Dec 2020 03:35:02 -0800 (PST) Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id j15sm57482964wrr.85.2020.12.28.03.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 03:35:01 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <871rfal18a.fsf@gmail.com> Date: Mon, 28 Dec 2020 11:34:59 +0000 In-Reply-To: (Dario Gjorgjevski's message of "Mon, 28 Dec 2020 11:22:18 +0100") Message-ID: <87wnx2jh98.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dario Gjorgjevski writes: >> Last time I looked it was too complex for me to follow, touches many >> lines, and created unnecessary consing. I'm convinced the current >> algorithm in completion-pcm--hilit-commonality is fine for these >> 1-char edge cases, given that the assumptions hold. > > I very much disagree with this My assertion that your solution is complex is comparative, of course, not absolute. It is _more_ complex that some other existing solution -- in this case my three-line solution -- and I say that because of the factual observation that it changes much more than three lines, introduces new code paths, etc.=20=20 For now, I believe the original problem that started this bug report, which dealt with flex and substring completion, is fixed by my patch. Your failed user experience of typing "R" to perform "M-x R" should now be correct, as far as I can tell. Of course, you say your current patch fixes _more_ things, but I've yet to understand what those presumably broken things are. Perhaps once all of this is understood we will come to the conclusion that your solution is indeed the simplest possible. Or perhaps we won't. > due to 1. the test cases The test cases should be independent of the implementation, so adding more tests doesn't make the implemented solution any simpler. It does make solutions _simpler to simplify_, which is why I welcome tests. However, tests themselves should map to real-world problems (you know, the ones that you describe in terms of Emacs -Q reproduction recipes). And I'm still having trouble understanding exactly what these are for some tests. But I'm spending time to work on that. > 2. the previous reply to Stefan where I tried to explain the shortcoming= s of > the current implementation of completion-pcm--hilit-commonality. I don't understand these shortcomings, yet. I think they should be evidenced more clearly, in terms of actual user-experienceable problems. > Also, could you point to the unnecessary consing? completion-pcm--count-leading-holes and completion-pcm--match-size both add consing. That is clear to see from their respective implementations. I don't know if they can be made non-consing, though I suspect they can. Anyway, using them as they are adds a small amount consing. > I believe my patch is faster than the current implementation. Why do you believe that? Do you have any benchmarks to demonstrate it? >> I'm not aware that it's not sound, but I do believe it's too complex and >> not well understood. In constrast, I can understand the three-line fix >> I did earlier and which covers all of Darios's test cases for the flex >> completion style. Previously it was failing 7 cases, now it is only >> failing these 3. > > Making the `any' explicit was also the very first thing I suggested, but > further testing pointed to problems it doesn=E2=80=99t solve, which are i= ndeed > parts of the tests that are failing. My latest proposal doesn't make the any explicit. I'll try to understand what the intention is behind the tests that are failing. > I can add more tests if you think that would help. Yes, it would. But any test that you add should bring about evidence of a real-world problem. I.e., to state the obvious but make my point clear, the assertion: (should (eq 'foo 'bar)) =20=20=20=20 fails spectacularly but doesn't bring about such evidence. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 06:48:40 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 11:48:40 +0000 Received: from localhost ([127.0.0.1]:34440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktr0x-0000FG-QV for submit@debbugs.gnu.org; Mon, 28 Dec 2020 06:48:40 -0500 Received: from mail-ej1-f47.google.com ([209.85.218.47]:38651) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktr0t-0000Ey-08 for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 06:48:38 -0500 Received: by mail-ej1-f47.google.com with SMTP id 6so13848692ejz.5 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 03:48:34 -0800 (PST) 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=ZtvLYecJmM4/yvXohaPXIpnF6LfGHYXHTEJo22FcmPU=; b=GpdUtTe3CKd9MmsSY49Cght71rWioGwyyRpuRLd9/fLcIaGUnADIgHy+QAwILrAMRC OKlICwWbjST1lfxH9aFRi0JhWhXYrEcHEXXsoRjSPGXKwu+1OBt5G9yEAJLUNvhpv5EQ /4pTgjVrai+RUQn85cWc3u9NZCaozBC3PyJUR7/nyE2zqejigZQiqf8Ys2cNzTh54NR0 a3NY765TSczD91vqIrtGcxxgzysO+7oU9GPpKd/ai5h6RLpjk3b4bJ9nExkM++Dhou8W GxvcnUVCXWIrXtdaVNMJVvq38Or4T79hRq5fG8jN36t2rh/sFzrAxHj7BxnLboydYXr6 Dhvg== 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=ZtvLYecJmM4/yvXohaPXIpnF6LfGHYXHTEJo22FcmPU=; b=tGHf2tg4/LpqPJGWywwyrYIWsfk8WbaKCPzsdtwrRD/y3Vv6MRtsmj9BiKC3cz00M5 +AVylV6bGMBzWu7YF/PDcvtZIzhCTQFQtcPevtayMtM9nJ//MjRW71adKi5ucatwzGiC 2EBo93QQmyVOjsWTxCMVfSuwiKxdBn4pRfUOd3Q4jS/1xu6IqIf8lprlt7aUyfaFbPQF liMCkXnfFGLk4lqvipyFX82XI4sZe8zN16qYECaH0UKeb0XAzP3EukJE9OIkZ4TG5elt BVBUK/9LfNPxLphOuscRVUoiCMnBGzl1+QASGWdq/Ehijqheovk2e9PIOXPiOFZs6zSF whNw== X-Gm-Message-State: AOAM532BsmQ1uavsmAu9cMPLhUDfuP5dQl0RLX3XiSSpISeuRckevgK1 VgaaXp/YtqhBfoB6+2t2fuuAzXox2u0= X-Google-Smtp-Source: ABdhPJwYDYNfM2HlyJ7b0MHCkkqFdjoA0Q3QSQhNC+voROtEtVbvsYvuKIN/VczHjb0Cp4xM6IM7Pg== X-Received: by 2002:a17:906:780c:: with SMTP id u12mr15573779ejm.125.1609156108990; Mon, 28 Dec 2020 03:48:28 -0800 (PST) Received: from ZALANDO-31298 ([79.140.114.243]) by smtp.gmail.com with ESMTPSA id x4sm36684793edr.40.2020.12.28.03.48.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Dec 2020 03:48:28 -0800 (PST) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <871rfal18a.fsf@gmail.com> <87wnx2jh98.fsf@gmail.com> Date: Mon, 28 Dec 2020 12:48:28 +0100 In-Reply-To: <87wnx2jh98.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Mon, 28 Dec 2020 11:34:59 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > For now, I believe the original problem that started this bug report, > which dealt with flex and substring completion, is fixed by my patch. > Your failed user experience of typing "R" to perform "M-x R" should now > be correct, as far as I can tell. Sorry, but the branch bug-42149-funny-pcm-completion-scores doesn=E2=80=99t= fix any of that problem. (completion-flex-all-completions "R" '("R" "something-else-with-an-R") nil 1) Will make both "R" and "something-else-with-an-R" get a completion-score of 0, which is definitely not helping anything. Best regards, Dario --=20 $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net $ keyid=3D744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 07:57:21 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 12:57:21 +0000 Received: from localhost ([127.0.0.1]:34574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kts5R-0004An-3N for submit@debbugs.gnu.org; Mon, 28 Dec 2020 07:57:21 -0500 Received: from mail-wm1-f45.google.com ([209.85.128.45]:38186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kts5P-0004AX-78 for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 07:57:19 -0500 Received: by mail-wm1-f45.google.com with SMTP id g185so9735439wmf.3 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 04:57:19 -0800 (PST) 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=Uth/5Ngv+mPEVysyPSXscX0nLbJV9tWJ0YZMEEk6R94=; b=sawk//tfW+aZElLyUTwxE26hfRc9OFW3wPC1w4YDz92rL1+CtVkI0H9kby2LsSf2xJ nYu6EAQ3j+opVvTkenGKs0pj6seeKnl5qYzGtf625ZH5yzhe7Lh+c7vEGNGnfSTM5KSh VnUMGPh08cF9RkHOmjsypDsHReLsURb8ohTNsIUD4uwl39+w27WKfpafw9ZVNFDPF58b J9yHkVWBABPVi8qVITsz5eqyBJbyIoRcSa01eDUwks2FwvSfFRcLoiHYx+EIEpnoGd94 mOWI970w36CHwd5yZPcLnDTjUh+OI+P0xuCrMr+PMcfZgtBR5tSwuAQyfQ6xvoi9k8Bd KMWg== 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=Uth/5Ngv+mPEVysyPSXscX0nLbJV9tWJ0YZMEEk6R94=; b=oktFs1q3o2kp8JjNVvZR8mUoCFls5czSlxAXow3KcEZKM3hQQ+C6Ud7MB7I15oy+LL 8Lg7xNLww2RS6RKCfMMzvuuUx6e/8otw6u4sswLCiH0r1GGf6zgbGzWB4xlfDHoJJSB1 cKj2n9enoCnqetVO35EkHeRJ6NeFE13AVwIuB+d+tnkc4nW1yJjycTOTLGaVk2BkcVNj uYcwn7loBM2wYVT3+9XFlBcDgwtn65r3L7bxY6n7+voivvDsimGSHOOxanafIvKIw1oI 6CHqiAt0KNdTzbMeefwNRGQfQE38kP8kX9OFMIR5m+K3FS/jTUZnkIisMbgKeUr00um0 apcw== X-Gm-Message-State: AOAM531/wEz9RrgPvmxZRpH+WFPK8pHAekU7T2Wt9+4imPPwbLztM7h2 WTKHAWLrAtDsocLx5A4FAwYtOr3D0As= X-Google-Smtp-Source: ABdhPJwj1/OShayVLKfMdxnz7PVihblowZY7o3k4+NRxk4KgBNEuriwF8tIZAg/HFor921lvCiz/Mw== X-Received: by 2002:a1c:b7d4:: with SMTP id h203mr20593589wmf.59.1609160232931; Mon, 28 Dec 2020 04:57:12 -0800 (PST) Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id h3sm20245762wmm.4.2020.12.28.04.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 04:57:11 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <871rfal18a.fsf@gmail.com> <87wnx2jh98.fsf@gmail.com> Date: Mon, 28 Dec 2020 12:57:10 +0000 In-Reply-To: (Dario Gjorgjevski's message of "Mon, 28 Dec 2020 12:48:28 +0100") Message-ID: <87r1najdg9.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dario Gjorgjevski writes: >> For now, I believe the original problem that started this bug report, >> which dealt with flex and substring completion, is fixed by my patch. >> Your failed user experience of typing "R" to perform "M-x R" should now >> be correct, as far as I can tell. > > Sorry, but the branch bug-42149-funny-pcm-completion-scores doesn=E2=80= =99t fix > any of that problem. > > (completion-flex-all-completions "R" '("R" "something-else-with-an-R") > nil 1) > > Will make both "R" and "something-else-with-an-R" get a completion-score > of 0, which is definitely not helping anything. You're right. I was a little too eager, and reported results on a version that had another fix built it (a fix that is also simple and reasonable, but which I haven't shown since it conses a little bit). Anyway, the patch after my sig should fix it. I'll push it later with better comments, but it correctly identifies the presence or absence of a trailing 'any in terms of the match-data, and corrects accordingly, in terms of scoring. It also fixes another one (I don't know which) of your tests. Now only two tests fail: F completion-pcm-test-5 F completion-substring-test-4 I think we should focus on the meaning of these tests from here on. Thanks, Jo=C3=A3o diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 4c912b5a34..eec0b3e09e 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3263,9 +3263,9 @@ completion-pcm--hilit-commonality (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) (md (cddr (match-data))) + (match-end (cadr (match-data))) (start 0) - (len (length str)) - (end len) + (end (length str)) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" ;; flex-matches "fabrobazo", "fbarbazoo" and @@ -3326,6 +3326,8 @@ completion-pcm--hilit-commonality 'completions-common-part nil str) (setq start (pop md))) + (unless (=3D start match-end) ; ... which is t if we have trail= ing 'any + (funcall update-score start match-end)) (add-face-text-property start end 'completions-common-part @@ -3338,7 +3340,7 @@ completion-pcm--hilit-commonality (unless (zerop (length str)) (put-text-property 0 1 'completion-score - (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + (/ score-numerator (* end (1+ score-denominator)) 1.0) str))) str) completions)))) From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 11:04:11 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 16:04:11 +0000 Received: from localhost ([127.0.0.1]:36565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktv0F-000361-8D for submit@debbugs.gnu.org; Mon, 28 Dec 2020 11:04:11 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20185) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktv0A-00035M-3n for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 11:04:09 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 932C6809C6; Mon, 28 Dec 2020 11:04:00 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5D8268065D; Mon, 28 Dec 2020 11:03:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609171435; bh=1xEsy9Jep5GBBT3a5agjZI/JLDhD248ifEjWiLzGfi4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=RlizyjIB3ryRromllpUwjhXIKiVG3SpTKxN2eCHsitiKrJrvZ2YywUxmWSrBOUMhN A1/ezOjVazgQyrw/VMziz3WQn1Pt2Cm4v145jve9kyeXTQp5XPAVR+f+e76WugK0WD z3R5ulLmo0AkBgWCGKqns2iO6uXe4XgjQBQugpCJDzdmjJw5HOxz5dpCW8CnCFy42M mq5YLqs/UcNHJrwtUS+m9RHxXYjHfW7OENOsa4eFHGGx30+nMvvBi/fJlhBVqK565k tV5c5x1a9iNag15F6PtEr0m8F+fITrKy8ND//qArQ8322PchUxH2P1vW737Dl81vRs B/vOtkg6I7x5w== Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 145A912034B; Mon, 28 Dec 2020 11:03:55 -0500 (EST) From: Stefan Monnier To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <874kk7107v.fsf@gmail.com> <875z4ml1l2.fsf@gmail.com> Date: Mon, 28 Dec 2020 11:03:54 -0500 In-Reply-To: <875z4ml1l2.fsf@gmail.com> (=?windows-1252?Q?=22Jo=E3o_T=E1vo?= =?windows-1252?Q?ra=22's?= message of "Mon, 28 Dec 2020 09:30:33 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.125 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > This is one of them. > > (ert-deftest completion-pcm-test-3 () > ;; Full match! > (should (eql > (completion--pcm-score > (car (completion-pcm-all-completions > "R" '("R" "hello") nil 1))) > 1.0))) BTW, a good improvement to the tests would be to replace the score equality tests with score ordering comparisons (like "score of foo > score of bar") since it'd be perfectly OK to use a different scoring system which gives different values as long as the relative ordering is still obeyed. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 11:08:06 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 16:08:06 +0000 Received: from localhost ([127.0.0.1]:36570 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktv41-0003Cz-Oz for submit@debbugs.gnu.org; Mon, 28 Dec 2020 11:08:05 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:26017) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktv3z-0003CQ-Kh for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 11:08:04 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7510B80E1F; Mon, 28 Dec 2020 11:07:58 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 17A5180A5C; Mon, 28 Dec 2020 11:07:57 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609171677; bh=rqZ+aXidLSCZ0IQrCJVRmMKsX7CIMfLvoJX1Xiz3P68=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=GT9WDMnMNQWm7TXZPAik+gitDe15o1IWGWOaHfLHwBnumLPw0ghcwkDAuu7TKsjSA oEujrE3vMQanp+KnPmFqC8RS1BbEcdVpGwOfKotp3nuOQIi4PufzL+C3BecRqHxYxu tfFjNMR8/zmZUJAafGn7inPIvLzrK5t1073ec+wRd4jZW2zLl5Eldv3/ySjL1QAA/h 5Tq4SOmSPbTRgmXvoPQW7csDsYMl5SEfSv0qKRFvNY5cdue9+HJsZIaafiUWnZKMg4 sOsFewG2bYjpqCI0le2tpj+ob7hUcVocOStTZXzAhwGm82hzCyNoxrKK/vUyJ0eOO8 XpynF/OpEAfnA== Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id CB4D21204A2; Mon, 28 Dec 2020 11:07:56 -0500 (EST) From: Stefan Monnier To: =?windows-1252?B?Sm/jbyBU4XZvcmE=?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <874kk7107v.fsf@gmail.com> <875z4ml1l2.fsf@gmail.com> Date: Mon, 28 Dec 2020 11:07:56 -0500 In-Reply-To: <875z4ml1l2.fsf@gmail.com> (=?windows-1252?Q?=22Jo=E3o_T=E1vo?= =?windows-1252?Q?ra=22's?= message of "Mon, 28 Dec 2020 09:30:33 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.125 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Regardless, if you don't want to touch that funciton, I understand, it > is used in more places than just completion-pcm--hilit-commonality, > which really should be called > > completion--given-that-we-know-this-matches-tell-me-where-and-how-well Hmm... until someone=E2=84=A2 added scoring to it, this function did nothing more than add faces to highlight the common parts and the "first difference". So I'd suggest you take it up with that someone ;-) Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 11:26:15 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 16:26:15 +0000 Received: from localhost ([127.0.0.1]:36596 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvLb-0003ff-9u for submit@debbugs.gnu.org; Mon, 28 Dec 2020 11:26:15 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvLX-0003fK-Uy for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 11:26:14 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4C5E28058D; Mon, 28 Dec 2020 11:26:06 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C7178801A3; Mon, 28 Dec 2020 11:26:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609172761; bh=zjEgR2YJodP2NqY2sAqdaA2qY7a9ufic5H5Maw0SGy0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=TpfwUQ/9auZYvxlkx0TmbTsWjlky7uqq2JyayTRu8NsVshW4qdXJfF5He3HqhRXmB 2yJbvOlVdoY/rmgRKn/4e3RiTw05aJr1Q9li+/emRn5qV4RjzubkYl4n6hBoExLtYM L9b9+/rlG5J9nz91+WVGu8CLW2dD22F+Mnom4s+KWqkOZynB2D45bDVah/vAANTq11 bwD5nZnGFP+7/lw0LJ3CF6ADX6wYe3TA1ppPAcW33zOE9hnMc1sXHy8qnfNDBToNNo ZImyz6KSedClVAcGVKA7O6G+zbGcWp4+8C8FRGJZoN2T65iL5x7kLvTf2oVrA2JSuw bM7oquCFE7vjw== Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6C3781201FA; Mon, 28 Dec 2020 11:26:01 -0500 (EST) From: Stefan Monnier To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <87k0znsdjb.fsf@gmail.com> <87sgbsv7gg.fsf@gmail.com> Date: Mon, 28 Dec 2020 11:26:00 -0500 In-Reply-To: (Dario Gjorgjevski's message of "Mon, 28 Dec 2020 11:17:40 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.124 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?windows-1252?B?Sm/jbyBU4XZvcmE=?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >>> The latter is fixed by explicitly moving >>> the position of =E2=80=98completions-first-difference=E2=80=99 in case = an overlap with >>> =E2=80=98completions-common-part=E2=80=99 is detected. >> >> Did you (by any chance) figure out how/why the two end up overlapping? >> The fix you're using looks pretty "hackish" and introduces a non-trivial >> data flow for `pos`. Before using such an ad-hoc solution it'd be best >> to understand where the problem comes from (it might still be the >> better answer in the end, but it's hard to judge). > > `completions-first-difference' is put at the first position after point > in the query string. Oh, yes, I remember the problem is in the name: it is not really used to highlight the first difference, but rather something like the "next character to type" (which happens to be the first difference in the simplest case of prefix completion). In the example you show, I think overlapping *is* as good a behavior as any other (and the code is careful to to replace one face with the other but to actually put both faces there, so you get a bold-blue instead of either bold or blue). Moving the highlighting to the next character like you've done seems actually worse in this case (e.g. if you're completing ("f" . 0) against ("foo" "barfoo"), it's rather odd to highlight the "b" of "barfoo" and the first "o" of "foo"). [ BTW, I notice that we have a bug currently in the highlighting: M-x for-s C-a ? correctly puts "for" and "s" in blue in the completion list, whereas M-x for C-a ? somehow fails to put "for" in blue :-( >> This is good (consecutive `any` can introduce serious performance bugs >> because of our backtracing regexp matcher). >> Other than improving performance, have you found other effects? > > Yes, the presence of multiple consecutive wildcards invalidates the > aforementioned assumption of completion-pcm--hilit-commonality that the > match is of the form > > ... Makes sense, thank you. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 11:58:43 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 16:58:43 +0000 Received: from localhost ([127.0.0.1]:36681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvr0-0004a9-Mx for submit@debbugs.gnu.org; Mon, 28 Dec 2020 11:58:42 -0500 Received: from mail-wr1-f41.google.com ([209.85.221.41]:41872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvqx-0004Zv-P8 for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 11:58:41 -0500 Received: by mail-wr1-f41.google.com with SMTP id a12so11820753wrv.8 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 08:58:39 -0800 (PST) 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=R3g3zZVTkKNmwjCJ9Z2kYk+9K33l8+uYXjwjZdLe9c0=; b=mJWoYNEl8B7Boyol6A2pw85Dsq4HVby1HMYvcqGBVAvr00MlpoR17WIv7krSHGMUDY Oub9/XdyMZ66V66Ab5Exd+NphMGqILmmGIK/+GzwxYx7UxJ8AB8IO1wEfKoUQKevedur C4J66GIk3cUHx2svmTPMKHsdJKmO3l/1G/v5sl9qEvpqVkxe7/mW1TCAUvM125bXEf3E YotoYvpP+/YVS4U1pUKfgJ0TTVgDCPzQFygZ0gcvgZoph262nnwN/udoUWV1ZPbHy7eL hHYEWHrECmXnJFOqNZj5WyproIuUTyopkWuUUeZJZ/4B/ZrbjXajwxpX/q3zxGZYtVoS MVjg== 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=R3g3zZVTkKNmwjCJ9Z2kYk+9K33l8+uYXjwjZdLe9c0=; b=bKw0uRYKoQkGPhVU6dMI+dg8F3vPngKagJVo9i5r7JIt4Wf4u5GVoeCG5usA9Z3+TF uRPx8/8eapu6F+rBLDyI7rI3nmH9lOluRmkfSihVrkLz3ab9U1vYmLLzHYUKw1JdXKWF oWqw3eOHEaqqkC1UVpvJKepYlhAMcNMnJBJcQ3ygmKR3m+GWtPRPm1U2dNY+3e+KoYbE es8J8BSCpSAIf5uCy73gccUV05nIb0bSQabxoOcya8e6OezKHFn3UL5acK7NrQtXe2OQ /sOV7QDfjr1O+CSN+INn7QMl6/7sUtJ7T222yeqJ3P3RPwcnP4/47aG6gdHeCAflbi8C +s/g== X-Gm-Message-State: AOAM5335Z4BhxaYrTamYWidhg5vwNcP7qVjXwVmcvs5Z1xthvyuxha0q 8X1i078g8XECV9SqBd00S3oRQIQj/BA= X-Google-Smtp-Source: ABdhPJysTjXRlqEf/DWagvY3ZQJyVe5YcQbLhKrz+X3wcveRMeBei/uuoB5ACrSCBs+WUihOBhgmng== X-Received: by 2002:a5d:4e92:: with SMTP id e18mr53753228wru.66.1609174713640; Mon, 28 Dec 2020 08:58:33 -0800 (PST) Received: from krug (6.213.115.89.rev.vodafone.pt. [89.115.213.6]) by smtp.gmail.com with ESMTPSA id w13sm55585246wrt.52.2020.12.28.08.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 08:58:32 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <874kk7107v.fsf@gmail.com> <875z4ml1l2.fsf@gmail.com> Date: Mon, 28 Dec 2020 16:58:30 +0000 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Dec 2020 11:03:54 -0500") Message-ID: <87im8lkguh.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> This is one of them. >> >> (ert-deftest completion-pcm-test-3 () >> ;; Full match! >> (should (eql >> (completion--pcm-score >> (car (completion-pcm-all-completions >> "R" '("R" "hello") nil 1))) >> 1.0))) > > BTW, a good improvement to the tests would be to replace the score > equality tests with score ordering comparisons (like "score of foo > > score of bar") since it'd be perfectly OK to use a different scoring > system which gives different values as long as the relative ordering is > still obeyed. I'm not so sure I agree. I mean, I agree with the general principle, but I also think in our particular algorithm we can make some simple guarantees about the absolute value of the computed score in such trivial situations. In this case, Dario's test asserts that a full and perfect match has a score of 1 (hundred percent). So the test is only brittle if we break down this pillar, and I don't think we should. At least I don't think we have good reason to. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 12:04:52 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 17:04:52 +0000 Received: from localhost ([127.0.0.1]:36694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvwy-0004kt-24 for submit@debbugs.gnu.org; Mon, 28 Dec 2020 12:04:52 -0500 Received: from mail-wm1-f45.google.com ([209.85.128.45]:39278) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktvww-0004kh-Cs for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 12:04:50 -0500 Received: by mail-wm1-f45.google.com with SMTP id 3so10293565wmg.4 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 09:04:50 -0800 (PST) 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=dlD9yM9vMqHE2bR+FKnVl+WJeSNf3BoPaew6uUV4qjE=; b=oxkf9FOv6N1CpJQKBR1Vm5DwFkiq11NWjxKObzEkx+gZTz+2XsZhMeDtSZBN//9R9N KL0oZEDueWt/GyoK9Xx4VQ1T78zij5RN81jzjnuYEo8xvZ8QiXsQZ4fUDjEmIEcmxRoY SDZw3N4X1FsGyp9AGm+iDu7H7oGUlf0XZIE7G1ZPCzTdJMwQxaN4U+WF06k+gRt1HKFN qawYIQQbFbGYx022m4q/luLtBY1KPMSGA0DkzenYLeTZ3GqWDl2x7mDYtcE9ARmc3vmC npM92DeCM4sDBUKSQILL5jQxcB84Xa+rS9gltWsvm2y1WrcpZsWw9WTTwnP5CJAca0aD gpRA== 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=dlD9yM9vMqHE2bR+FKnVl+WJeSNf3BoPaew6uUV4qjE=; b=R6oq+KBmW3V/8jD/JoBpCAwpS/BgGA0MG0dWAvcST8df5MroWij7MAU+W86HOoMIFh KLDC8aVXOXvgV6Ln638oZWmz4u6mabYtDJ1ujgKFxQC7ArOuYeUV/WqLN9NyM5voT0CO 21evUMiDAFPrZe1Tt4TB1k8PdEtRFxQbskjA5rWr5g6RbyZHq8myv2V2L1JmMl98WWHr r2Zfu3xkK+7bIsqf8A09bJB8cemVRu3RYKvQRlbnAVOYqt6VvLkmOO/ufrRkAs3VP11v aKl5uygMUZwKqbx3UdE/rAUuEn63FrGiHmmZXeTmuuieGYfZR8mM/dSe4N5ZOVSPDXdt uVDA== X-Gm-Message-State: AOAM530clxo9yaP45DapUS93rTMmTDY5S/hYXBpwH+jS6so2fUWSnWAm fR7C4nLrwUhfGAzEVXyQwzRuP73hu1k= X-Google-Smtp-Source: ABdhPJxEyhjxk885oZHeh/gcuaIFoG6dmPnIKfqr96jIzpVNi+QDyZS4aDPN7oI58GyWH3aCsgvwvQ== X-Received: by 2002:a1c:208f:: with SMTP id g137mr20760707wmg.67.1609175084101; Mon, 28 Dec 2020 09:04:44 -0800 (PST) Received: from krug (6.213.115.89.rev.vodafone.pt. [89.115.213.6]) by smtp.gmail.com with ESMTPSA id 125sm19581292wmc.27.2020.12.28.09.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 09:04:43 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <874kk7107v.fsf@gmail.com> <875z4ml1l2.fsf@gmail.com> Date: Mon, 28 Dec 2020 17:04:42 +0000 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Dec 2020 11:07:56 -0500") Message-ID: <87bledkgk5.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> Regardless, if you don't want to touch that funciton, I understand, it >> is used in more places than just completion-pcm--hilit-commonality, >> which really should be called >> >> completion--given-that-we-know-this-matches-tell-me-where-and-how-well > > Hmm... until someone=E2=84=A2 added scoring to it, this function did noth= ing > more than add faces to highlight the common parts and the "first > difference". So I'd suggest you take it up with that someone ;-) :-) Grumblebgrumpbl. I kinda did, and so I added a docstring to it (have a read). Anyway, what's suprising about this function is that this re-matches PATTERN to each of COMPLETIONS which is very odd to the reader, becasue it also asserts that PATTERN already matches COMPLETIONS. Why are we regexp-matching twice?! -- asks the poor soul reading this. This comes down to completion-regexp-list being used by Fall_completions() directly. If that C function recorded the match data in all the lisp strings it was passed, then completion--given-that... would be easier follow. And likely faster. Though I haven't measured the impact, sparing a regexp match against each completion might be worth it in terms of responsiveness, especially in flex and similar methods. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 12:16:59 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 17:16:59 +0000 Received: from localhost ([127.0.0.1]:36712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktw8g-00054I-Ty for submit@debbugs.gnu.org; Mon, 28 Dec 2020 12:16:59 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:35767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktw8e-00053u-7q for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 12:16:56 -0500 Received: by mail-wm1-f49.google.com with SMTP id e25so10366149wme.0 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 09:16:56 -0800 (PST) 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=/KewdaImyXmBgBBYFXkxtdHanGI2kU3YYSfV02wMG/8=; b=M5Ds+wCgl5BtTt1gQXQK0az50MHNsA0IvAeyFSP39zbrJE2ZEe+t4tL29Lf+l62oSe GKOWt/JLQNOkRAAC+jdNYIHoKCsJRNS2aptXGY36TTCpS1+dzaSCvCNLeArF6VNUsycV liQ4gd4yfPIfTAxAX/9Q4S1aXOpL5LrbDCYkhWE+GSM9e3N8LNJ1ftE+NoOY1JP9VZp0 l2hExB/S1jJnpD1B9r92Qs9A4jo0U6no3sL2+dUaPs3HqkIXw9FhJ30GchZxBN9xR8kG ye9Ea3IsXySybyHA6T2b2houZ+v8iBkpH8fKBmHVrtIsIZ7WN2vpuHZFWXmTDg/qUx2s MGLA== 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=/KewdaImyXmBgBBYFXkxtdHanGI2kU3YYSfV02wMG/8=; b=dSC6hhsN2hV4KiRqOu5XL1TQ6idcyw3S60plTSfpA8qebN+8pkbgFBTVkliqo/b+X4 Vxcpw8NoNKvnmJS+cUT11I5Y3Lsj0dmrFmWW9jeQACcQEO/Tg8D4q8wUbf50zPv1Hpza LBsOZv8Fimj8WRRHXE6aSC3AOHQI3MceRZFryRw6K3Cu0NTY2ZtGqqQu2ndkeMYykTd0 0k/0NFp4XIr5TT3A2bB/8ahkc1mXdizGxMtQYH77Z7jHPy8DArp0RyhAIj3S2Z78kLg1 eH7IDhwSd2bg0NFxWlGAwYjoChZ1Pshu5nLE87d2Nq9i2q1djYdjRTIVtNBv32ho2Zya lwAQ== X-Gm-Message-State: AOAM533UVVWIhjvFZx99NW7qnwldFtgfkf3oWd3TobYmqccYh0CFdz6C VMmoryRKZ4lJaLMLBSHSO0TvuYVDnu8= X-Google-Smtp-Source: ABdhPJx8yr4vr08M4+dS3VFhUgRCCvI0iNiT0D5l6mTWFQToYXfThQIK+SJnRiGfSvmPPNdnDlEAFw== X-Received: by 2002:a1c:9acb:: with SMTP id c194mr20919103wme.43.1609175809931; Mon, 28 Dec 2020 09:16:49 -0800 (PST) Received: from krug (6.213.115.89.rev.vodafone.pt. [89.115.213.6]) by smtp.gmail.com with ESMTPSA id z63sm21900720wme.8.2020.12.28.09.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 09:16:49 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> Date: Mon, 28 Dec 2020 17:16:48 +0000 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Dec 2020 11:26:00 -0500") Message-ID: <877dp1kfzz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> `completions-first-difference' is put at the first position after point >> in the query string. > > Oh, yes, I remember the problem is in the name: it is not really used to > highlight the first difference, but rather something like the "next > character to type" (which happens to be the first difference in the > simplest case of prefix completion). > > In the example you show, I think overlapping *is* as good a behavior as > any other (and the code is careful to to replace one face with the > other I agree with this general idea. I think we have to be careful to write tests in terms of user experience as much as possible. For example, in the very latest version of the code I pushed, I still have one of Dario's original tests failing (down to only two now). completion-substring-test-4 Actually, only 1 of 3 of its assertions is failing (and this is an argument for splitting it up further). This is that assertion: (should (equal (completion--pcm-first-difference-pos (car (completion-substring-all-completions "jab" '("dabjabstabby" "many") nil 1))) 6)) The number returned by the current code is 4, and not 6. Maybe this is wrong, but I don't know if it makes a difference. If I evaluate (let ((completion-styles '(substring))) (completing-read "hey? " '("dabjabstabby" "dabjabfooey" "many"))) ... and then type "jab", backtrack two characters, and type TAB. I see the 's' of stabby and the 'f' of fooey being highlighted as the "next character to type". I also see "jab" correctly highlighted. Exactly as expected. Likewise if I evaluate this: (let ((completion-styles '(partial-completion))) (completing-read "hey? " '("few" "many" "foo"))) which is similar to the other failing test. Anyway, what I mean is that we need to see tests that tell us when things are failing at this level. It's not always easy to write such tests: we should pick "public" interfaces carefully (regardless of these problems Dario did a great job with the new tests, which are certainly better than the pure nothing we had there.) Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 14:49:03 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 19:49:03 +0000 Received: from localhost ([127.0.0.1]:36941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktyVq-0002al-OK for submit@debbugs.gnu.org; Mon, 28 Dec 2020 14:49:02 -0500 Received: from mail-ed1-f52.google.com ([209.85.208.52]:43736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktyVl-0002aB-NS for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 14:49:01 -0500 Received: by mail-ed1-f52.google.com with SMTP id y24so10699729edt.10 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 11:48:57 -0800 (PST) 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=Z9VU8uXtZRlh8Fh7uNhqQRa2Pq+YJxuyY7Ps7S5miEw=; b=YSeOevILWC2kg4xouZV3YbrHYcNNjxBq4B69eZAXQ2caXEdNwKYTtC+bVXcLCRc6ce 2Tlx1W7erFJp9y+n2gESS575ZFnbVNPdszv5pa6gbvWoPqb9mV+OyRuBz6g46WSd6W+T d8DuPhwJNooQh4SXz5rSklR6KYnrchSeNOUpnbeULrV5jG5UHZdxuAC4v/0NF/Yfp/L1 txhBrWGf5c3gvm+R2GxuLwKP4QOdLUKZDgsmeSp/HNiJG0ybWBd9dJ+yHa0uViQTbWVI TAniOWZvJgOtqHnv3PKeX0SmAvpP3Z3eaQ0QLmsB4b059jYi7kr5vSk66Zo7h9XiE4yA giig== 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=Z9VU8uXtZRlh8Fh7uNhqQRa2Pq+YJxuyY7Ps7S5miEw=; b=X2LyE6Lt37o3MTo7MDbjUErUE4/T+oqyNx0uUPCkjUGuIgfdZ3HdeXuzOi1WgMSmqN IfW0hfdtkJOpufsHNU5MRWItPJvCCsVfwDRE/AzfX4l4809MpALGewJ/tRFaW8eukmhV hR6urG0qJfYzVonRQT43iNCqdbHtDKdMNU1vARtqp58Mqp6gAAlflpgHFrFZOBzgtrms fRAevA9bfQMinfVilwYSmYlMfe4l1JzIt70ICQ7f1zzE2lwZZVGSJs4hc95lSvFrYb7d CYodStZop1BmvGdu/9Opjc215sl5VqoW+dsbsHRr7G1UyyfoGLqa00PXJCLUp8Pcy30k PkYw== X-Gm-Message-State: AOAM532kHomQekixNn5J3dSswSusK92tlQTlbC4EusxW81LhrwJN3zvI y9whZRce73miAzaJzQ0+HUfA42/XXgo= X-Google-Smtp-Source: ABdhPJygXas+tE4mjZzSnipcSwLwe11CAiPc1mOlDGDBAiS+AeQSIOBDP2Nv0/GDXx0VP2yvzU6AZw== X-Received: by 2002:a05:6402:2074:: with SMTP id bd20mr42745224edb.326.1609184931549; Mon, 28 Dec 2020 11:48:51 -0800 (PST) Received: from ZALANDO-31298 (p200300e9772150b2a1d656ddd4cf4854.dip0.t-ipconnect.de. [2003:e9:7721:50b2:a1d6:56dd:d4cf:4854]) by smtp.gmail.com with ESMTPSA id b19sm36384877edx.47.2020.12.28.11.48.50 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Dec 2020 11:48:51 -0800 (PST) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> Date: Mon, 28 Dec 2020 20:48:50 +0100 In-Reply-To: <877dp1kfzz.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Mon, 28 Dec 2020 17:16:48 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) >> In the example you show, I think overlapping *is* as good a behavior as >> any other (and the code is careful to to replace one face with the >> other > > I agree with this general idea. I think we have to be careful to write > tests in terms of user experience as much as possible. For example, in > the very latest version of the code I pushed, I still have one of > Dario's original tests failing (down to only two now). Makes sense. I had misunderstood the purpose of the face. Overlapping is indeed fine -- for all I care, we can also avoid putting it altogether in cases where there is no _first character to type_ (without moving point). But again, the current behavior is OK. In that case, the tests should be changed. >>> This is good (consecutive `any` can introduce serious performance >>> bugs because of our backtracing regexp matcher). Other than >>> improving performance, have you found other effects? >> >> Yes, the presence of multiple consecutive wildcards invalidates the >> aforementioned assumption of completion-pcm--hilit-commonality that >> the match is of the form >> >> ... > > Makes sense, thank you. I think this elimination of consecutive `any' should also be included in Jo=C3=A3o=E2=80=99s branch. Best regards, Dario --=20 $ keyserver=3Dhkps://hkps.pool.sks-keyservers.net $ keyid=3D744A4F0B4F1C9371 $ gpg --keyserver $keyserver --search-keys $keyid From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 15:01:07 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 20:01:07 +0000 Received: from localhost ([127.0.0.1]:36965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktyhX-0002v3-BS for submit@debbugs.gnu.org; Mon, 28 Dec 2020 15:01:07 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktyhS-0002uF-CF for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 15:01:06 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D45E04407B9; Mon, 28 Dec 2020 15:00:56 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B7C92440791; Mon, 28 Dec 2020 15:00:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1609185655; bh=yiIb/o7DYXsyxrtjx5HapFOppS20uRCDAiB1NXN/EVc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=cowUsrX0Q27KocKL1+gmyoczns8ejWYsA+pIqJjG6RW7KGpN1Em/UVxInlVxAlziz 0YcnBalQOICN/hde6xqfCClmxxWJ2oPNJDXsxclG9IjH532tCFLCpsV9oqFXBU9aLs kpnO41pcPHdgdTkjDtOrKbSkfDPy2HcpEn5E3q6koagQ/SaCDOAamhCoXpYN/C/Zzk tsu3txhDYFV+t2CXl4Fh2cGqnpftN3BbIzja1muhLs9ZrnpLOYdlVwvTk6aNnJRUpA /5zDOFQr44a36/ffpCn2OmZrhMo+26YCmFuefbEtYyQxH7EQtcxD+SeyynyxGdesF1 sF5L2x0X6w+8Q== Received: from alfajor (unknown [104.247.243.191]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 83C731202E2; Mon, 28 Dec 2020 15:00:55 -0500 (EST) From: Stefan Monnier To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= Message-ID: References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> Date: Mon, 28 Dec 2020 15:00:54 -0500 In-Reply-To: (Dario Gjorgjevski's message of "Mon, 28 Dec 2020 20:48:50 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.101 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, =?windows-1252?B?Sm/jbyBU4XZvcmE=?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I think this elimination of consecutive `any' should also be included in > Jo=C3=A3o=E2=80=99s branch. I just pushed (a rewrite of) that change to `master`. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 28 18:20:32 2020 Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 23:20:32 +0000 Received: from localhost ([127.0.0.1]:37157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ku1oW-0001Og-89 for submit@debbugs.gnu.org; Mon, 28 Dec 2020 18:20:32 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:54946) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ku1oT-0001OS-5Q for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 18:20:31 -0500 Received: by mail-wm1-f49.google.com with SMTP id c133so679688wme.4 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 15:20:29 -0800 (PST) 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=oCNDBOxMMXT82buEELrWbetLdh/5xXGGtBtZziH11SA=; b=Fk3/LESKQhpSFIZXEAaVOlvZ2i999lmXwlJqH1+5yz997cOiyzthxDAPKur9fni7a2 /ntVZpAhurdmG/CbMHkhynzGszfjDCLbRRr6A4fULYnQD72u2/GRahu1rU+JtdvLmsma s/NMq/W2ZNsMQHvZY4xaeE7/Bql4f5XgBuu8VrQR0b0jt8cLvHMSysskeM3Qnr77FceE EWqCjn9C+/4xIgP2IfbYwvb7QVBJtT6hxC9Xqeh9Utl9UEKNotuEGCDnMCjyuoRj+SD8 Uw0WOCrcEiXvJnITWmMs6soa41i7j20P4MZBexaRRtfzNCZ9jlguKLGvCpkaGIf8wlPl /J+A== 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=oCNDBOxMMXT82buEELrWbetLdh/5xXGGtBtZziH11SA=; b=aAe7kzZgShKiqi4E8JBOqiOb/3XWwQ2HKmmQLZtNOYrSvCcvc1gDkCB65zNzesMk4V MvOG7kNqRHzSxKfSOdKuJPLbf1yIuZog1PpOq9DBgVq8wy8b8PW0eoW22OLF6ksW8287 vWUX1piHdAq/2kakRE8aRPwQbY261siZPCutF/qmTNvs4x4hrHMNlR1A3ZHo2ocZyj5u CV0TDCyukE1cFOJ7a8U23lhWVwRxyrrBUbtEieV36bmzq7W/xfNE0IxBgA4VAOF/CwZp mp975tvd41aAgRE6Shar0VqcW/PM1e7kTZpMrrW3HcdzZPz1YonI2s84ea7iARxNmSVI RTdw== X-Gm-Message-State: AOAM533/08ZDM+G9ztzIvERS7acsZE+tFla2+gK6SvoRp0yawfBkF9Ex QiI8f/RrZTkkawzyoYxxsMpXc8+7JoI= X-Google-Smtp-Source: ABdhPJziEGyX6pbczdptsEDSN11iL0oldPdMd+oQRvikdN1Tk1sTbL929hMFgxLOVnBPQMriff8+nA== X-Received: by 2002:a7b:c8c5:: with SMTP id f5mr950548wml.106.1609197622940; Mon, 28 Dec 2020 15:20:22 -0800 (PST) Received: from krug ([89.180.149.164]) by smtp.gmail.com with ESMTPSA id o83sm909689wme.21.2020.12.28.15.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 15:20:22 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> Date: Mon, 28 Dec 2020 23:20:19 +0000 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Dec 2020 15:00:54 -0500") Message-ID: <8735zpjz64.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Stefan Monnier writes: >> I think this elimination of consecutive `any' should also be included in >> Jo=C3=A3o=E2=80=99s branch. > > I just pushed (a rewrite of) that change to `master`. And I just pushed my cleaned up fix to to master as well, thus hopefully fixing the brunt of this bug. Dario and others, please test this. I haven't yet pushed the tests, since we're not entirely sure of those, but I think we should break them up further and push them too, once we come to an aggreement on what and how they should test exactly. Thanks, Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 29 08:27:19 2020 Received: (at 42149) by debbugs.gnu.org; 29 Dec 2020 13:27:19 +0000 Received: from localhost ([127.0.0.1]:37983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuF1z-0003hU-2n for submit@debbugs.gnu.org; Tue, 29 Dec 2020 08:27:19 -0500 Received: from mail-wm1-f54.google.com ([209.85.128.54]:34132) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kuF1w-0003hF-A0 for 42149@debbugs.gnu.org; Tue, 29 Dec 2020 08:27:17 -0500 Received: by mail-wm1-f54.google.com with SMTP id g25so1239778wmh.1 for <42149@debbugs.gnu.org>; Tue, 29 Dec 2020 05:27:16 -0800 (PST) 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=ChLAjYvGxdpquRVo7eFXQX11v8cvxG9nCL6xs/k6Nkc=; b=tc7g12ER1ctSUJIyjFAmn4n/NDvdrdiKzUPfpvOAS7Z8ilrpbXdjKv5ME72Kx8cgnQ LSosPs7r0AadaaRH6c7CWKCKGtUtAlt0KrfSmdBvWe2XLnE2EMw0r5uh7Xtw+UfhLNAQ YVKewSSh8AMRbe9k7KpTK7WzomSqkI5qpWrKnAq1IQYCGQfpcXlpjM4HTdU/tt+wNtaR IF+qLChIE9FN0bQaDJJfWC61kohRQagESJ0GPUaAftJchpSXmGzjLQiyVEPSKYnBzdWi D3s6q0huQyE55zNF2soxMG8r8uxm4tzkoguPNUgiOKJpcwSUMGsuufMvGEP+B+02ynfb HlNw== 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=ChLAjYvGxdpquRVo7eFXQX11v8cvxG9nCL6xs/k6Nkc=; b=WIm791ZlrfRz+yFT+4uMnA93JJgu+gTPAhg28rHBcez9fxoYJSqmhDgo1jNctKsh5f c1hW3JNMHfntcarL5Z0jLnQMUuRiJcTCQjLYMd1ZhPqLF9hSABoC9FKs4GtD/TWC/5rg nOPpc43A5E6hUajnwcbcJWaRvie9hDpgn8Bfh+vCR94vjHOauMT/6SgqgzwWD818239r 683J0EGoAdtKMzfC5AAk9PD0EjJRLlLLivqHCJkKMxqV8jdd0+KkrRzUx/qgCfBBZPaI Cxi1sB0zUF7K9IRT4o0WpzgJgIoV+lkHmjX0r2pDAXN3NzYH+2g0RyzoTUCoesSdCShW y9wA== X-Gm-Message-State: AOAM530qr/fp86TSYVJ0JJLyqydqmfanSWBSRhvjxyxnUwykiu0DNCMH mFS1X7jT09uaoUk5tdglmBLj8fyI6EU= X-Google-Smtp-Source: ABdhPJyYb0iVxR8Yicr0Ew44rgRV079dSn/5HRnZVQVQ0AgHpARzxO1uJKQZIM+yvGZHwcCoJCWqSg== X-Received: by 2002:a1c:e0d4:: with SMTP id x203mr3616983wmg.68.1609248429894; Tue, 29 Dec 2020 05:27:09 -0800 (PST) Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id r7sm3490967wmh.2.2020.12.29.05.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Dec 2020 05:27:08 -0800 (PST) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Stefan Monnier Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> Date: Tue, 29 Dec 2020 13:27:05 +0000 In-Reply-To: <8735zpjz64.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Mon, 28 Dec 2020 23:20:19 +0000") Message-ID: <87ft3oivyu.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > Stefan Monnier writes: > >>> I think this elimination of consecutive `any' should also be included in >>> Jo=C3=A3o=E2=80=99s branch. >> >> I just pushed (a rewrite of) that change to `master`. > > And I just pushed my cleaned up fix to to master as well, thus hopefully > fixing the brunt of this bug. Dario and others, please test this. I > haven't yet pushed the tests, since we're not entirely sure of those, > but I think we should break them up further and push them too, once we > come to an aggreement on what and how they should test exactly. Meanwhile, I found that the patch after my sig fixes the remaining two Dario tests, concerning the presumed misplacement of 'completions-first-difference. I hadn't touched this part explicitly, and it doesn't seem to make a world of difference, so I'll leave it up to you two if we should isntall something like this or not. (I do think some form of tests should go in). I'll put this bit of patch in the side branch scratch/bug-42149-funny-pcm-completion-scores, too Jo=C3=A3o diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index dc37c5f447..074d436b35 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3332,11 +3332,12 @@ completion-pcm--hilit-commonality ;; for that extra bit of match (bug#42149). (unless (=3D from match-end) (funcall update-score-and-face from match-end)) - (if (> (length str) pos) - (add-face-text-property - pos (1+ pos) - 'completions-first-difference - nil str)) + (cl-loop for p from pos below (length str) + unless (eq (get-text-property p 'face str) + 'completions-common-part) + return (add-face-text-property p (1+ p) + 'completions-first-diff= erence + nil str)) (unless (zerop (length str)) (put-text-property 0 1 'completion-score From debbugs-submit-bounces@debbugs.gnu.org Thu May 13 05:24:51 2021 Received: (at 42149) by debbugs.gnu.org; 13 May 2021 09:24:51 +0000 Received: from localhost ([127.0.0.1]:41327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lh7aN-0006VT-F5 for submit@debbugs.gnu.org; Thu, 13 May 2021 05:24:51 -0400 Received: from quimby.gnus.org ([95.216.78.240]:40046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lh7aL-0006VE-6b for 42149@debbugs.gnu.org; Thu, 13 May 2021 05:24:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YI8h/2EawNH5XOdCQOD3fIupejgnErq4arxWYuc+rto=; b=JWxX0Wp/RY3HbTxlYLzBJgnGrG Grzopc444UDMd2/Q5vB/MR2mJjser07guVBgXf/xsMEHRKo2rmbkJ4ZoEfu7qNIAEz2NB7PqN5YjB m8TRkMuKnv9nv8HFnaVDAL9/RKJDNn9YNVozSk++1LMvf2mWpLKuemjwtnvdR3+Y5cf4=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lh7aC-0002FA-I4; Thu, 13 May 2021 11:24:42 +0200 From: Lars Ingebrigtsen To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> X-Now-Playing: Chrome Hoof's _Pre-Emptive False Rapture_: "Circus 9000" Date: Thu, 13 May 2021 11:24:39 +0200 In-Reply-To: <8735zpjz64.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Mon, 28 Dec 2020 23:20:19 +0000") Message-ID: <877dk3rnoo.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: João Távora writes: > And I just pushed my cleaned up fix to to master as well, thus hopefully > fixing the brunt of this bug. Dario and others, please test this. I > haven't yet pushed the tests, since we're not entirel [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > And I just pushed my cleaned up fix to to master as well, thus hopefully > fixing the brunt of this bug. Dario and others, please test this. I > haven't yet pushed the tests, since we're not entirely sure of those, > but I think we should break them up further and push them too, once we > come to an aggreement on what and how they should test exactly. I've only skimmed this long thread, but my understanding of it is that the reported bug was fixed... but there was some discussion about including (or not) Dario's tests? Which (if I'm grepping correctly) would be the patch below? I tried applying it, and: 2 unexpected results: FAILED completion-pcm-all-completions-test FAILED completion-substring-all-completions-test I have not looked into this further -- Jo=C3=A3o, what's the state here? diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 5da86f3614..a473fec441 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -104,5 +104,132 @@ nil (length input)) (cons output (length output))))))) =20 +(ert-deftest completion-pcm-all-completions-test () + ;; Point is at end, this does not match anything + (should (equal + (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 3) + nil)) + ;; Point is at beginning, this matches "barfoobar" + (should (equal + (car (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 0)) + "barfoobar")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; One fourth of a match and no match due to point being at the end + (should (eql + (get-text-property + 0 'completion-score + (car (completion-pcm-all-completions + "RO" '("RaOb") nil 1))) + (/ 1.0 4.0))) + (should (equal + (completion-pcm-all-completions + "RO" '("RaOb") nil 2) + nil)) + ;; Point is at beginning, but `completions-first-difference' is + ;; moved after it + (should (equal + (get-text-property + 1 'face + (car (completion-pcm-all-completions + "f" '("few" "many") nil 0))) + 'completions-first-difference)) + ;; Wildcards and delimiters work + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("list-packages") nil 7)) + "list-packages")) + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("do-not-list-packages") nil 7)) + nil))) + +(ert-deftest completion-substring-all-completions-test () + ;; One third of a match! + (should (equal + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)) + "barfoobar")) + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3))) + (/ 1.0 3.0))) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-substring-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Substring match + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 4)) + "customize-group")) + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 5)) + nil)) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-substring-all-completions + "jab" '("dabjobstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 1))) + 'completions-first-difference)) + (should (equal + (get-text-property + 6 'face + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 3))) + 'completions-first-difference))) + +(ert-deftest completion-flex-all-completions-test () + ;; Fuzzy match + (should (equal + (car (completion-flex-all-completions + "foo" '("hello" "world" "fabrobazo") nil 3)) + "fabrobazo")) + ;; Full match! + (should (eql + (get-text-property + 0 'completion-score + (car (completion-flex-all-completions + "R" '("R" "hello") nil 1))) + 1.0)) + ;; Another fuzzy match, but more of a "substring" one + (should (equal + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4)) + "customize-group-other-window")) + ;; `completions-first-difference' should be at the right place + (should (equal + (get-text-property + 4 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4))) + 'completions-first-difference)) + (should (equal + (get-text-property + 15 'face + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 9))) + 'completions-first-difference))) + --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu May 13 10:31:40 2021 Received: (at 42149) by debbugs.gnu.org; 13 May 2021 14:31:41 +0000 Received: from localhost ([127.0.0.1]:44039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhCNI-00051J-Iz for submit@debbugs.gnu.org; Thu, 13 May 2021 10:31:40 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]:34444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhCNG-000514-3m for 42149@debbugs.gnu.org; Thu, 13 May 2021 10:31:38 -0400 Received: by mail-wm1-f52.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso1031104wmc.1 for <42149@debbugs.gnu.org>; Thu, 13 May 2021 07:31:38 -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=Pb6mluQgfRMUCZctE8kGcqyrqTj/J2MropToEcv6f3U=; b=VPn/J3k/GyaGmEha7T2YDpqvXdaMs7uZDD7x2ilfpZhMA8jPM7ROzVibDoLw5dSDQ3 vbUrs5jhIrGUeFUnhSzOQO0iTjp5Sd88PIywgDzeMvWmMU4kBMRPHes2xk/jv+MsY4f8 1Wx2BKw3N/Fum5dORNqqfr5L55Jsjx77ldhHEquNSEghZ5I2SQ5NSvrwD0kUeG4RBkEO YtIqJqP0PAU3jvKSDr0j3nzIi7+iyadts5duz0N0fOkCTDJDLHLpbIEHpjqzgS2tF0a8 5KcIaCnEWBzkwC1u2ib9VWlgdJXlDc6gfXQDROdo83CH/MulnIU4paNAGquR6O+zfQLt 9AEg== 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=Pb6mluQgfRMUCZctE8kGcqyrqTj/J2MropToEcv6f3U=; b=Zz8TlTNsh4y1yH3tc78CZxEL37wm7J4jzWTfTOr550HNB6tW/cV7X8m3ILb/hTxCho c4cYikap5M+3VrpdwXyjfvsxjlDAciq9n6g4YsfwYWOxY4ZmzHc68y6sA+vDj64juhW4 FFidpVAUDysoUzKqvdhkb2TnEc/iT4garUxM+4Jtv1edWDyyr2xvLy5tqe1XNtB+6SHo fxqszZB9gRkUnSsDSE7CS4QcqWAw2msU5MT+hxCXrP8iKC9nt/NGWDbk8oH5KiUASxor EDkOOdP/s2BOj4XieNcB0umOIPNg5tgx1h1DatR5tk1Ju958Az2jOKPBq2P5DHiKb7t2 G07Q== X-Gm-Message-State: AOAM533Dh7BAxNPeTLne4G0ikVovrdQadBrqEPoIjnKO8BnwTKHwmF9e q4apRDpRzbxH4nzE8iH4kkI= X-Google-Smtp-Source: ABdhPJybWqR1dkYElr7LwNpOAfdhsxRJiLqbqm60nTRbt0+2iwRkZd7ScYBdEAFpu9U8fKW2x1LKtg== X-Received: by 2002:a05:600c:4242:: with SMTP id r2mr4131189wmm.140.1620916292261; Thu, 13 May 2021 07:31:32 -0700 (PDT) Received: from krug ([89.180.156.166]) by smtp.gmail.com with ESMTPSA id v12sm3238724wrv.76.2021.05.13.07.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 07:31:31 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Lars Ingebrigtsen Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> <877dk3rnoo.fsf@gnus.org> Date: Thu, 13 May 2021 15:31:29 +0100 In-Reply-To: <877dk3rnoo.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 13 May 2021 11:24:39 +0200") Message-ID: <87im3maeny.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Lars Ingebrigtsen writes: > Jo=C3=A3o T=C3=A1vora writes: > >> And I just pushed my cleaned up fix to to master as well, thus hopefully >> fixing the brunt of this bug. Dario and others, please test this. I >> haven't yet pushed the tests, since we're not entirely sure of those, >> but I think we should break them up further and push them too, once we >> come to an aggreement on what and how they should test exactly. > > I've only skimmed this long thread, but my understanding of it is that > the reported bug was fixed... but there was some discussion about > including (or not) Dario's tests? > > Which (if I'm grepping correctly) would be the patch below? I tried > applying it, and: > > 2 unexpected results: > FAILED completion-pcm-all-completions-test > FAILED completion-substring-all-completions-test > > I have not looked into this further -- Jo=C3=A3o, what's the state here? I think you applied the original patch of two failing tests, the tests that demonstrate a particular bug. So it makes sense that hey fail. I think we want to merge what's in the scratch/bug-42149-funny-pcm-completion-scores. I attach a summary of the four commtis there. Then we want to close this issue. Not sure if it's merged yet, but I don't think so. I was waiting for Dario's comments on it, they never arrived, but I'm veryq confident that this fixes the issues reported here. There are 4 commits there. And if you merge this branch, _don't_ also try to merge the patch you tried earlier: the branch already contains a rewrite of those tests. Jo=C3=A3o commit 03c160fb1573107586355e851c111326debfe95a Author: Jo=C3=A3o T=C3=A1vora Date: Tue Dec 29 13:31:46 2020 +0000 Fix "first-differente" face in completion-pcm--hilit-commonality =20=20=20=20 Fixes: bug#42149 =20=20=20=20 Depending on the position of point in the completion and the completion style being used, it may or may not make sense for this face to appear immediately after point. This patch assumes that it should appear in the first non-matched character after point, which may likely be the next one to type to disambiguate between two or more completions. =20=20=20=20 Suggested by Dario Gjorgjevski . =20=20=20=20 * lisp/minibuffer.el (completion-pcm--hilit-commonality): Fix occasional misplacement of completions-first-differente. commit d8c596f7309bd6fd6e127b8027dfb4c508afd2ea Author: Jo=C3=A3o T=C3=A1vora Date: Mon Dec 28 09:10:19 2020 +0000 Robustify a helper function for test/lisp/minibuffer-tests.el =20=20=20=20 completion--pcm-first-difference-pos wasn't taking into account the fact that faces may come in lists. bug#42149 =20=20=20=20 * test/lisp/minibuffer-tests.el (completion--pcm-first-difference-pos): Robustify. commit d333ec4cabd21244e5ee468b3a7475fa2dcbe614 Author: Jo=C3=A3o T=C3=A1vora Date: Tue Nov 24 23:15:40 2020 +0000 Make a completion test robust to custom completion styles =20=20=20=20 * test/lisp/minibuffer-tests.el (completion-test1): Make test resilient to more completion styles. commit 0265a99ed6b035930fdb21d5bcfdab0707b303aa Author: Jo=C3=A3o T=C3=A1vora Date: Tue Nov 24 22:34:22 2020 +0000 Add tests for bug#42149 =20=20=20=20 * test/lisp/minibuffer-tests.el (completion--pcm-score) (completion--pcm-first-difference-pos): New helpers. (completion-pcm-test-1, completion-pcm-test-2) (completion-pcm-test-3, completion-pcm-test-4) (completion-pcm-test-5, completion-pcm-test-6) (completion-substring-test-1, completion-substring-test-2) (completion-substring-test-3, completion-substring-test-4) (completion-flex-test-1, completion-flex-test-2) (completion-flex-test-3): New tests. =20=20=20=20 Co-authored-by: Dario Gjorgjevski Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Thu May 13 11:42:10 2021 Received: (at 42149) by debbugs.gnu.org; 13 May 2021 15:42:10 +0000 Received: from localhost ([127.0.0.1]:44156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhDTV-0006l3-MF for submit@debbugs.gnu.org; Thu, 13 May 2021 11:42:10 -0400 Received: from mail-wr1-f51.google.com ([209.85.221.51]:41868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhDTO-0006kT-4X for 42149@debbugs.gnu.org; Thu, 13 May 2021 11:42:08 -0400 Received: by mail-wr1-f51.google.com with SMTP id d11so27313436wrw.8 for <42149@debbugs.gnu.org>; Thu, 13 May 2021 08:42:02 -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; bh=+tufT/V+qLhxBckbndT8+ahPE4D+9lyo86jrzd1AOGc=; b=vhA/OtIKOsh9eOTyAGXOdVSeZDVA+dh3ulSJm86sj8POtf8eY1vwyNIPbZv7csc9ZO G1dZRYq8nI0aoB5bMijlqrWN3xFC7bekvRnJigfxwxiccxMqoFSpmN7NQxuQtOg0whQr iOHBz9+fSHrYaeVBbhHCBKz5fLkHtbXxz5iDdigwXo9bVVB0v7Sqv3DLDKH+BNhS7PA8 RNJUxl+Ere4CZSPnZ5hIinR15Ythk3o3wg07tVApGjYjl6uQxp3Qy2ynoi0vw5PjWldY pNiiuA1yluMuNyinpTYA0PaDGyW5iZ0HytGrpF0OxiFpRLQwaRcemYzVqS8N5mJKCXKG 7QlQ== 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; bh=+tufT/V+qLhxBckbndT8+ahPE4D+9lyo86jrzd1AOGc=; b=AIuEGNlS/nhaP8JT9BKguB2NYrr78HS6TRgvA5yZIWvpLPUOPGlWebteyG2KvTTuG9 qm2xRm8zxbrNwb5604BTPwf3TXB+VnOZAnLSE/XrEoMjrTCrJjwv0pCPCQH0uh/1lQra sDdNDb7BoN1keW9RXxg7SoefOVs7m1a2MLZQueu1P8NUenaWvc1345ZqfdmkZJuFxev2 T2L1yOyoJEoZWPiR1QGS9X3F6B+TzEzKAV+bfwgwmtwvYdHAa8t9ZnKJocbWcsra+xbc Qasv0OCMW+LvmilSQzWSf09BN4SpbRxklmp2NA2mzaB7GPZSo4tJWVU6aTi880iOBu/V Okmg== X-Gm-Message-State: AOAM5336G2pTshjaQtK3AVal4SwLMdSTX4hIA1p7A0Ae4B0DMVMyPyW+ QQl405d8YiXvzR1LGAkFQEyw96AydxqXMw== X-Google-Smtp-Source: ABdhPJxNne9UFJFykdlun1O9V7rXCEc8aHK4n67x4KWWTimn344X+//+omSNd9hLH2vekp9duJoJnA== X-Received: by 2002:a5d:6811:: with SMTP id w17mr53666466wru.348.1620920516361; Thu, 13 May 2021 08:41:56 -0700 (PDT) Received: from ZALANDO-31298 ([79.140.114.107]) by smtp.gmail.com with ESMTPSA id y21sm9200839wmi.15.2021.05.13.08.41.55 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 May 2021 08:41:55 -0700 (PDT) From: Dario Gjorgjevski To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <87sgbsv7gg.fsf@gmail.com> <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> <877dk3rnoo.fsf@gnus.org> <87im3maeny.fsf@gmail.com> Date: Thu, 13 May 2021 17:41:54 +0200 In-Reply-To: <87im3maeny.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Thu, 13 May 2021 15:31:29 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Lars Ingebrigtsen , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hi, > Not sure if it's merged yet, but I don't think so. I was waiting for > Dario's comments on it, they never arrived, but I'm veryq confident that > this fixes the issues reported here. Sorry, I kind of forgot about this. The bug itself was fixed by commit d199a46, it is only the test that have not been merged yet. The tests that fail are the ones related to completions-first-difference, which, we agreed should be left as it is. Therefore, those tests need to be changed. (This also applies to the scratch/bug-42149-funny-pcm-completion-scores branch.) Here is a patch with the fixed tests: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Add-tests-for-bug-42149.patch Content-Transfer-Encoding: quoted-printable Content-Description: Add tests for bug#42149 >From 215ac5b9c55670435b69fa92d6124d0c7bf9b5a3 Mon Sep 17 00:00:00 2001 From: Dario Gjorgjevski Date: Thu, 13 May 2021 17:29:13 +0200 Subject: [PATCH] Add tests for bug#42149 MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * test/lisp/minibuffer-tests.el (completion--pcm-score) (completion--pcm-first-difference-pos): New helpers. (completion-pcm-test-1, completion-pcm-test-2) (completion-pcm-test-3, completion-pcm-test-4) (completion-pcm-test-5, completion-pcm-test-6) (completion-substring-test-1, completion-substring-test-2) (completion-substring-test-3, completion-substring-test-4) (completion-flex-test-1, completion-flex-test-2) (completion-flex-test-3): New tests. Co-authored-by: Jo=C3=A3o T=C3=A1vora --- test/lisp/minibuffer-tests.el | 143 ++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 6ab5f57eff..c3ba8f9a92 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -188,5 +188,148 @@ '("some/alpha" "base/epsilon" "base/delta")) `("epsilon" "delta" "beta" "alpha" "gamma" . 5)))) =20 +(defun completion--pcm-score (comp) + "Get `completion-score' from COMP." + (get-text-property 0 'completion-score comp)) + +(defun completion--pcm-first-difference-pos (comp) + "Get `completions-first-difference' from COMP." + (cl-loop for pos =3D (next-single-property-change 0 'face comp) + then (next-single-property-change pos 'face comp) + while pos + when (eq (get-text-property pos 'face comp) + 'completions-first-difference) + return pos)) + +(ert-deftest completion-pcm-test-1 () + ;; Point is at end, this does not match anything + (should (null + (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)))) + +(ert-deftest completion-pcm-test-2 () + ;; Point is at beginning, this matches "barfoobar" + (should (equal + (car (completion-pcm-all-completions + "foo" '("hello" "world" "barfoobar") nil 0)) + "barfoobar"))) + +(ert-deftest completion-pcm-test-3 () + ;; Full match! + (should (eql + (completion--pcm-score + (car (completion-pcm-all-completions + "R" '("R" "hello") nil 1))) + 1.0))) + +(ert-deftest completion-pcm-test-4 () + ;; One fourth of a match and no match due to point being at the end + (should (eql + (completion--pcm-score + (car (completion-pcm-all-completions + "RO" '("RaOb") nil 1))) + (/ 1.0 4.0))) + (should (null + (completion-pcm-all-completions + "RO" '("RaOb") nil 2)))) + +(ert-deftest completion-pcm-test-5 () + ;; Since point is at the beginning, there is nothing that can really + ;; be typed anymore + (should (null + (completion--pcm-first-difference-pos + (car (completion-pcm-all-completions + "f" '("few" "many") nil 0)))))) + +(ert-deftest completion-pcm-test-6 () + ;; Wildcards and delimiters work + (should (equal + (car (completion-pcm-all-completions + "li-pac*" '("list-packages") nil 7)) + "list-packages")) + (should (null + (car (completion-pcm-all-completions + "li-pac*" '("do-not-list-packages") nil 7))))) + +(ert-deftest completion-substring-test-1 () + ;; One third of a match! + (should (equal + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3)) + "barfoobar")) + (should (eql + (completion--pcm-score + (car (completion-substring-all-completions + "foo" '("hello" "world" "barfoobar") nil 3))) + (/ 1.0 3.0)))) + +(ert-deftest completion-substring-test-2 () + ;; Full match! + (should (eql + (completion--pcm-score + (car (completion-substring-all-completions + "R" '("R" "hello") nil 1))) + 1.0))) + +(ert-deftest completion-substring-test-3 () + ;; Substring match + (should (equal + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 4)) + "customize-group")) + (should (null + (car (completion-substring-all-completions + "custgroup" '("customize-group") nil 5))))) + +(ert-deftest completion-substring-test-4 () + ;; `completions-first-difference' should be at the right place + (should (eql + (completion--pcm-first-difference-pos + (car (completion-substring-all-completions + "jab" '("dabjobstabby" "many") nil 1))) + 4)) + (should (null + (completion--pcm-first-difference-pos + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 1))))) + (should (equal + (completion--pcm-first-difference-pos + (car (completion-substring-all-completions + "jab" '("dabjabstabby" "many") nil 3))) + 6))) + +(ert-deftest completion-flex-test-1 () + ;; Fuzzy match + (should (equal + (car (completion-flex-all-completions + "foo" '("hello" "world" "fabrobazo") nil 3)) + "fabrobazo"))) + +(ert-deftest completion-flex-test-2 () + ;; Full match! + (should (eql + (completion--pcm-score + (car (completion-flex-all-completions + "R" '("R" "hello") nil 1))) + 1.0))) + +(ert-deftest completion-flex-test-3 () + ;; Another fuzzy match, but more of a "substring" one + (should (equal + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4)) + "customize-group-other-window")) + ;; `completions-first-difference' should be at the right place + (should (equal + (completion--pcm-first-difference-pos + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 4))) + 4)) + (should (equal + (completion--pcm-first-difference-pos + (car (completion-flex-all-completions + "custgroup" '("customize-group-other-window") nil 9))) + 15))) + (provide 'minibuffer-tests) ;;; minibuffer-tests.el ends here --=20 2.31.GIT --=-=-= Content-Type: text/plain Once the tests are merged, I suppose the scratch/bug-42149-funny-pcm-completion-scores branch can safely be deleted. Best regards, -- Dario Gjorgjevski Key fingerprint = F7C3 734D 2381 DAEB 4C6D 9CF7 744A 4F0B 4F1C 9371 $ gpg --keyserver hkps://hkps.pool.sks-keyservers.net \ --search-keys 744A4F0B4F1C9371 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu May 13 12:04:38 2021 Received: (at 42149) by debbugs.gnu.org; 13 May 2021 16:04:38 +0000 Received: from localhost ([127.0.0.1]:44167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhDpG-0007In-7a for submit@debbugs.gnu.org; Thu, 13 May 2021 12:04:38 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:37628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhDpE-0007IV-0e for 42149@debbugs.gnu.org; Thu, 13 May 2021 12:04:36 -0400 Received: by mail-wr1-f49.google.com with SMTP id q5so7937051wrs.4 for <42149@debbugs.gnu.org>; Thu, 13 May 2021 09:04:36 -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=XXsUYapPZ7yTzw7AyJfuDYdB1w6X4SUIDa619JRE3Ow=; b=nAhirRdjO2QoufLsfO5AWjHOxzNTF6KavKcXbi9bUVgDZs1L/xYtPuu3DhIWphE3l3 dcIOtU0U+Nj634R2caHD/wBwOmc7bLXU59rymh2i/0f5NBhPAgLkszgxFxjQfSJTt26A 2kKnLN8TqEBUSEQGrwTsTsUspzyS4t8u8ztUHmHeqodbjq8MpIkxYCVJ41v/3WxSy0CQ 7cqMz7otQyV9PBCXr3InWUx78QNs7yMzpWbM+74RHQYghxWqdN5LFWth5SG4nzd321h8 LjxNIWu87/KbnNg68QcWQ2yJW4mmLurC9xGrZcChc9TjuTa5m2LEcKeINuuY9TYL4Bba MW5A== 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=XXsUYapPZ7yTzw7AyJfuDYdB1w6X4SUIDa619JRE3Ow=; b=cxzLLuPRhXqUefbrEtClp3VBt2fK/wT1Y25ZWuMmql69WEsusT8eZpvwN89pwPwv7J dTYkOxxAZFcP3cDj1XHogglwYxfqQ4+lCgp7gfby0rqmQYsvfsBO8euG7ufe69KfYOLi IQJAEFOxqudqJX1iBM95XFb67e+etYPt6rJGekaozDMMvedqvbEsFs2SqpGN2p3i5XGH C7d89dJR2s5qBM8Q/sFirYGDbo+4Y56h80mlVywhPTNOlE+sXahaCfIMvcYJ1gRvJXyz Wx5hEuWbz74YelRS821NaLyVenPHkotewosIFz8vh8WCVbEe+UBd1BETFl3WYOUZ8vuM qLyQ== X-Gm-Message-State: AOAM530qXWpnb7C6v4APx87UiW6zFFw21MjWVVcjnyN3rVGouNd+wmPT Wb/gAeI0WZu+kzTj1PpYF0p0KE5wg5A= X-Google-Smtp-Source: ABdhPJzfFFNTdNxD8c9afKQFI46UIEg25z0vm0yLwC/8a0XO78LqTn8/0TAcoI17puIf2+/CPnDTZg== X-Received: by 2002:adf:e291:: with SMTP id v17mr52315550wri.149.1620921869870; Thu, 13 May 2021 09:04:29 -0700 (PDT) Received: from krug ([89.180.156.166]) by smtp.gmail.com with ESMTPSA id m11sm3199246wri.44.2021.05.13.09.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 May 2021 09:04:29 -0700 (PDT) From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= To: Dario Gjorgjevski Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> <877dk3rnoo.fsf@gnus.org> <87im3maeny.fsf@gmail.com> Date: Thu, 13 May 2021 17:04:28 +0100 In-Reply-To: (Dario Gjorgjevski's message of "Thu, 13 May 2021 17:41:54 +0200") Message-ID: <87eeeaaacz.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Lars Ingebrigtsen , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dario Gjorgjevski writes: > Hi, > >> Not sure if it's merged yet, but I don't think so. I was waiting for >> Dario's comments on it, they never arrived, but I'm veryq confident that >> this fixes the issues reported here. > > Sorry, I kind of forgot about this. The bug itself was fixed by commit > d199a46, it is only the test that have not been merged yet. Oh, so it is merged (or rather rebased). Thanks for checking, Dario. Then I guess this can be closed after merging this patch, which I suppose is a variation on one of the test commits I presented before. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sun May 16 09:51:37 2021 Received: (at 42149) by debbugs.gnu.org; 16 May 2021 13:51:37 +0000 Received: from localhost ([127.0.0.1]:49892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1liHBB-0007jj-Bi for submit@debbugs.gnu.org; Sun, 16 May 2021 09:51:37 -0400 Received: from quimby.gnus.org ([95.216.78.240]:47064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1liHB9-0007jS-TZ for 42149@debbugs.gnu.org; Sun, 16 May 2021 09:51:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=r4jmvafu2o/zdybMKtyud7qC0DkkoZxG4IF2oR9cwq0=; b=kV1Bu6mcUQNvgFMGcC32ehehKV DKKn6ihaQN1IwatgVB38vhHwxS2fKCliQOGNV3IJ53ELtNoPb/QK7T/JMTIieW40LoU7hG24/fhtR 5cJgAkCtgGLKThFed+z9IdORysLiLUtjHTJa+jeVNkyT1ro1B1m7kgFVrI9rs/Q6bXys=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1liHB1-0007W7-L9; Sun, 16 May 2021 15:51:29 +0200 From: Lars Ingebrigtsen To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#42149: Substring and flex completion ignore implicit trailing =?utf-8?B?4oCYYW554oCZ?= References: <877dp1kfzz.fsf@gmail.com> <8735zpjz64.fsf@gmail.com> <877dk3rnoo.fsf@gnus.org> <87im3maeny.fsf@gmail.com> <87eeeaaacz.fsf@gmail.com> X-Now-Playing: Rocketnumbernine's _Meyouweyou_: "Lope" Date: Sun, 16 May 2021 15:51:27 +0200 In-Reply-To: <87eeeaaacz.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Thu, 13 May 2021 17:04:28 +0100") Message-ID: <871ra6pz1c.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: João Távora writes: > Then I guess this can be closed after merging this patch, which I suppose > is a variation on one of the test commits I presented before. OK; I've now pushed Dario's latest patch (i.e., the additional tests), and I'm closing this bug report. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 42149 Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > Then I guess this can be closed after merging this patch, which I suppose > is a variation on one of the test commits I presented before. OK; I've now pushed Dario's latest patch (i.e., the additional tests), and I'm closing this bug report. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sun May 16 09:51:47 2021 Received: (at control) by debbugs.gnu.org; 16 May 2021 13:51:47 +0000 Received: from localhost ([127.0.0.1]:49895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1liHBL-0007k6-Iq for submit@debbugs.gnu.org; Sun, 16 May 2021 09:51:47 -0400 Received: from quimby.gnus.org ([95.216.78.240]:47080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1liHBJ-0007jt-Sw for control@debbugs.gnu.org; Sun, 16 May 2021 09:51:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=U0nVcwwbwtfwfjY3747bbOXASVyDQURqAwfMDllVwzE=; b=QrT4iYDQvWvBZD8oEKR9k5AyML O7DzJPkmCKMgMMZGTNmi/JUahdCW4ipmlWNYynE5qUE/b4KL4ujsfVNnYBxQ4KW8ruoruupF/CJJX 6k7FXyoIAqR27HxNXG1ZiQ3kA0/0gwABvMmjjVjTzWcvJnNKKyP1BPNNIthslB2q+X1o=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1liHBC-0007WK-2U for control@debbugs.gnu.org; Sun, 16 May 2021 15:51:40 +0200 Date: Sun, 16 May 2021 15:51:37 +0200 Message-Id: <87zgwuokgm.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #42149 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 42149 fixed close 42149 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 42149 fixed close 42149 28.1 quit From unknown Sat Jun 21 10:25:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 14 Jun 2021 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator