From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 10 12:50:43 2024 Received: (at submit) by debbugs.gnu.org; 10 Dec 2024 17:50:43 +0000 Received: from localhost ([127.0.0.1]:59499 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL4Ne-0002Jb-OR for submit@debbugs.gnu.org; Tue, 10 Dec 2024 12:50:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:56598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL4Nb-0002JR-Nq for submit@debbugs.gnu.org; Tue, 10 Dec 2024 12:50:41 -0500 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 1tL4LV-0004Ia-Jk for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 12:48:29 -0500 Received: from mxout6.mail.janestreet.com ([64.215.233.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL4LS-0007RU-EB for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 12:48:29 -0500 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard Date: Tue, 10 Dec 2024 12:48:23 -0500 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=1733852903; bh=rw+tc/bYEMDaJw8SUT7odwFELvCyV/kUzy+GdaAZPOA=; h=From:To:Cc:Subject:Date; b=yiwFIcWtmU8OziLmYHjI1OHSb/dXATyl0WRMZR02JZd0FWpydlnY4TANXETwNQ/3f JgXqy6mMLQwZth4lCmHNIXqyuSyqi1z1pbmhWhNM+TGGYOYgHEmdAYfbAjwBza2NOl Q4Qo/9QZw/Rp7n7qwwAaZ1ovFLXTPKPTo2hTCCwXKQAUTj07nkBy82t5FwWuSXHpDj 7y7pycWzcBbxutEgLykConliX6uWYEUJddu22PKxDPTB+tdZiBqVaDI95p2q44QEhB I9aA9u8ronYP0u3SU1rKi0Bh3dCYHk9ADogFRa+6AW7SubWMeyNhLMwUKCYV6pEpp2 GJNvr0A5kOhLQ== Received-SPF: pass client-ip=64.215.233.21; envelope-from=sbaugh@janestreet.com; helo=mxout6.mail.janestreet.com 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, 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: -1.4 (-) X-Debbugs-Envelope-To: submit 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: -2.4 (--) --=-=-= Content-Type: text/plain Tags: patch completion-pcm--find-all-completions has two different phases: First we turn the minibuffer text into a regex and matches completion alternatives against it. If that finds no matches, then we strip some text off the completions and minibuffer text and call ourselves recursively to find completions, then filter the results with the removed text (converted into a regex). Because of this, completion-pcm-leading-wildcard had inconsistent behavior: in the second phase, the filter created from the removed text would have a leading wildcard. That effectively adds wildcards in the middle of the minibuffer text at the start of each "word". But the first phrase created a regex which had no such wildcards. Thus, the two phases could get substantially different results. We fix this by changing completion-pcm-leading-wildcard to consistently add a leading wildcard for each word. This was always my intention. * lisp/minibuffer.el (completion-pcm--string->pattern): Include a wildcard after each delimter with completion-pcm-leading-wildcard. * lisp/minibuffer.el (completion-pcm-leading-wildcard): Update docs. * doc/emacs/mini.texi (Completion Styles): Update docs. In GNU Emacs 29.2.50 (build 11, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-12-02 built on igm-qws-u22796a Repository revision: ddde0f4eead134864c7db775c0aeb93f201c35f6 Repository branch: my-emacs-29 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-selinux --without-imagemagick --with-modules --with-gif=no --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-Consistently-add-wildcards-for-completion-pcm-leadin.patch >From c6229d0dc2d78486dac00e5a8a1d6f95a08b80fd Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 10 Dec 2024 12:41:49 -0500 Subject: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard completion-pcm--find-all-completions has two different phases: First we turn the minibuffer text into a regex and matches completion alternatives against it. If that finds no matches, then we strip some text off the completions and minibuffer text and call ourselves recursively to find completions, then filter the results with the removed text (converted into a regex). Because of this, completion-pcm-leading-wildcard had inconsistent behavior: in the second phase, the filter created from the removed text would have a leading wildcard. That effectively adds wildcards in the middle of the minibuffer text at the start of each "word". But the first phrase created a regex which had no such wildcards. Thus, the two phases could get substantially different results. We fix this by changing completion-pcm-leading-wildcard to consistently add a leading wildcard for each word. This was always my intention. * lisp/minibuffer.el (completion-pcm--string->pattern): Include a wildcard after each delimter with completion-pcm-leading-wildcard. * lisp/minibuffer.el (completion-pcm-leading-wildcard): Update docs. * doc/emacs/mini.texi (Completion Styles): Update docs. --- doc/emacs/mini.texi | 6 +++--- lisp/minibuffer.el | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 0fcd24ed79d..8e0d58d0f7c 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -577,9 +577,9 @@ Completion Styles @vindex completion-pcm-leading-wildcard If @code{completion-pcm-leading-wildcard} is set to @code{t}, this style -always acts as if a @dfn{wildcard} is present at the start of the -minibuffer text, similar to the @code{substring} style. For example, -@samp{l-m} will complete to @samp{emacs-lisp-mode}. +always acts as if a @dfn{wildcard} is present at the start of each word +in the minibuffer text, similar to the @code{substring} style. For +example, @samp{l-ode} will complete to @samp{emacs-lisp-mode}. @item emacs22 @cindex @code{emacs22}, completion style diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 2d27fef44ab..cf9ff46e572 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3996,17 +3996,18 @@ completion-pcm--pattern-trivial-p trivial))) (defcustom completion-pcm-leading-wildcard nil - "If non-nil, partial-completion completes as if there's a leading wildcard. + "If non-nil, partial-completion adds a leading wildcard for each word. -If nil (the default), partial-completion requires a matching completion -alternative to have the same beginning as the first \"word\" in the -minibuffer text, where \"word\" is determined by +If nil (the default), partial-completion requires each word in a +matching completion alternative to have the same beginning as each +\"word\" in the minibuffer text, where \"word\" is determined by `completion-pcm-word-delimiters'. If non-nil, partial-completion allows any string of characters to occur -at the beginning of a completion alternative, as if a wildcard such as -\"*\" was present at the beginning of the minibuffer text. This makes -partial-completion behave more like the substring completion style." +at the beginning of each word in a completion alternative, as if a +wildcard such as \"*\" was present at the beginning of each word. This +makes partial-completion behave more like the substring completion +style." :version "31.1" :type 'boolean) @@ -4053,7 +4054,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 'any-delim) + (setq pending (if completion-pcm-leading-wildcard 'prefix 'any-delim)) (setq p0 (match-end 0)))) (setq p p0)) -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 10 14:04:36 2024 Received: (at 74772) by debbugs.gnu.org; 10 Dec 2024 19:04:36 +0000 Received: from localhost ([127.0.0.1]:59607 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL5XA-0007Z8-0W for submit@debbugs.gnu.org; Tue, 10 Dec 2024 14:04:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL5X7-0007YW-Lk for 74772@debbugs.gnu.org; Tue, 10 Dec 2024 14:04:34 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL5Uu-00087T-WC; Tue, 10 Dec 2024 14:02:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=myDhwgyu/pk0UracM3hjU4T0nhvExQY8Gq/BEjEiaSI=; b=SHuUsSM7J0Z2 guN55Y15tLIKqDH1T5drRlWszZzN0cs+GZ9U++H9Jv76w2i/9/bw/7JH60a6O5pitmRz/sw+1veYI Lj1pHo8fb9aXUx3VChxtTrkVUQkgq8MGGl9YvuFYwrUdpviGhWNzpm0HJ3RQiQmbmYo+FU923t7YD aycciLTiRGFrMNi/Jgsyl8ZZNO5rU556Er9e/gti4TDSd9nlsYf1QVFFZhmRO6NwdM6pg2LpIQHmg Aqh46GIiG0evzL41Yl/5aQs3u8n+uT/DJymQeUGrc94QArwEKFZEmfDFpW+lKbDvu5FxARYOO9tYF 37Z36XdMx3OO/OyWi49fhQ==; Date: Tue, 10 Dec 2024 21:02:12 +0200 Message-Id: <86zfl39xaj.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74772 Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca 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 (---) > Cc: Stefan Monnier > Date: Tue, 10 Dec 2024 12:48:23 -0500 > From: Spencer Baugh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > (defcustom completion-pcm-leading-wildcard nil > - "If non-nil, partial-completion completes as if there's a leading wildcard. > + "If non-nil, partial-completion adds a leading wildcard for each word. The modified wording is misleading, because it says something that doesn't really happen (as the rest of the doc string reveals). From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 10 14:14:23 2024 Received: (at 74772) by debbugs.gnu.org; 10 Dec 2024 19:14:24 +0000 Received: from localhost ([127.0.0.1]:59626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL5gd-00007e-Bz for submit@debbugs.gnu.org; Tue, 10 Dec 2024 14:14:23 -0500 Received: from mxout1.mail.janestreet.com ([38.105.200.78]:44705) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL5gb-00006m-5z for 74772@debbugs.gnu.org; Tue, 10 Dec 2024 14:14:21 -0500 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard In-Reply-To: <86zfl39xaj.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Dec 2024 21:02:12 +0200") References: <86zfl39xaj.fsf@gnu.org> Date: Tue, 10 Dec 2024 14:14:15 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1733858055; bh=afAnCKneINDt0CnA8YtUbiQwUCQaN3iCp2xJAh6MkNQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=yIWWOcCaFEuTh1M7b4PPgF21YsKOSwwJ3dvpiWmNIPrK+7MOm3TFSda8HP1UV5UUk /RLqTb6EvIqqUSjGCuh4ZcfLBkNSuF5pcwbtPMscZC/vO0AdpGHm6WYYQ8zNaCIntV Kks0ROCrlgeElxZrhiHg8UA05e+E9+bYiIyhH2+0TE1pLwbmenPY0jWPb4dVIpvHOT RAb9ttabwuP3UCx3f1/8Jqdy+JmWdkodC8Y+ME+9ZjWiqjY4NsnQag/8imdTk8HEKC ZuPhhOxpmg/TExy2tgYTcHI2pMie94eXInIEh2HrewmZrt8PfpE0hEMqM1NbvBSURS glFyHj2JIZ/Kg== X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74772 Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca 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 (-) Eli Zaretskii writes: >> Cc: Stefan Monnier >> Date: Tue, 10 Dec 2024 12:48:23 -0500 >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> (defcustom completion-pcm-leading-wildcard nil >> - "If non-nil, partial-completion completes as if there's a leading wildcard. >> + "If non-nil, partial-completion adds a leading wildcard for each word. > > The modified wording is misleading, because it says something that > doesn't really happen (as the rest of the doc string reveals). Okay, how about: If non-nil, PCM completes as if there's a wildcard before each word. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 10 14:40:22 2024 Received: (at 74772) by debbugs.gnu.org; 10 Dec 2024 19:40:22 +0000 Received: from localhost ([127.0.0.1]:59677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL65l-0002SV-BN for submit@debbugs.gnu.org; Tue, 10 Dec 2024 14:40:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35084) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL65j-0002S4-9c for 74772@debbugs.gnu.org; Tue, 10 Dec 2024 14:40:20 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL65c-0003z1-BQ; Tue, 10 Dec 2024 14:40:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=U1EkWr7pOiXI9cQuzFtiSjeGfzGHt9OZROb74jmGIP4=; b=f39aGT1c7jrZ 9XSFUAlRpzZCdJHpcnSgNU3g4tlZUJJV+OImySGmh4L6j2Vmf0qPdi744gdHniAwiNV2d1qES+m9m paHhWqoqXtG4lBQ0cZAQC6vzdKAhV3F45K/MhHsvscsdREVgniQW0NtxbqaT6oP7hfv3N2RMEjwlH e89k0ZBUgknsVKWfyL3aybBi9EfpM/OfTqlwO/2/ezhR4Dd4O8HSXjkzZ03i9tLbgtbXoIlTXphhi PB51vUiH3H4qZ77vtvQK7PD8/xRxbfxmRapDdG9bBigvIMz2QZRlfDP4g2cP8iAn3l8VKm2wkphFb VJnXXeoqB3/WqQa8ZyqUAg==; Date: Tue, 10 Dec 2024 21:40:06 +0200 Message-Id: <86wmg79vjd.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Tue, 10 Dec 2024 14:14:15 -0500) Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard References: <86zfl39xaj.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74772 Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca 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 (---) > From: Spencer Baugh > Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Tue, 10 Dec 2024 14:14:15 -0500 > > Eli Zaretskii writes: > > >> Cc: Stefan Monnier > >> Date: Tue, 10 Dec 2024 12:48:23 -0500 > >> From: Spencer Baugh via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> (defcustom completion-pcm-leading-wildcard nil > >> - "If non-nil, partial-completion completes as if there's a leading wildcard. > >> + "If non-nil, partial-completion adds a leading wildcard for each word. > > > > The modified wording is misleading, because it says something that > > doesn't really happen (as the rest of the doc string reveals). > > Okay, how about: > > If non-nil, PCM completes as if there's a wildcard before each word. Much better, thanks. You could even say If non-nil, partial-completion behaves as if each word is preceded by wildcard. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 10 15:05:21 2024 Received: (at 74772) by debbugs.gnu.org; 10 Dec 2024 20:05:21 +0000 Received: from localhost ([127.0.0.1]:59727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL6Tw-0004XY-2r for submit@debbugs.gnu.org; Tue, 10 Dec 2024 15:05:21 -0500 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:39511) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tL6Tu-0004We-CS for 74772@debbugs.gnu.org; Tue, 10 Dec 2024 15:05:19 -0500 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard In-Reply-To: <86wmg79vjd.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Dec 2024 21:40:06 +0200") References: <86zfl39xaj.fsf@gnu.org> <86wmg79vjd.fsf@gnu.org> Date: Tue, 10 Dec 2024 15:05:12 -0500 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=1733861112; bh=oAy5To9ZIn1hwbuPb+cxd4P2sCUICcbEWyEVwdHZpOE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=RJESt2BFHFOojIF5klomAc5FyH6DOb92tlaN0yWrO4ni1V5Ne3Iz4UR7cxvym2WjF wGQL8bgFVoyjIi59hugzxdFUkTHH3saqsi8NqwV8baSeJcZ70XO8tv5OCoFQMFEh9Q yBhJwPaeX5Kqyz7LiHUD1L2f8IaVOwXhTwYzJw/ff3/EUMcqkTpw+jDlPotXyJ5/um Y4xOKTHxaz0gy4wM0LNgjrAxRPwoFO3qfwRnIERZ40qPJXl9K5kZiZunG7s62qoeZ2 9dexRvyluxvnBXaWM/7pBKFaa1MKs6RgE0Yu7jS/GftcIIcb/ubnLLdJDAaVGfzBuI IgU0rydPMYaIg== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 74772 Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca 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 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca >> Date: Tue, 10 Dec 2024 14:14:15 -0500 >> >> Eli Zaretskii writes: >> >> >> Cc: Stefan Monnier >> >> Date: Tue, 10 Dec 2024 12:48:23 -0500 >> >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> >> the Swiss army knife of text editors" >> >> >> >> (defcustom completion-pcm-leading-wildcard nil >> >> - "If non-nil, partial-completion completes as if there's a leading wildcard. >> >> + "If non-nil, partial-completion adds a leading wildcard for each word. >> > >> > The modified wording is misleading, because it says something that >> > doesn't really happen (as the rest of the doc string reveals). >> >> Okay, how about: >> >> If non-nil, PCM completes as if there's a wildcard before each word. > > Much better, thanks. You could even say > > If non-nil, partial-completion behaves as if each word is preceded by wildcard. Ok, updated patch: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Consistently-add-wildcards-for-completion-pcm-leadin.patch >From 09d8d74cabe7157d5e8e89e82b7e8bb9129ca007 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 10 Dec 2024 12:41:49 -0500 Subject: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard completion-pcm--find-all-completions has two different phases: First we turn the minibuffer text into a regex and matches completion alternatives against it. If that finds no matches, then we strip some text off the completions and minibuffer text and call ourselves recursively to find completions, then filter the results with the removed text (converted into a regex). Because of this, completion-pcm-leading-wildcard had inconsistent behavior: in the second phase, the filter created from the removed text would have a leading wildcard. That effectively adds wildcards in the middle of the minibuffer text at the start of each "word". But the first phrase created a regex which had no such wildcards. Thus, the two phases could get substantially different results. We fix this by changing completion-pcm-leading-wildcard to consistently add a leading wildcard for each word. This was always my intention. * lisp/minibuffer.el (completion-pcm--string->pattern): Include a wildcard after each delimter with completion-pcm-leading-wildcard. (bug#74772) * lisp/minibuffer.el (completion-pcm-leading-wildcard): Update docs. * doc/emacs/mini.texi (Completion Styles): Update docs. --- doc/emacs/mini.texi | 6 +++--- lisp/minibuffer.el | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 0fcd24ed79d..8e0d58d0f7c 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -577,9 +577,9 @@ Completion Styles @vindex completion-pcm-leading-wildcard If @code{completion-pcm-leading-wildcard} is set to @code{t}, this style -always acts as if a @dfn{wildcard} is present at the start of the -minibuffer text, similar to the @code{substring} style. For example, -@samp{l-m} will complete to @samp{emacs-lisp-mode}. +always acts as if a @dfn{wildcard} is present at the start of each word +in the minibuffer text, similar to the @code{substring} style. For +example, @samp{l-ode} will complete to @samp{emacs-lisp-mode}. @item emacs22 @cindex @code{emacs22}, completion style diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 2d27fef44ab..a695e4f9f73 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3996,17 +3996,18 @@ completion-pcm--pattern-trivial-p trivial))) (defcustom completion-pcm-leading-wildcard nil - "If non-nil, partial-completion completes as if there's a leading wildcard. + "If non-nil, partial-completion behaves as if each word is preceded by wildcard. -If nil (the default), partial-completion requires a matching completion -alternative to have the same beginning as the first \"word\" in the -minibuffer text, where \"word\" is determined by +If nil (the default), partial-completion requires each word in a +matching completion alternative to have the same beginning as each +\"word\" in the minibuffer text, where \"word\" is determined by `completion-pcm-word-delimiters'. If non-nil, partial-completion allows any string of characters to occur -at the beginning of a completion alternative, as if a wildcard such as -\"*\" was present at the beginning of the minibuffer text. This makes -partial-completion behave more like the substring completion style." +at the beginning of each word in a completion alternative, as if a +wildcard such as \"*\" was present at the beginning of each word. This +makes partial-completion behave more like the substring completion +style." :version "31.1" :type 'boolean) @@ -4053,7 +4054,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 'any-delim) + (setq pending (if completion-pcm-leading-wildcard 'prefix 'any-delim)) (setq p0 (match-end 0)))) (setq p p0)) -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 21 04:16:54 2024 Received: (at 74772) by debbugs.gnu.org; 21 Dec 2024 09:16:54 +0000 Received: from localhost ([127.0.0.1]:45265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOvbR-0006hU-RN for submit@debbugs.gnu.org; Sat, 21 Dec 2024 04:16:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOvbQ-0006hH-3z for 74772@debbugs.gnu.org; Sat, 21 Dec 2024 04:16:52 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOvbJ-0002sK-QO; Sat, 21 Dec 2024 04:16:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=UjGL3AqSN+w/6zGEaeP9cFRyULkdQl3Y3yqHdQ0NokU=; b=U2VWP+c6tFL/ ZivusB5v/4LGG43o6MImln0FY5S5hI5Oy2oUABQx4I6nbzi/wFQigv9aRK9n6lcOou1QvRXuk189L sLbVbvP5xJS/ePQcS4GSBu6uri9zmLyf4bQgHZAiOq2/N8ynqZLf2xu6adEjudI65PwRN88s4vfUP Hjm8xocQzNKfZ3uOnRg4dnAGTH9t5qoQCGA8zIzQQp8UAbw/Tq3EMS5acYsrZiL/d+A1BhiPo1B6I 1qWlAWRUYUuAC+0g5FwjuCIH5OImtiyXFFcpjiTrXUdq7pCMdDarVxbNHNm/Z7S8UVRY7VwH6y9XS KJtot/wBzDIZ8/CJP4fF5Q==; Date: Sat, 21 Dec 2024 11:16:42 +0200 Message-Id: <86ed218kg5.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh , monnier@iro.umontreal.ca In-Reply-To: (message from Spencer Baugh on Tue, 10 Dec 2024 15:05:12 -0500) Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard References: <86zfl39xaj.fsf@gnu.org> <86wmg79vjd.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74772 Cc: 74772@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 (---) > From: Spencer Baugh > Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca > Date: Tue, 10 Dec 2024 15:05:12 -0500 > > Eli Zaretskii writes: > > >> From: Spencer Baugh > >> Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca > >> Date: Tue, 10 Dec 2024 14:14:15 -0500 > >> > >> Eli Zaretskii writes: > >> > >> >> Cc: Stefan Monnier > >> >> Date: Tue, 10 Dec 2024 12:48:23 -0500 > >> >> From: Spencer Baugh via "Bug reports for GNU Emacs, > >> >> the Swiss army knife of text editors" > >> >> > >> >> (defcustom completion-pcm-leading-wildcard nil > >> >> - "If non-nil, partial-completion completes as if there's a leading wildcard. > >> >> + "If non-nil, partial-completion adds a leading wildcard for each word. > >> > > >> > The modified wording is misleading, because it says something that > >> > doesn't really happen (as the rest of the doc string reveals). > >> > >> Okay, how about: > >> > >> If non-nil, PCM completes as if there's a wildcard before each word. > > > > Much better, thanks. You could even say > > > > If non-nil, partial-completion behaves as if each word is preceded by wildcard. > > Ok, updated patch: Stefan, is this patch okay with you? Any comments? From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 21 09:20:46 2024 Received: (at 74772) by debbugs.gnu.org; 21 Dec 2024 14:20:46 +0000 Received: from localhost ([127.0.0.1]:45787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP0LV-0005bS-Mn for submit@debbugs.gnu.org; Sat, 21 Dec 2024 09:20:45 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP0LT-0005bF-F2 for 74772@debbugs.gnu.org; Sat, 21 Dec 2024 09:20:43 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 40E7E44178B; Sat, 21 Dec 2024 09:20:37 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1734790835; bh=VdLCR+pjh0lRzVsUwGR4+FP6y3fjaRxp0Lxz4abo1CA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jKkDlwX0yhP9uXfU4UaZz2tsB7VT6EZ0J7OTJkKuqU2RrwuFV0lmbGvWtoqkoGGsG l5B3zaZoZ7swtAAO7sGsH17rKIv7U9ZOB6l06FgmcjpLLjGdtpi3km9IKJNZncWETE 4ylBZVeCWWI9syMaggiXGAupYQhud2Mzcd8txJ059UTpWl6OX01sGE1aA1oW5IMpdR i2tYx7v/jz30HFwA3TQPFMxoVzBJxkjbR12oHDPrHgYOtZZZG04TlHWvOrmVun6ysF +6FjnQKuw8/Ao2RwOSbYTpLF/YlCi9tRfqaJ/SUoBPwezSCVUM1DPhlUT8RZjOea+2 AL5pE+cv9n7mw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id AB9594404E6; Sat, 21 Dec 2024 09:20:35 -0500 (EST) Received: from asado (unknown [199.119.74.1]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 69C961205CC; Sat, 21 Dec 2024 09:20:35 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard In-Reply-To: <86ed218kg5.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Dec 2024 11:16:42 +0200") Message-ID: References: <86zfl39xaj.fsf@gnu.org> <86wmg79vjd.fsf@gnu.org> <86ed218kg5.fsf@gnu.org> Date: Sat, 21 Dec 2024 09:20:33 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) 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.345 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 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74772 Cc: Spencer Baugh , 74772@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 (---) > Stefan, is this patch okay with you? Any comments? It's OK with me, yes, Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 26 03:44:39 2024 Received: (at 74772-done) by debbugs.gnu.org; 26 Dec 2024 08:44:39 +0000 Received: from localhost ([127.0.0.1]:40025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQjTy-0001JX-Qs for submit@debbugs.gnu.org; Thu, 26 Dec 2024 03:44:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tQjTv-0001JI-C4 for 74772-done@debbugs.gnu.org; Thu, 26 Dec 2024 03:44:37 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQjTp-0002kv-Gw; Thu, 26 Dec 2024 03:44:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=AynRdPdTCitlvv/d0WUt7e/Z2n8uUOtxN/EhzJ3Zh28=; b=QaasONSvQ5iN o/QeGFQqh2PZWzroI9taHN06X1nu4Z84zM8UtEb8dCnmrm529xw9t0gU6f8mbviXPldIMWdSrPkL3 2XUG3TF2c6inn5t+ziwTj4veAGdtFD3nMvh71y0Z+k0hZ4iIFwM57Ev4MhsqHFjJ8t3teR8WjxGbW EUjrg1A2cTRRd6kDM4gwk2HwYNJGV6xb3Lf6svphLyNxA5FatdeGuwjOKV5LIKGe49lT1psRPRjvr 8KGiWgi07CC1+dyV+fPl3fzNpFH/NcWeFhG534FzI3BZ6ffLSVs5wDR9m1PjDrcHVo18CuMmVrLDJ pqJr97SozFxP7vy870B1Sw==; Date: Thu, 26 Dec 2024 10:44:26 +0200 Message-Id: <86a5cizvdh.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Sat, 21 Dec 2024 09:20:33 -0500) Subject: Re: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard References: <86zfl39xaj.fsf@gnu.org> <86wmg79vjd.fsf@gnu.org> <86ed218kg5.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74772-done Cc: sbaugh@janestreet.com, 74772-done@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 (---) > From: Stefan Monnier > Cc: Spencer Baugh , 74772@debbugs.gnu.org > Date: Sat, 21 Dec 2024 09:20:33 -0500 > > > Stefan, is this patch okay with you? Any comments? > > It's OK with me, yes, Thanks, installed on master, and closing the bug. From unknown Sat Jun 21 03:27:24 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 23 Jan 2025 12:24:22 +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