From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74772: [PATCH] Consistently add wildcards for completion-pcm-leading-wildcard Date: Tue, 10 Dec 2024 15:05:12 -0500 Message-ID: References: <86zfl39xaj.fsf@gnu.org> <86wmg79vjd.fsf@gnu.org> Reply-To: Spencer Baugh 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="33405"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74772@debbugs.gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 10 21:06:25 2024 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 1tL6Ux-0008Uk-LQ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Dec 2024 21:06:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tL6Uf-0001Ok-AM; Tue, 10 Dec 2024 15:06:05 -0500 Original-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 1tL6Ud-0001Nv-Qk for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 15:06:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tL6Ud-0006pE-9A for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 15:06:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=oAy5To9ZIn1hwbuPb+cxd4P2sCUICcbEWyEVwdHZpOE=; b=ZCwA+a4QHMNGrSIa1B9Wv/K/HTirVlry6eThluHe1zBiqEcGPub+7we0tgSezLi8hYwR22oAo6ygarcOAr3w+417TopXzCmKKLAfyE77jnfbFWzoSF1q/IX19Hmh1AiUFfq351ATlCzVlezh/WJRGgdQ4Bl5tvlQPTFS3e7qyTT9cWgcEUZH2iUk8IctJLm1Vx1aFtr12V9dkJV+tT+UkmhgFuTVEqdQjCUADeHMbZ7ZOhiQ2cHpdCesLfx9l4N/9auQV8TEVODO5TGRcBtjze41exvJNE6hplyDvxDhu5iobaf68NbSdrg1ZzsLRkmh6XPKHDq1T5F4AU+OThGfNA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tL6Uc-0004c5-CP for bug-gnu-emacs@gnu.org; Tue, 10 Dec 2024 15:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Dec 2024 20:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74772 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74772-submit@debbugs.gnu.org id=B74772.173386112117467 (code B ref 74772); Tue, 10 Dec 2024 20:06:02 +0000 Original-Received: (at 74772) by debbugs.gnu.org; 10 Dec 2024 20:05:21 +0000 Original-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 Original-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 In-Reply-To: <86wmg79vjd.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Dec 2024 21:40:06 +0200") 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-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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296781 Archived-At: --=-=-= 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 --=-=-=--