From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dario Gjorgjevski Newsgroups: gmane.emacs.bugs Subject: bug#42149: Substring and flex completion ignore implicit trailing =?UTF-8?Q?=E2=80=98any=E2=80=99?= Date: Wed, 01 Jul 2020 12:40:42 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="466"; mail-complaints-to="usenet@ciao.gmane.io" To: 42149@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 01 12:41:15 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jqaB0-000Aaq-7P for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jul 2020 12:41:14 +0200 Original-Received: from localhost ([::1]:46032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqaAz-00046f-A4 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jul 2020 06:41:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqaAs-00046R-23 for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:41:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqaAn-0000Sz-Pp for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:41:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jqaAn-0003S9-OE for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 06:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dario Gjorgjevski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Jul 2020 10:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42149 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.159360005213249 (code B ref -1); Wed, 01 Jul 2020 10:41:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Jul 2020 10:40:52 +0000 Original-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 Original-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 Original-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 Original-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 Original-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) Original-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) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182594 Archived-At: --=-=-= 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' --=-=-=--