From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 11 12:44:42 2025 Received: (at submit) by debbugs.gnu.org; 11 Aug 2025 16:44:42 +0000 Received: from localhost ([127.0.0.1]:49954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ulVdY-0002hO-LV for submit@debbugs.gnu.org; Mon, 11 Aug 2025 12:44:41 -0400 Received: from lists.gnu.org ([2001:470:142::17]:54644) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ulVdR-0002gz-Iq for submit@debbugs.gnu.org; Mon, 11 Aug 2025 12:44:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ulVdJ-0007vw-2I for bug-gnu-emacs@gnu.org; Mon, 11 Aug 2025 12:44:25 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ulVdA-000678-A0 for bug-gnu-emacs@gnu.org; Mon, 11 Aug 2025 12:44:22 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: [PATCH] Insert * on TAB with completion-pcm-leading-wildcard=t X-Debbugs-CC: Stefan Monnier , Dmitry Gutov Date: Mon, 11 Aug 2025 12:44:12 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1754930652; bh=2nF7dXJmiXMPbe1n0zrrJv9CX+hEHLH7THL1BRaxEkY=; h=From:To:Subject:Date; b=3F8ZVbWRjeSBUk5zLJNtCoV4Ym/Y4VjJjWaoD+aHNaDCo1+Rjw/bavrnSJyJx+OvM 6KhUj90PVEIsMr/I0plHWNPCOd9AmDt3OoC/PamBikEHv78p0xS+n0onAGFjhKVD0Q p5483I74MMlfa5V1OeWc7/iJX1IaqCrRY3FcGerMEHpzn0dZ4SIMJMsaenDGvKn+TS UKI1fLvtostcu/cfcHIrcQGVfqjtPkjnhB2ye3a7gn7clXiGnpcUw2BWJylu/2Tdzp UrDiTAHoElhMiz3mSWXBCCrIv+sb+i0+B7LZ7vJVm7DiiBZXbpBsfOFTQpP/OR7OV9 6Gc2MmBPKmmpw== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) 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: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Improve completion-pcm-leading-wildcard by actually inserting a * when try-completion runs. completion-pcm--merge-try will automatically remove the wildcard anywhere that it has no matches, so the * is inserted only where it actually had an effect. This makes the behavior more explicit and consistent, and improves performance in the case where completion-styles is configured such that we first do partial-completion with completion-pcm-leading-wildcard=nil, and then fall back to completion-pcm-leading-wildcard=t: explicitly inserting the * avoids the need to fallback. My site has been running with this patch for 4 months now and it's worked fine. In my experience it's very useful. In GNU Emacs 30.1.90 (build 14, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2025-08-11 built on igm-qws-u22796a Repository revision: 2828c98aa29c66798fcb3fa67ccc3ed706024340 Repository branch: emacs-30 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --with-x-toolkit=lucid --without-gpm --without-gconf --without-gsettings --without-selinux --without-imagemagick --with-modules --with-gif=no --with-cairo --with-rsvg --without-compress-install --with-tree-sitter --with-native-compilation=aot PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Insert-on-TAB-with-completion-pcm-leading-wildcard-t.patch >From 0c13bd0b3de0cd7f2f06e304cf7d578f93fe4343 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 9 Apr 2025 14:01:05 -0400 Subject: [PATCH] Insert * on TAB with completion-pcm-leading-wildcard=t Improve completion-pcm-leading-wildcard by actually inserting a * when try-completion runs. completion-pcm--merge-try will automatically remove the wildcard anywhere that it has no matches, so the * is inserted only where it actually had an effect. This makes the behavior more explicit and consistent, and improves performance in the case where completion-styles is configured such that we first do partial-completion with completion-pcm-leading-wildcard=nil, and then fall back to completion-pcm-leading-wildcard=t: explicitly inserting the * avoids the need to fallback. * lisp/minibuffer.el (completion-pcm--string->pattern): Add 'star wildcard, not just 'prefix. --- lisp/minibuffer.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 1d1e07faf70..632e111ecc8 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -4197,7 +4197,7 @@ completion-pcm--string->pattern (setq p0 p) (push (substring string p (match-end 0)) pattern) ;; `any-delim' is used so that "a-b" also finds "array->beginning". - (setq pending (if completion-pcm-leading-wildcard 'prefix 'any-delim)) + (setq pending (if completion-pcm-leading-wildcard 'star 'any-delim)) (setq p0 (match-end 0)))) (setq p p0)) @@ -4207,7 +4207,7 @@ completion-pcm--string->pattern (setq pattern (nreverse pattern)) (when completion-pcm-leading-wildcard (when (stringp (car pattern)) - (push 'prefix pattern))) + (push 'star pattern))) pattern))) (defun completion-pcm--optimize-pattern (p) -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 14 21:34:40 2025 Received: (at 79219) by debbugs.gnu.org; 15 Aug 2025 01:34:40 +0000 Received: from localhost ([127.0.0.1]:35130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1umjL5-0005ma-Tn for submit@debbugs.gnu.org; Thu, 14 Aug 2025 21:34:40 -0400 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]:48037) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1umjL1-0005mH-Vs for 79219@debbugs.gnu.org; Thu, 14 Aug 2025 21:34:37 -0400 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id DD9D51D00094; Thu, 14 Aug 2025 21:34:29 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Thu, 14 Aug 2025 21:34:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1755221669; x=1755308069; bh=ghYv3WJPZPXSLyr7E1EGUla0vjCO+IdqPFPJnLsm37o=; b= Ds0vvuRijemFLHAPDRlNMndhw5jZaaPR65gzk4uaxTueEvKUJuKwZ9g4NV3quG6j cvTfaAfXtCQ7Q9SXfz1KJoocX/7844vquPaaGs6Hcd9ziGjAsu+38kQj6Qfum17j NxS0fgvIsB0jdvTlaMrTjbROLG6nf5B+wPdkHAq/4M+T3kncgV51Mun623tw5R7Y Y42mvFQE8fmYVAvl6bQ5WwyuBm5+3PH3MZey36LoiqP/b/8plcsrMYIOHbImm1Sr inseRoyTcrlGnK2/vWDgnyR4tuq640a90mbi0cs7ZC7E5XNNEi7FoHIRohPd9vb/ er5uEy8wtBuOUGurVdaRtA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1755221669; x= 1755308069; bh=ghYv3WJPZPXSLyr7E1EGUla0vjCO+IdqPFPJnLsm37o=; b=C hOvNATSQ1upA6LNMNuuYZjLVmT8WfWG7LD5NtM9hZxmdev/L+Izr7tgR188Z5eIT EuI598q0UMOqiRuYSLumky6hcxfwuZchHpRCWzatUozN4EJCAsI4RwcT21SUalMb bIc0Q4QezxBeyicCx5YitIqOvlgmoKLaMvwuAd3ZIKZ+fhW9m24LGsW3IATVsNYD 0c4t3CuqirX2x4Qrq1sfC6dCNvgKRKun4eO+4napFGp0VoJ6XPXZrK5g2+Szji++ RrkZmTXh1gMIvSh7kM0oi2Nim1w3XzsjTxjvutt9zlGPmMByi5zuyEuOVaNxjf5c WEvyuVPPhmumq1wxhhYpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddugedvieehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedujeeh necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmih htrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehssggruhhghhesjhgrnhgvshhtrhgvvghtrdgtohhmpdhrtg hpthhtohepjeelvdduleesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehm ohhnnhhivghrsehirhhordhumhhonhhtrhgvrghlrdgtrg X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 14 Aug 2025 21:34:27 -0400 (EDT) Message-ID: <6abb2c37-73b7-40d3-a416-7c5b9e4d9a6f@gutov.dev> Date: Fri, 15 Aug 2025 04:34:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#79219: [PATCH] Insert * on TAB with completion-pcm-leading-wildcard=t To: Spencer Baugh , 79219@debbugs.gnu.org References: Content-Language: en-US From: Dmitry Gutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 79219 Cc: 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.7 (-) Spencer, hi, On 11/08/2025 19:44, Spencer Baugh wrote: > Improve completion-pcm-leading-wildcard by actually inserting > a * when try-completion runs. completion-pcm--merge-try will > automatically remove the wildcard anywhere that it has no > matches, so the * is inserted only where it actually had an > effect. Would it be difficult to add a test for this? I can see that you authored some of most recent ones in minibuffer-tests.el, but completion-pcm-leading-wildcard does not seem to be exercised in our suite yet. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 18 15:01:42 2025 Received: (at 79219) by debbugs.gnu.org; 18 Aug 2025 19:01:42 +0000 Received: from localhost ([127.0.0.1]:51251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uo56z-0003sw-SV for submit@debbugs.gnu.org; Mon, 18 Aug 2025 15:01:42 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:42327) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uo56w-0003sd-Mu for 79219@debbugs.gnu.org; Mon, 18 Aug 2025 15:01:39 -0400 From: Spencer Baugh To: Dmitry Gutov Subject: Re: bug#79219: [PATCH] Insert * on TAB with completion-pcm-leading-wildcard=t In-Reply-To: <6abb2c37-73b7-40d3-a416-7c5b9e4d9a6f@gutov.dev> (Dmitry Gutov's message of "Fri, 15 Aug 2025 04:34:25 +0300") References: <6abb2c37-73b7-40d3-a416-7c5b9e4d9a6f@gutov.dev> Date: Mon, 18 Aug 2025 15:01:32 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1755543692; bh=3QWiM42GGOhHjXEjeOrvnn2VtP7VS2ZKOMGMyZIeuVc=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=DxB116cSH1NGDVl5pvvOtsrUn7F84z3Q2sMsjiCzqRIlcsVNqb4HKII0DSWIr8YrH Dm4h5yM1W2qkkafXgxQgU8k+bNRLITjuK5/U+Od6LxlrJ5jyRtxfYMgQlFHJ/3xweo ku9yvWR7K1b+z2SmvjtsY4Zq4qHRoxJ2m0RkNXV+XZdmDHja6GF3V1txTuWmh1hKEI KsxkOpV17ULRR/R3A2GN5ABLn9QcOe/1SFrMuvDcBGdp/F+XODsownmsLtXMvmFzs2 AGVnWd7H9M02I7v56kP5nShLHuAUW/ONkEB2JzP8/sE2on78bo1RGWWKCCB8xYanMx 5Y19TlHi4CH6w== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79219 Cc: Stefan Monnier , 79219@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: -3.3 (---) --=-=-= Content-Type: text/plain Dmitry Gutov writes: > Spencer, hi, > > On 11/08/2025 19:44, Spencer Baugh wrote: >> Improve completion-pcm-leading-wildcard by actually inserting >> a * when try-completion runs. completion-pcm--merge-try will >> automatically remove the wildcard anywhere that it has no >> matches, so the * is inserted only where it actually had an >> effect. > > Would it be difficult to add a test for this? > > I can see that you authored some of most recent ones in > minibuffer-tests.el, but completion-pcm-leading-wildcard does not seem > to be exercised in our suite yet. Certainly, easy enough to do a basic test, attached. Though, after working on this some more, I think there's a better thing to be doing here, which should always apply to pcm rather than be conditioned on completion-pcm-leading-wildcard: insert a * when a non-* wildcard is matching against an empty string. For example, when doing (completion-pcm-try-completion "a/b" '("a/bbb" "a-test/bbb") nil 3) return "a*/bbb" instead of the current "a/bbb". This matches up with this comment in completion-pcm--merge-completions: ;; FIXME: in some cases, it may be necessary to turn an ;; `any' into a `star' because the surrounding context has ;; changed such that string->pattern wouldn't add an `any' ;; here any more. I tried doing that change instead, and it works pretty nicely, but before landing it I found I had to fix bug#79265 first. So let's settle that one first then come back to this bug. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-add-some-leading-wildcard-tests.patch >From e3e8e2f90f33f03127e091388305251d26e5c233 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Mon, 18 Aug 2025 14:51:33 -0400 Subject: [PATCH] add some leading-wildcard tests --- test/lisp/minibuffer-tests.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el index 59b72899e22..2b22ee20b3f 100644 --- a/test/lisp/minibuffer-tests.el +++ b/test/lisp/minibuffer-tests.el @@ -332,6 +332,22 @@ completion-pcm-test-8 "" '("fooxbar" "fooybar") nil 0) '("foobar" . 3)))) +(ert-deftest completion-pcm-test-9 () + ;; By default completions must match the begining of the string. + (should (equal (completion-pcm-try-completion + "oo" '("foo") nil 2) + nil)) + ;; But not with `completion-pcm-leading-wildcard'. + (should (equal (let ((completion-pcm-leading-wildcard t)) + (completion-pcm-try-completion + "oo" '("foo") nil 2)) + '("foo" . 3))) + ;; The wildcard is actually inserted into the text. + (should (equal (let ((completion-pcm-leading-wildcard t)) + (completion-pcm-try-completion + "oo" '("foo" "goo") nil 2)) + '("*oo" . 1)))) + (ert-deftest completion-substring-test-1 () ;; One third of a match! (should (equal -- 2.43.7 --=-=-=--