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#74420: 31.0.50; PCM completion for ~/src/emacs/trunk/*/minibuf breaks Date: Wed, 27 Nov 2024 14:30:36 -0500 Message-ID: References: Reply-To: Spencer Baugh Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11228"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74420@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 27 20:31:19 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 1tGNkt-0002jm-5C for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 27 Nov 2024 20:31:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGNkf-00052Y-8P; Wed, 27 Nov 2024 14:31: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 1tGNkd-00051x-1s for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2024 14:31:03 -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 1tGNkc-0001rw-2l for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2024 14:31:02 -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=MsxRpp9RkOKokUpg7MJw/3cHFaDlsA8Jel2BI2ehz9w=; b=kFmKucRHY5SHB9Im4LT053K2Rv74L6pk3VQh7VMxEUOvwh0/8JDxEtxWIQr7AARSgLOleo8Tb/qonwg4Gbn+nbnBXmp1BWrjBe7dx1yCV88a3Fg5A+B06NklQ3FotZDkJsF0pnbQNonSXYnwTugCncqhU+V4r25WtSS1+fj6qwmfvFpUYjj9P5fIy5Wl/q0ql3jZ6cGv/jEw8FLGURyzwcce+p3hRw33qTxqd5bBqlyFcTriqpQoxSHgMyiZSXZPs1mCURy+vp9rWCsOmiBw2G+pWmxOcMCoyY5KGJkKksIjTcTiv+mvYm0Jb9H2aJrd85wogfeL+6pntut932SHBQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tGNkb-0006AD-TH for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2024 14:31:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Nov 2024 19:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74420 X-GNU-PR-Package: emacs Original-Received: via spool by 74420-submit@debbugs.gnu.org id=B74420.173273584323658 (code B ref 74420); Wed, 27 Nov 2024 19:31:01 +0000 Original-Received: (at 74420) by debbugs.gnu.org; 27 Nov 2024 19:30:43 +0000 Original-Received: from localhost ([127.0.0.1]:34618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGNkJ-00069W-6I for submit@debbugs.gnu.org; Wed, 27 Nov 2024 14:30:43 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:34489) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGNkI-00069D-1V for 74420@debbugs.gnu.org; Wed, 27 Nov 2024 14:30:42 -0500 In-Reply-To: (Spencer Baugh's message of "Tue, 19 Nov 2024 08:18:30 -0500") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1732735836; bh=MsxRpp9RkOKokUpg7MJw/3cHFaDlsA8Jel2BI2ehz9w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=ri3famBHt2eOHJ1C980vzzt4Fkgbegdq8tHdEkmFu0yskpuo+KgCjhhRzMJhD31D0 qNGPnCiYkcxT/6jc8n3uIkv8/DgHxpEyzoOVP6lIzBrLZlDi5DHDoXoNU8+hNAxYjL FTtnYJEOvylyYhX/0nNpQRBUvNV6YGa4IOcelXu4B6JSGND6fB0U7z+pDv4HcuNj4C 1X2kvL0hsUnZi4+cOfmIVb0dhO5rbBhvhvZ4oJq3WvomS0jOZSBe8iotAVi6+RznNt +QvrByLD1aj0x/kdhmh6sdTwQiP8JeUkoeZCEDx95c4l1/ZMjvAgSQV2Lki2AjiHse tELaHCe3Jc2Yw== 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:296038 Archived-At: Spencer Baugh writes: > Stefan Monnier writes: >>> Actually... I just realized this misses some cases, namely when we have >>> "star point" or "point star". >> >> FWIW, my local patches have included for years optimizations like the >> ones you suggested *and* they replaced `star point` and `point star` >> with just `star`. >> >> Do you think it's important to preserve `point` in those cases? > > Hm, I'm not sure. I've been playing around with alternative ways to > move point in pcm-try-completion but haven't yet got something I'm > satisfied with. So let me defer this question until I've hacked on that > some more :) Okay, so I ended up not wanting to move point. What I have instead now is something which explicitly inserts a * in the minibuffer, specifically with completion-pcm-leading-wildcard: diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 01502235403..db13c659004 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3925,7 +3925,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 'star 'any-delim)) (setq p0 (match-end 0)))) (setq p p0)) @@ -3935,7 +3935,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 This does two things: - completion-pcm-leading-wildcard previously had inconsistent behavior: if completion-pcm--find-all-completions makes a recursive call, completion-pcm-leading-wildcard would effectively add a leading wildcard to each component. But that wouldn't happen if the original pattern happens to match, in the first completion-pcm--all-completions call. To make them behave identically, now completion-pcm-leading-wildcard changes the 'any-delim inserted at the start of each component into a proper wildcard. This is just a bugfix. - More radically, actually insert a * in the minibuffer text if we run completion-pcm-try-completion with completion-pcm-leading-wildcard=t. Inserting a * is pretty nice for multiple reasons. Paradoxically, inserting a * makes things more efficient for the configuration I intend people to use, where completion-styles contains: ... partial-completion (partial-completion ((completion-pcm-leading-wildcard t))) ... With this configuration, if partial-completion fails, we make one call to the expensive completion-pcm-leading-wildcard=t mode, and then afterwards the explicit *s cause us to stay in regular partial-completion, with only the exact amount of leading wildcards that we actually need, rather than having an extra 'prefix wildcard at the start of every single component. And, inserting the * ensures that we stay in this "leading wildcard" mode. I've found that tab-completing with completion-pcm-leading-wildcard tends to sometimes change the minibuffer contents such that subsequent tab-completions get handled by another completion style. With leading wildcards, that's pretty undesirable, because it can make the set of completions much narrower. But explicitly inserting the * forces the leading-wildcard behavior to stay around. And it just looks pretty good: because the 'star wildcards are removed if they can't expand to anything, when you hit TAB the * are basically inserted everywhere that you might add new text. This is pretty neat. I usually use completion-pcm-leading-wildcard with project-find-file, so e.g. this is a decent way to test: (setf (alist-get 'project-file completion-category-overrides) '((styles basic partial-completion (partial-completion ((completion-pcm-leading-wildcard t)))))) Then C-x p f in the Emacs repo What do you think?