X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 05 Apr 2024 12:43:02 +0000 Resent-Message-ID: <handler.70217.B.171232093024141 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 70217 <at> debbugs.gnu.org Cc: monnier@HIDDEN X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.171232093024141 (code B ref -1); Fri, 05 Apr 2024 12:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 5 Apr 2024 12:42:10 +0000 Received: from localhost ([127.0.0.1]:35392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rsitV-0006HJ-8u for submit <at> debbugs.gnu.org; Fri, 05 Apr 2024 08:42:09 -0400 Received: from lists.gnu.org ([2001:470:142::17]:45890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1rsitQ-0006Fb-3X for submit <at> debbugs.gnu.org; Fri, 05 Apr 2024 08:42:06 -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 <sbaugh@HIDDEN>) id 1rsitC-0006rC-ML for bug-gnu-emacs@HIDDEN; Fri, 05 Apr 2024 08:41:50 -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 <sbaugh@HIDDEN>) id 1rsitA-0003Vx-Pv for bug-gnu-emacs@HIDDEN; Fri, 05 Apr 2024 08:41:50 -0400 From: Spencer Baugh <sbaugh@HIDDEN> Date: Fri, 05 Apr 2024 08:41:47 -0400 Message-ID: <ier5xwwugl0.fsf@HIDDEN> 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=1712320907; bh=p/h8GDp3kFS1D8jqE73cIWEgLCEmnXtp5BkKo3koYzQ=; h=From:To:Cc:Subject:Date; b=zC8H5U9UpW7znQXZZvMpmO+RsU2ze1I0W01bKqbqsWhnEC7rFlLY01yQRtS4RK3// 1vqQlniOgisggo0H41iyPfC5M+J2piYidHyiDxm/8snuzc/rhUTk5ZV8ohSUc+FmJ8 CafENDNlpAVI2tanlAJKD0aLQURpEj85+fQIKTitiBqI0muVJgwFGUI1GH6mD+8Fb0 2rXFP2YPN+uk5DSRIAlvHDtBE6U1P5sjBx/ZyTrbK55uQjarTMoBJuXhtckjvOcClX l6wWOnLdq+VgkxqOjNQGq5diuph12uyPoVm5yUN8W+hfYSmru3bc1l5eqV0xo68dx6 LxGGltvc39pdQ== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN; helo=mxout5.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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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.9 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch The substring completion style completes "foo-bar" as "*foo-bar*". The partial-completion completion style completes "foo-bar" as "foo*bar*". It is currently not possible to get completion as "*foo*bar*", e.g. combining the two. This patch adds a completion style that combines the two. (It's a bit rough right now, just a quick implementation, will clean it up with feedback) It's preferable for this to be a separate style from partial-completion rather than a customization for partial-completion, because completing with a leading glob is inefficient: it doesn't allow the completion table to do any filtering at all. So, for example, one might want the regular partial-completion style to run first, and if it doesn't find anything then the substring-partial-completion style can run. Further claim: I think the substring completion style should be replaced with the substring-partial-completion style in most places. But that may be a bit more controversial. In GNU Emacs 29.2.50 (build 6, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-03-25 built on igm-qws-u22796a Repository revision: 5d867aca5ea016c07fe9e8b60f55345f83012333 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure -C --with-x-toolkit=lucid --with-native-compilation --with-gif=ifavailable' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-substring-partial-completion-style.patch From 6446dfddb240e206ae24d0a3124325121fd1ffe5 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Fri, 5 Apr 2024 08:34:59 -0400 Subject: [PATCH] Add substring-partial-completion style --- lisp/minibuffer.el | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index a1df6f4c5ab..76de97e0ad9 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1061,6 +1061,14 @@ completion-styles-alist I.e. when completing \"foo_bar\" (where _ is the position of point), it will consider all completions candidates matching the glob pattern \"*foo*bar*\".") + (substring-partial-completion + completion-substring-pcm-try-completion completion-substring-pcm-all-completions + "A combination of the partial-completion and substring styles. +This is like the partial-completion style, but it will also +expand at the start of a completion string. +I.e. when completing \"l-co_h\" (where _ is the position of point), +it will consider all completions candidates matching the glob +pattern \"*l*-co*h*\".") (flex completion-flex-try-completion completion-flex-all-completions "Completion of an in-order subset of characters. @@ -3727,10 +3735,13 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) -(defun completion-pcm--string->pattern (string &optional point) +(defun completion-pcm--string->pattern (string &optional point startglob) "Split STRING into a pattern. A pattern is a list where each element is either a string -or a symbol, see `completion-pcm--merge-completions'." +or a symbol, see `completion-pcm--merge-completions'. + +If STARTGLOB is non-nil, the pattern will start with the symbol +`prefix' if it would otherwise start with a string." (if (and point (< point (length string))) (let ((prefix (substring string 0 point)) (suffix (substring string point))) @@ -3777,7 +3788,10 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (if (not (stringp (car pattern))) + pattern + (cons 'prefix pattern))))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" @@ -3976,11 +3990,12 @@ completion-pcm--hilit-commonality (t completions))) (defun completion-pcm--find-all-completions (string table pred point - &optional filter) + &optional filter startglob) "Find all completions for STRING at POINT in TABLE, satisfying PRED. POINT is a position inside STRING. FILTER is a function applied to the return value, that can be used, e.g. to -filter out additional entries (because TABLE might not obey PRED)." +filter out additional entries (because TABLE might not obey PRED). +STARTGLOB controls whether there's a leading glob in the pattern." (unless filter (setq filter 'identity)) (let* ((beforepoint (substring string 0 point)) (afterpoint (substring string point)) @@ -3991,7 +4006,7 @@ completion-pcm--find-all-completions (setq string (substring string (car bounds) (+ point (cdr bounds)))) (let* ((relpoint (- point (car bounds))) (pattern (completion-pcm--optimize-pattern - (completion-pcm--string->pattern string relpoint))) + (completion-pcm--string->pattern string relpoint startglob))) (all (condition-case-unless-debug err (funcall filter (completion-pcm--all-completions @@ -4255,6 +4270,25 @@ completion-pcm-try-completion 'completion-pcm--filename-try-filter)))) (completion-pcm--merge-try pattern all prefix suffix))) +;; Substring-pcm completion +;; A trivial copy of pcm completion, passing startglob=t + +(defun completion-substring-pcm-all-completions (string table pred point) + (pcase-let ((`(,pattern ,all ,prefix ,_suffix) + (completion-pcm--find-all-completions string table pred point nil t))) + (when all + (nconc (completion-pcm--hilit-commonality pattern all) + (length prefix))))) + +(defun completion-substring-pcm-try-completion (string table pred point) + (pcase-let ((`(,pattern ,all ,prefix ,suffix) + (completion-pcm--find-all-completions + string table pred point + (if minibuffer-completing-file-name + 'completion-pcm--filename-try-filter) + t))) + (completion-pcm--merge-try pattern all prefix suffix))) + ;;; Substring completion ;; Mostly derived from the code of `basic' completion. -- 2.39.3 --=-=-=--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Spencer Baugh <sbaugh@HIDDEN> Subject: bug#70217: Acknowledgement ([PATCH] Add substring-partial-completion style) Message-ID: <handler.70217.B.171232093024141.ack <at> debbugs.gnu.org> References: <ier5xwwugl0.fsf@HIDDEN> X-Gnu-PR-Message: ack 70217 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 70217 <at> debbugs.gnu.org Date: Fri, 05 Apr 2024 12:43:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 70217 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 70217: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D70217 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Stefan Monnier <monnier@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 05 Apr 2024 18:39:02 +0000 Resent-Message-ID: <handler.70217.B70217.171234229922802 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171234229922802 (code B ref 70217); Fri, 05 Apr 2024 18:39:02 +0000 Received: (at 70217) by debbugs.gnu.org; 5 Apr 2024 18:38:19 +0000 Received: from localhost ([127.0.0.1]:37496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rsoSB-0005vi-3I for submit <at> debbugs.gnu.org; Fri, 05 Apr 2024 14:38:19 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:13436) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1rsoS6-0005us-AC for 70217 <at> debbugs.gnu.org; Fri, 05 Apr 2024 14:38:17 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5C33D80B3D; Fri, 5 Apr 2024 14:38:02 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712342277; bh=l3/qBxKijpym+K8jEBjmBi2UkvurGMWtngb5p2A9ZCY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=g+XQJFO/QmXQ9AOE4I4yYRJnAQ3+4rEegg0tWcRUzifRdBx+UlPB3j80t1lTyCCJm CdBzjq3YD/byRZFb9zMllqGpVAV2FQs9I9Ojx9MwEOFVJyQezdLXZ60HDO9imgknNG aVTjKFEee/EBopzj1HSCwGRtk6TxMXB90XefexR/94RabPsOpuIz+/AHXZSVxh2eTA 7PzbI0ral4m7EIjYuzKeGHpMPVusPWXA6KGkq/QzpCjkc63iLnCMrkkk5MJuVjChf/ Iuk881+8LTs+DpLWTC0ETrPPFp1HoSKz0jXJuh7F70DeKUHGI41qlZ/E7ubcoSGunZ XV3YF8aU3Alag== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2F7BE802B3; Fri, 5 Apr 2024 14:37:57 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1E31312024D; Fri, 5 Apr 2024 14:37:57 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> In-Reply-To: <ier5xwwugl0.fsf@HIDDEN> (Spencer Baugh's message of "Fri, 05 Apr 2024 08:41:47 -0400") Message-ID: <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> References: <ier5xwwugl0.fsf@HIDDEN> Date: Fri, 05 Apr 2024 14:35:24 -0400 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.163 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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > It's preferable for this to be a separate style from partial-completion > rather than a customization for partial-completion, because completing > with a leading glob is inefficient: it doesn't allow the completion > table to do any filtering at all. So, for example, one might want the > regular partial-completion style to run first, and if it doesn't find > anything then the substring-partial-completion style can run. FWIW, I think the "language of completion styles" would benefit from being a bit richer. I.e. instead of a completion style (i.e. an entry in `completion-styles`) being limited to a symbol, we could extend it so a style can take arguments. E.g. the `substring` style could take an argument which when set to the symbol `pcm` would cause it to behave like your "substring-partial-completion": (setq completion-styles '(basic (substring pcm) emacs22)) Alternatively, it could be an argument to `partial-completion`, e.g.: (setq completion-styles '(basic (partial-completion notanchored) emacs22)) - Stefan
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Drew Adams <drew.adams@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 05 Apr 2024 19:47:02 +0000 Resent-Message-ID: <handler.70217.B70217.17123463849433 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier <monnier@HIDDEN>, Spencer Baugh <sbaugh@HIDDEN> Cc: "70217 <at> debbugs.gnu.org" <70217 <at> debbugs.gnu.org> Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.17123463849433 (code B ref 70217); Fri, 05 Apr 2024 19:47:02 +0000 Received: (at 70217) by debbugs.gnu.org; 5 Apr 2024 19:46:24 +0000 Received: from localhost ([127.0.0.1]:37528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rspW4-0002S4-6t for submit <at> debbugs.gnu.org; Fri, 05 Apr 2024 15:46:24 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:27540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <drew.adams@HIDDEN>) id 1rspVz-0002RQ-3g for 70217 <at> debbugs.gnu.org; Fri, 05 Apr 2024 15:46:23 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 435Jg93K003200; Fri, 5 Apr 2024 19:46:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2023-11-20; bh=yKLSl+7GUGIF93zV5I5Y0zByuOtF3u7KVz31XLq2HvQ=; b=c4zxq+wIhZYHQ+Lhjl5Ybfd4GXEHhCdCUrawzZ6Hg0d6dkEGOfQdJNHL9yQ9xDuQ3uLr wQg1FUt3rBfFQ9u0f8PUGfPNlDwa9ubPB70DNKCnNah97jwivZ83EBH9CmBdL/Tmq8Zm O8Y4fYry+MZZwHtTZ32ebOKpPC/vtZuoTtZNtM5foRvTi/tRMUkNMSNlzwtyRgm0G6B9 CxIRXWRExLK44klpoJqcK0w6LXsJ1iclG/tU2aEdNlGYFS3Widmma/Q+megq4WBsEvzb esbDihdjeQg3LHBJ2YV4jCcEOt0DoYP9FtBwueA2VEciJ+idAS2wPI8dwPL1UOXJfo4n UQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x9evyv92v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Apr 2024 19:46:11 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 435HpNQT009372; Fri, 5 Apr 2024 19:46:10 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3x9emngwf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Apr 2024 19:46:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nIlbe7loojfZ9YSqPscZVhSymvu7Kw08bH4TbIkpzXBGnYCcdCITCZCVkm2kfInJDNgA+na3NlBoRrGrn+D3QB/pJjefoQtrzSsyGR4oWAY2RTHiADZhWr61E5ggVP42VGQJbzg0ks+WoDoQJNN4huDiEOpontJHq4Pgwc0kQv079lrskUaqXSMMALNUV+RozYdjrxZi1cz98GDKgExwq1deUTs3t0497uHoAj0teT0jP7F08/rdGxFDAPyfLwZwM96uu3vwxwLc3ymsa6GzBurbewmcfAMiiX2VcSBlo0pc6djXknr6dus/i/NaBnzXCcdKssVeAmW+sdIhSSFYrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yKLSl+7GUGIF93zV5I5Y0zByuOtF3u7KVz31XLq2HvQ=; b=AfQSZ1bBBYebV9DyVDnEw35fKOjzhu7ku8rV3g4IFuNFNyo1QgKMLSXx24VA9eTZFkTOjWVq/Pzp0sBc9Obtf3Wns/fxjt0DiecmEPUzjBhHNTjALXogzUWuqhIzOhtzriZxPmh0Pkk426uQbeDy4w4K1rY22x2nlgJJnmUVqcKQ7uOKqOwofo/ObksIwHDzdgQ70wSJDOOIOqlsPHQPXdbScb/D1Uc7Mzouv6T8DgkNFpSz2Z0mWSXk71WbzweMMVRrVzIsHdGZ0IIYKBirwLtDsKUZmZ0JeQHi9bz6Rbn9OSf9Nik+tP4lhuL96Yu1ktaPSz30V6WkvlFj5AU5Ag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yKLSl+7GUGIF93zV5I5Y0zByuOtF3u7KVz31XLq2HvQ=; b=lEYD0Q3yJuZDnAqSDitOVuFZPP76QZ9vEpQjhDqNKw+qTRl/yDSnEayK67ZAFLfHWHs23apwRSySzNCkzbkdzX2R6VrcPpjERaTOemA/oGWYu2Zuf8soZGV+spyegTfwvON8P0IYN4EceQ3HSrWqAueHnZT6aSeibwg8GFU/9iw= Received: from SJ0PR10MB5488.namprd10.prod.outlook.com (2603:10b6:a03:37e::19) by IA1PR10MB7540.namprd10.prod.outlook.com (2603:10b6:208:445::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.26; Fri, 5 Apr 2024 19:46:07 +0000 Received: from SJ0PR10MB5488.namprd10.prod.outlook.com ([fe80::d9bc:c5bb:7fc4:cf9f]) by SJ0PR10MB5488.namprd10.prod.outlook.com ([fe80::d9bc:c5bb:7fc4:cf9f%6]) with mapi id 15.20.7409.042; Fri, 5 Apr 2024 19:46:07 +0000 From: Drew Adams <drew.adams@HIDDEN> Thread-Topic: [External] : bug#70217: [PATCH] Add substring-partial-completion style Thread-Index: AQHah4iYpniH+TW1VkO8KQCcYr9oT7FaCikA Date: Fri, 5 Apr 2024 19:46:07 +0000 Message-ID: <SJ0PR10MB5488B00744F472A5B1D1BD6CF3032@HIDDEN> References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> In-Reply-To: <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR10MB5488:EE_|IA1PR10MB7540:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ivt3JxhMfoumSUR7XaZaG1I95QC4E4zrVSS2ziplHZDGNI0zhJaZ9ub5Ikb99qN90/giHjcLFL3G3ADCn2uFnJxTyFlydVzyaIqaBZCSM4HoB8qAei6LdzjLz9LcBF8AHhscKz2FZDuXvoqyecGjlkzONGZ8Bf+AP9Bb1b6AiDjrF4rIQkwBIJw4Kc09d4jJA0M6A231Sci1h2Z/QddNZ/J0u7AEsTUa1HggizOd6lz6ANVP58fmhwf/80CHsTsQwOf24Y2Dd7SWdkHfUqqcfmhCR/qKCDihHY8OfUOvb5uZwmmFudkEOihRNaPvvbwThvGboAISyKFKFK5gFealW0wVRAdPLZ9pU8l8HFDOJcUegDBYQ4+Gq9jPAhwcrmgO/+XEVdRD34YgyZWhmNg8zlX2NJhWO/CSBK9gt8aVjUwGH92kU3iyaiR41f5TKiCSqNY1htHG7OnRpeHIDbGnMR/LVuacPND8eWN9mE6Jx6m4ZrqZmgYFyfCMNg4bddequvP+NcfL3wIKPsilDNdtss+nOHe/8jOI9jDGxjH1MiHpuS5xJJpkIzvLSNr8CPoc/d91UsfK6osLGeW0KIKeC4ywMZjQu/VLj2lasli6wN8= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR10MB5488.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(366007)(376005)(1800799015); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: RqqRqFN6cJxxTsElKIpIjo1MeEC41XtF+FuCwYwEsSBXUWlFyzGnCzkUK+DpzniCV8zoqc9kJCZYKS7YukTAHdWLvs3azR/fctte0LPsf4Gr5HKMhW/ZDJzFPjh9b1++0PGObinLg71gjYhdrL8rpecXGFP2fHDG7ZHYcqVhGB+6LiL4WRfMMecV/cb0Z6iuzBIhU5TgynCdTsc/dWmnGQAJwU05O3vS+aECgvVLD25hSNKt+dz2v9cGcIrW5+imtsip6KQtiloYg5LeOehKj8CdXb+udtuMF2JGuzQV/3QNaS9P2EqnS+zbhxdztjZo3l6uupNJLGXUOud/R89NM+qnn+FPeVfRxek1Yue5iIdLQik1CJbWKyK7ORp+iGehud9FxDJ8JNHJhYTLhJOxXY0wekt3krYf8eaR09RhmSvuaYwEBrcUsCcx3wR80BokcyPfu5QXXy0j75x5oLT50R71UYGK5MISRmuzaZnM/f50N0VCIKG1dDZ18nqs8p9yRwK/qcdJ97jdyOsImw4aZTOqg4KM9sqS53i9CDL8VllPhubzbSyJC2P6MrYyq7s8MnlX164n7nKuxdlvovQWsgFjtBHB3mJLR60DGnaBlbfbdJ1Qlb07PWjpqP4KSF3vjIWviHmp1uCFNYEHZOvHbhqRkLRMNOLu8K4W21FhLzmmOF1bbU6oJdbMsTL32794Itcvj8Z1adlOucLffr4wSCohtRgVh0+UaPid/TjgI149xELXZC5BX8uhy7R/ZMHFe0kLbXP8hyyaoT7nUcUQGrIZ5MEMf1WQ5tNHUS0DXlUxqqp4A+4TKid6HfRuYKa1YSR0htMUcRV46tlMbJCzcgO29cFRxmTVa/IIDLWg7ZXo8owe6qGiTJxoBkbiMn1DUPaOtPr+UoM1o2TAAjuG0q0IvA63S7de+Q1JE38kxBTWRQ8BBLbiPMjv+BxJuzKZLyuEyHiJfEzbRl5K9whqmqe+Q/PqKEFqIixEmUCFxvsDi25AXwOlgrlFltRNh/+iJCDy29ZsYtAYpZThQTDG+VcBRy2hMzXqZYhj/oWtGcZ7psI04M6F/AwfpmEyfq7PjoUQR51bmlNbVy0vzVgeh/fp71rFLp3erq57k1jgQKs1jK5umhwcymU+H3XsRMSV8MViCGjs5a8oYUAqj9tcjRJA44ZDt4jxs5U/3FCZL+jy0ohSd9Vaw7su+vd/izT8lxH5Us23anApWI6b3vODQc0eFQzC5DLZndQEadbGBpX4n21sDjg4ezAseIyIo1TD3P2uOyVgYAZod+gflGirA/EuffTDgZaPyrDD/KQt8NK0XPLho7Zd/vsdfLvxuoI0+bsBsaQ/T/r4kwmKOiZxcX8DCHM3QU6+C90jgLG55fM2Q/6ukNuR6FpDKqqSmMbWVqYa8MWfPZML49dXJlsLDPm5BGklGG2ohmbJOXtfqT5Zk2o0XbTMDYOmEXLG2aNuJh76xcCVPdxQFA1XjOP4PLVaRgyl5xb0f823OaiGA+4fq5IPpkrmLDUNcgOpm5uVXCkH3stoCVaLvQ90fwzRUCJ9I4hdLuGaMz90ju6D5Vzgl4LW+2tUAcLoq2XjK1wL Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: SawFjOGUJTwYcv4199ul5rE1TZRjI1qUso++I3cDCqCXDNpH7jkztheh7UxsxL7gSLLP9zJAgGy7FYBhEg139FPpkOKm4HB70plhNMn8ZpIWJyktrkGI7qH6haIVJUZSJGGmLq/fo7BwwCq1qHgDf4jrxJSZDZwaYflyQUD6KQ9Y4yNr3AoJrGP+08JI3wbnwN/F4PbAC4i+uKZaHB/Fmcvo//ScSnfyiEXBfB/L+Zg+tZlolSF9Dfl6O6t1B1NeEFYPhpWRhADt1ZpL5gUtk+qIrQszRoeS9sn5mvnQA2IuCD2sgjjbmWGOIYmHsFwnJahHAfI5/GGgrdauBYchA0k0O7iIZrsEtpjbx9WWlEpTrM+baLEIRJHsF2WI916GpUxYPFmRwzlZM16ZyEn04E2m68SW3+FChKVlinwK5qTHW/C2B6vKRlNj5Ljl9cK29xzDVi2UxUFhxaJ6z3rmI8nHumjmB5TgSryCchD+EVv1b694VhnBIqE/XHObW3Eue1ZCPSpqlTJP6pAhrEVQMrMIagd2HjmSsJqam792pDxs+Gkm5lEnk6ObuevU47FnTw7TFWH7rjXRSK1QR/zS/4QzZousEElRhhdk4E9WsOQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5488.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d87b7e8b-ffd9-4888-519b-08dc55a90970 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Apr 2024 19:46:07.5624 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 7ZAcdEqt+uPlvjEsNrZVks7bKVlr6bL6LdTdjOcDYZaG68FKUa6KBQj2x3upkqK6v5Gxr7O7TiuzGNXlN5Gqsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7540 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-05_23,2024-04-05_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404050140 X-Proofpoint-GUID: i29Er5LjQheERJJR0oQ_1NdEmCAD7lxO X-Proofpoint-ORIG-GUID: i29Er5LjQheERJJR0oQ_1NdEmCAD7lxO X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > > It's preferable for this to be a separate style from partial-completion > > rather than a customization for partial-completion, because completing > > with a leading glob is inefficient: it doesn't allow the completion > > table to do any filtering at all. So, for example, one might want the > > regular partial-completion style to run first, and if it doesn't find > > anything then the substring-partial-completion style can run. >=20 > FWIW, I think the "language of completion styles" > would benefit from being a bit richer. FWIW, I agree. Richer in different ways/dimensions. > I.e. instead of a completion style (i.e. an entry > in `completion-styles`) being limited to a symbol, > we could extend it so a style can take arguments. >=20 > E.g. the `substring` style could take an argument > which when set to the symbol `pcm` would cause it > to behave like your "substring-partial-completion": > (setq completion-styles '(basic (substring pcm) emacs22)) >=20 > Alternatively, it could be an argument to `partial-completion`, e.g.: > (setq completion-styles '(basic (partial-completion notanchored) emacs22)= ) I'm not sure that's the best way/place to provide for that, but yes, it's one possible direction for enrichment. ___ FWIW, I think `completion-styles' is too rudimentary in additional ways. (I've mentioned this before.) 1. There's only one set of completion styles that's ever in effect. Each style is tried, in turn, until one of them successfully completes your input. They can only be used together - all or none; they can never serve as alternatives that you can choose interactively (runtime). 2. All completions you see come from the same style. You have no control over which style will actually be used for any given input, other than ordering the styles ahead of time. And you have no way of knowing which style was actually used to produce a given set of candidates. For users, the link (cognitive and otherwise) is lost between a style and its completions for a given input pattern. The relation between your input pattern and the matches is thus sometimes not so clear. There's no way to know, e.g., that initial matching failed and partial matching succeeded. 3. Instead of a single list of styles, Emacs should support a set (list) of such lists, which you can choose from at runtime. You can try completing using one styles list and, if that doesn't succeed, switch to another.=20 Since any such set can be a singleton, allowing multiple sets also means you can use just a single style. 4. Users should be able to define, for a specific _command_, the possible styles sets to choose from, and do so interactively. ___ I'd say Emacs should think about providing more=20 flexibility for what kinds of completing (and sequences of such kinds, per `completing-styles') are available and how users and code can move among them or conditionalize them per context. ___ As an illustration, Icicles has long had such=20 possibilities (even before `completion-styles'). https://www.emacswiki.org/emacs/Icicles_-_Completion_Methods_and_Styles
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eshel Yaron <me@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 06 Apr 2024 08:11:02 +0000 Resent-Message-ID: <handler.70217.B70217.1712391052552 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 70217 <at> debbugs.gnu.org Cc: sbaugh@HIDDEN, monnier@HIDDEN, drew.adams@HIDDEN X-Debbugs-Original-To: Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN> X-Debbugs-Original-Cc: Spencer Baugh <sbaugh@HIDDEN>, "70217 <at> debbugs.gnu.org" <70217 <at> debbugs.gnu.org>, Stefan Monnier <monnier@HIDDEN>, Drew Adams <drew.adams@HIDDEN> Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.1712391052552 (code B ref 70217); Sat, 06 Apr 2024 08:11:02 +0000 Received: (at 70217) by debbugs.gnu.org; 6 Apr 2024 08:10:52 +0000 Received: from localhost ([127.0.0.1]:38141 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rt18W-00008p-FM for submit <at> debbugs.gnu.org; Sat, 06 Apr 2024 04:10:52 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:46074 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1rt18U-00008h-9c for 70217 <at> debbugs.gnu.org; Sat, 06 Apr 2024 04:10:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1712391043; bh=uZBIshUwTb+RAPvmTTvw5Qr171TsK8lC490Rhbkcwv8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=lcrmJ3urC+lesUKr8s3YtOidRTNqR16Ry/FHY0GYlSpvr7TctCyJZ/pkGnBxMYhnb 7SlXT5s25H0+GU6PFYdUHweKVvwhAHLUeegah38uliZrETeLnLjCNFQ26sok1l6TRH RZ5k+lGKWZ17+M/OLRMFN6qN+vO4FKZRvpU1uwfMHjgAvnl32xat0tc4WHL3qL9pNw 7UZ6u+xFbZyBGQbqvGTOYUEXrgQ6gZVS76nsL3I4U+AdOteFRfI0QmDKKi9ez0m6IT ABC60aeMal7kq6USBcYm7MFoq1eWtRdG8GwQ59bl+FsNUlEmgLyVACzPULEUzF8Qur oXtRbJgow5I2Q== From: Eshel Yaron <me@HIDDEN> In-Reply-To: <SJ0PR10MB5488B00744F472A5B1D1BD6CF3032@HIDDEN> (Drew Adams via's message of "Fri, 5 Apr 2024 19:46:07 +0000") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <SJ0PR10MB5488B00744F472A5B1D1BD6CF3032@HIDDEN> X-Hashcash: 1:20:240406:sbaugh@HIDDEN::ApzzDtxNUB9/Nc5g:imP X-Hashcash: 1:20:240406:70217 <at> debbugs.gnu.org::lZiUpLydKLT5kpuA:0vFQ X-Hashcash: 1:20:240406:drew.adams@HIDDEN::xjBXomly+fjjkEYp:3jZw X-Hashcash: 1:20:240406:bug-gnu-emacs@HIDDEN::C9xhOslMjlORIyAy:4lBm X-Hashcash: 1:20:240406:monnier@HIDDEN::MYPGAWo0e4B6breI:5LcG Date: Sat, 06 Apr 2024 10:10:40 +0200 Message-ID: <m1o7amap33.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Drew Adams writes: >> > It's preferable for this to be a separate style from partial-completion >> > rather than a customization for partial-completion, because completing >> > with a leading glob is inefficient: it doesn't allow the completion >> > table to do any filtering at all. So, for example, one might want the >> > regular partial-completion style to run first, and if it doesn't find >> > anything then the substring-partial-completion style can run. >> >> FWIW, I think the "language of completion styles" >> would benefit from being a bit richer. > > FWIW, I agree. Richer in different ways/dimensions. > >> I.e. instead of a completion style (i.e. an entry >> in `completion-styles`) being limited to a symbol, >> we could extend it so a style can take arguments. One thing to keep in mind is that such parameterized completion styles would make user interaction with completion styles more complicated. It's much easier to indicate the effective completion style to the user, and to allow them to pick and choose their completion styles on the fly, when these completion styles are mere symbols. (Currently Emacs doesn't provide such UI for completion styles, but I proposed something along these lines in branch feature/minibuffer-completion-enhancements.) >> >> E.g. the `substring` style could take an argument >> which when set to the symbol `pcm` would cause it >> to behave like your "substring-partial-completion": >> (setq completion-styles '(basic (substring pcm) emacs22)) >> >> Alternatively, it could be an argument to `partial-completion`, e.g.: >> (setq completion-styles '(basic (partial-completion notanchored) emacs22)) [...] > ...you have no way of knowing which style was > actually used to produce a given set of candidates. > For users, the link (cognitive and otherwise) is > lost between a style and its completions for a > given input pattern. +1 I agree it's quite important to indicate which completion style produced what you're seeing, at the very least such indication makes it clear where you should look if you don't like the completions you got. Best, Eshel
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eshel Yaron <me@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 06 Apr 2024 08:12:01 +0000 Resent-Message-ID: <handler.70217.B.1712391062588 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 70217 <at> debbugs.gnu.org Cc: sbaugh@HIDDEN, monnier@HIDDEN, drew.adams@HIDDEN X-Debbugs-Original-To: Drew Adams via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN> X-Debbugs-Original-Cc: Spencer Baugh <sbaugh@HIDDEN>, "70217 <at> debbugs.gnu.org" <70217 <at> debbugs.gnu.org>, Stefan Monnier <monnier@HIDDEN>, Drew Adams <drew.adams@HIDDEN> Received: via spool by submit <at> debbugs.gnu.org id=B.1712391062588 (code B ref -1); Sat, 06 Apr 2024 08:12:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Apr 2024 08:11:02 +0000 Received: from localhost ([127.0.0.1]:38144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rt18f-00009K-S0 for submit <at> debbugs.gnu.org; Sat, 06 Apr 2024 04:11:02 -0400 Received: from lists.gnu.org ([2001:470:142::17]:55276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1rt18d-000091-UK for submit <at> debbugs.gnu.org; Sat, 06 Apr 2024 04:11:00 -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 <me@HIDDEN>) id 1rt18Q-0001FU-GR for bug-gnu-emacs@HIDDEN; Sat, 06 Apr 2024 04:10:46 -0400 Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <me@HIDDEN>) id 1rt18O-0003sj-Ux for bug-gnu-emacs@HIDDEN; Sat, 06 Apr 2024 04:10:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1712391043; bh=uZBIshUwTb+RAPvmTTvw5Qr171TsK8lC490Rhbkcwv8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=lcrmJ3urC+lesUKr8s3YtOidRTNqR16Ry/FHY0GYlSpvr7TctCyJZ/pkGnBxMYhnb 7SlXT5s25H0+GU6PFYdUHweKVvwhAHLUeegah38uliZrETeLnLjCNFQ26sok1l6TRH RZ5k+lGKWZ17+M/OLRMFN6qN+vO4FKZRvpU1uwfMHjgAvnl32xat0tc4WHL3qL9pNw 7UZ6u+xFbZyBGQbqvGTOYUEXrgQ6gZVS76nsL3I4U+AdOteFRfI0QmDKKi9ez0m6IT ABC60aeMal7kq6USBcYm7MFoq1eWtRdG8GwQ59bl+FsNUlEmgLyVACzPULEUzF8Qur oXtRbJgow5I2Q== From: Eshel Yaron <me@HIDDEN> In-Reply-To: <SJ0PR10MB5488B00744F472A5B1D1BD6CF3032@HIDDEN> (Drew Adams via's message of "Fri, 5 Apr 2024 19:46:07 +0000") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <SJ0PR10MB5488B00744F472A5B1D1BD6CF3032@HIDDEN> X-Hashcash: 1:20:240406:sbaugh@HIDDEN::ApzzDtxNUB9/Nc5g:imP X-Hashcash: 1:20:240406:70217 <at> debbugs.gnu.org::lZiUpLydKLT5kpuA:0vFQ X-Hashcash: 1:20:240406:drew.adams@HIDDEN::xjBXomly+fjjkEYp:3jZw X-Hashcash: 1:20:240406:bug-gnu-emacs@HIDDEN::C9xhOslMjlORIyAy:4lBm X-Hashcash: 1:20:240406:monnier@HIDDEN::MYPGAWo0e4B6breI:5LcG Date: Sat, 06 Apr 2024 10:10:40 +0200 Message-ID: <m1o7amap33.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@HIDDEN; helo=eshelyaron.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) Drew Adams writes: >> > It's preferable for this to be a separate style from partial-completion >> > rather than a customization for partial-completion, because completing >> > with a leading glob is inefficient: it doesn't allow the completion >> > table to do any filtering at all. So, for example, one might want the >> > regular partial-completion style to run first, and if it doesn't find >> > anything then the substring-partial-completion style can run. >> >> FWIW, I think the "language of completion styles" >> would benefit from being a bit richer. > > FWIW, I agree. Richer in different ways/dimensions. > >> I.e. instead of a completion style (i.e. an entry >> in `completion-styles`) being limited to a symbol, >> we could extend it so a style can take arguments. One thing to keep in mind is that such parameterized completion styles would make user interaction with completion styles more complicated. It's much easier to indicate the effective completion style to the user, and to allow them to pick and choose their completion styles on the fly, when these completion styles are mere symbols. (Currently Emacs doesn't provide such UI for completion styles, but I proposed something along these lines in branch feature/minibuffer-completion-enhancements.) >> >> E.g. the `substring` style could take an argument >> which when set to the symbol `pcm` would cause it >> to behave like your "substring-partial-completion": >> (setq completion-styles '(basic (substring pcm) emacs22)) >> >> Alternatively, it could be an argument to `partial-completion`, e.g.: >> (setq completion-styles '(basic (partial-completion notanchored) emacs22)) [...] > ...you have no way of knowing which style was > actually used to produce a given set of candidates. > For users, the link (cognitive and otherwise) is > lost between a style and its completions for a > given input pattern. +1 I agree it's quite important to indicate which completion style produced what you're seeing, at the very least such indication makes it clear where you should look if you don't like the completions you got. Best, Eshel
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Thu, 18 Apr 2024 15:20:02 +0000 Resent-Message-ID: <handler.70217.B70217.171345356726508 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier <monnier@HIDDEN> Cc: 70217 <at> debbugs.gnu.org Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171345356726508 (code B ref 70217); Thu, 18 Apr 2024 15:20:02 +0000 Received: (at 70217) by debbugs.gnu.org; 18 Apr 2024 15:19:27 +0000 Received: from localhost ([127.0.0.1]:52993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1rxTXq-0006tQ-I0 for submit <at> debbugs.gnu.org; Thu, 18 Apr 2024 11:19:27 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:57477) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1rxTXn-0006sY-S5 for 70217 <at> debbugs.gnu.org; Thu, 18 Apr 2024 11:19:25 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message of "Fri, 05 Apr 2024 14:35:24 -0400") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> Date: Thu, 18 Apr 2024 11:19:04 -0400 Message-ID: <ieril0ebswn.fsf@HIDDEN> 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=1713453544; bh=RMB++O/K3kyB4o1E3dpka0hSesKt3DTSS0/D6OVKycw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=fzQNrY2+wLhhjXhvYfhtMON+vlr6Ya5HAXlTZMKeqYbqzzwGipnw8cB4ksinCxPo1 8VcKGQeoK/WIE2adPUmgh9qeOin4siTvD6CeXuGNIRE6z5cVUos5xiqDR/7OjIwY+1 zKjOq7xS7Zh6kna1ytM2UTMAlnh+7c0Fzjmot81lgjcfUjPijiyUmJIvKBqbfb6SIt J1kTfxkWCYX0brc+fETLeQUAo2Jpr5DhDHGVPcHi/qFgUTRWA7UewnIXP9H0ZTCsIX D3gMCrMcd5mberEOyE1TdTKk2BhPrycnWGyD7yF2KRLJCqCQ9r31wS3CAHKUCdoVYu 952iHQLPXWf1g== X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Monnier <monnier@HIDDEN> writes: >> It's preferable for this to be a separate style from partial-completion >> rather than a customization for partial-completion, because completing >> with a leading glob is inefficient: it doesn't allow the completion >> table to do any filtering at all. So, for example, one might want the >> regular partial-completion style to run first, and if it doesn't find >> anything then the substring-partial-completion style can run. > > FWIW, I think the "language of completion styles" would benefit from > being a bit richer. I.e. instead of a completion style (i.e. an entry > in `completion-styles`) being limited to a symbol, we could > extend it so a style can take arguments. > > E.g. the `substring` style could take an argument which when set to the > symbol `pcm` would cause it to behave like your "substring-partial-completion": > > (setq completion-styles '(basic (substring pcm) emacs22)) > > Alternatively, it could be an argument to `partial-completion`, e.g.: > > (setq completion-styles '(basic (partial-completion notanchored) emacs22)) This is a good point, because I think there's a few things I want which fit neatly with this: - '(substring pcm) (i.e. the behavior added in this feature) - '(emacs22 pcm) (i.e. ignoring the suffix after point, but using pcm for what's before point) - '(emacs22 pcm substring) (i.e. ignoring the suffix after point, but also globbing at the start of the completion like substring, and using pcm for it) But, also, I realized that I basically always want PCM for both the substring and emacs22 completion styles. So what about having two customizations, defaulting to nil? completion-substring-use-pcm completion-emacs22-use-pcm These customization will affect all usage of those styles. Without this approach, I'd have to use completion-category-overrides to override the completion styles for every single category, just to make the styles use PCM. (which IMO should be the default anyway) This doesn't give me the substring-emacs22 style that I want, but maybe that should actually be a separate style, since its behavior would be fairly different from both emacs22 and substring, and so probably doesn't make sense as an option.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Wed, 08 May 2024 16:48:01 +0000 Resent-Message-ID: <handler.70217.B70217.171518683322607 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier <monnier@HIDDEN> Cc: 70217 <at> debbugs.gnu.org Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171518683322607 (code B ref 70217); Wed, 08 May 2024 16:48:01 +0000 Received: (at 70217) by debbugs.gnu.org; 8 May 2024 16:47:13 +0000 Received: from localhost ([127.0.0.1]:49747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1s4kRh-0005sX-UQ for submit <at> debbugs.gnu.org; Wed, 08 May 2024 12:47:13 -0400 Received: from mxout6.mail.janestreet.com ([64.215.233.21]:34183) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1s4kRb-0005sA-V5 for 70217 <at> debbugs.gnu.org; Wed, 08 May 2024 12:47:07 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <ieril0ebswn.fsf@HIDDEN> (Spencer Baugh's message of "Thu, 18 Apr 2024 11:19:04 -0400") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> Date: Wed, 08 May 2024 12:46:32 -0400 Message-ID: <ieredacqmjb.fsf@HIDDEN> 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=1715186792; bh=h4uMturcDgg7KC5ESz2j9eZ8qS+fWouT9jYRpVWi4qI=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=iQ7DgevpqU7nfOA7p0Ll/Xxhi8vfOntHkPAu85wAw0qKHCRCpa9FZ8P61YNHvSAL1 rvKYwLrv/cIbbhJR2PkPVdCasvyRSm33CR80aHQ7Vcy7WqgxfBcPbosnbfaQlYgDKn 8cfuSwxsNVGkkmHpIpZE2OhN3elmoGoezgaagFoAFRbYss3GTy7UK33bk5YNHM84V3 MeeCiwwffCbpRhhdA9gS3ZTMn5kxm9iubmqEcv8VcarG0yEDwPkGklRBsnwfvCd9Aa vAs5Ki7jawGhTA9NkuQ+4q10sLhE7hwf2YEizTlsPUQsEhkWX0sDWVapKjHfG9mksx gmCJjU/Qqka2w== X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Spencer Baugh <sbaugh@HIDDEN> writes: > But, also, I realized that I basically always want PCM for both the > substring and emacs22 completion styles. So what about having two > customizations, defaulting to nil? > > completion-substring-use-pcm > completion-emacs22-use-pcm Here is a patch implementing this approach for both substring and emacs22. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Support-using-partial-completion-in-emacs22-and-subs.patch From 1a10582f1d41109a8a84451fe847fd0ab685cacb Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Wed, 8 May 2024 12:45:19 -0400 Subject: [PATCH] Support using partial-completion in emacs22 and substring styles The partial-completion completion style is useful, and so are the emacs22 and substring completion styles. Now they can be used at the same time. * lisp/minibuffer.el (completion-emacs22-use-pcm) (completion-substring-use-pcm): Add. (bug#70217) (completion-emacs22-try-completion) (completion-emacs22-all-completions): Check completion-emacs22-use-pcm. (completion-pcm--string->pattern, completion-pcm--find-all-completions) (completion-pcm-all-completions, completion-pcm--merge-try) (completion-pcm-try-completion): Add "startglob" optional argument and pass through. (completion-substring-try-completion) (completion-substring-all-completions): Check completion-substring-use-pcm and pass startglob=t. --- lisp/minibuffer.el | 93 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 28 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index ad6a0928cda..d80cd91320c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3738,9 +3738,25 @@ completion-emacs21-all-completions (length string) (car (completion-boundaries string table pred "")))) +(defcustom completion-emacs22-use-pcm nil + "If non-nil, the emacs22 completion style performs partial-completion. + +This means that in addition to ignoring the text after point +during completion, the text before point is expanded following +the partial-completion rules.") + (defun completion-emacs22-try-completion (string table pred point) - (let ((suffix (substring string point)) - (completion (try-completion (substring string 0 point) table pred))) + (let* ((suffix (substring string point)) + (prefix (substring string 0 point)) + (completion + (if completion-emacs22-use-pcm + (let ((ret (completion-pcm-try-completion prefix table pred point))) + (if (consp ret) + ;; Ignore any changes to point; that would change + ;; what text we're ignoring + (car ret) + ret)) + (try-completion prefix table pred)))) (cond ((eq completion t) (if (equal "" suffix) @@ -3765,10 +3781,12 @@ completion-emacs22-try-completion (defun completion-emacs22-all-completions (string table pred point) (let ((beforepoint (substring string 0 point))) - (completion-hilit-commonality - (all-completions beforepoint table pred) - point - (car (completion-boundaries beforepoint table pred ""))))) + (if completion-emacs22-use-pcm + (completion-pcm-all-completions beforepoint table pred point) + (completion-hilit-commonality + (all-completions beforepoint table pred) + point + (car (completion-boundaries beforepoint table pred "")))))) ;;; Basic completion. @@ -3875,10 +3893,13 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) -(defun completion-pcm--string->pattern (string &optional point) +(defun completion-pcm--string->pattern (string &optional point startglob) "Split STRING into a pattern. A pattern is a list where each element is either a string -or a symbol, see `completion-pcm--merge-completions'." +or a symbol, see `completion-pcm--merge-completions'. + +If STARTGLOB is non-nil, the pattern will start with the symbol +`prefix' if it would otherwise start with a string." (if (and point (< point (length string))) (let ((prefix (substring string 0 point)) (suffix (substring string point))) @@ -3925,7 +3946,10 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (when (and startglob (stringp (car pattern))) + (push 'prefix pattern)) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" @@ -4218,11 +4242,12 @@ completion-pcm--hilit-commonality (t completions))) (defun completion-pcm--find-all-completions (string table pred point - &optional filter) + &optional filter startglob) "Find all completions for STRING at POINT in TABLE, satisfying PRED. POINT is a position inside STRING. FILTER is a function applied to the return value, that can be used, e.g. to -filter out additional entries (because TABLE might not obey PRED)." +filter out additional entries (because TABLE might not obey PRED). +STARTGLOB controls whether there's a leading glob in the pattern." (unless filter (setq filter 'identity)) (let* ((beforepoint (substring string 0 point)) (afterpoint (substring string point)) @@ -4233,7 +4258,7 @@ completion-pcm--find-all-completions (setq string (substring string (car bounds) (+ point (cdr bounds)))) (let* ((relpoint (- point (car bounds))) (pattern (completion-pcm--optimize-pattern - (completion-pcm--string->pattern string relpoint))) + (completion-pcm--string->pattern string relpoint startglob))) (all (condition-case-unless-debug err (funcall filter (completion-pcm--all-completions @@ -4311,9 +4336,9 @@ completion-pcm--find-all-completions (signal (car firsterror) (cdr firsterror)) (list pattern all prefix suffix))))) -(defun completion-pcm-all-completions (string table pred point) +(defun completion-pcm-all-completions (string table pred point &optional startglob) (pcase-let ((`(,pattern ,all ,prefix ,_suffix) - (completion-pcm--find-all-completions string table pred point))) + (completion-pcm--find-all-completions string table pred point nil startglob))) (when all (nconc (completion-pcm--hilit-commonality pattern all) (length prefix))))) @@ -4489,17 +4514,25 @@ completion-pcm--merge-try merged (max 0 (1- (length merged))) suffix)) (cons (concat prefix merged suffix) (+ newpos (length prefix))))))) -(defun completion-pcm-try-completion (string table pred point) +(defun completion-pcm-try-completion (string table pred point &optional startglob) (pcase-let ((`(,pattern ,all ,prefix ,suffix) (completion-pcm--find-all-completions string table pred point (if minibuffer-completing-file-name - 'completion-pcm--filename-try-filter)))) + 'completion-pcm--filename-try-filter) + startglob))) (completion-pcm--merge-try pattern all prefix suffix))) ;;; Substring completion ;; Mostly derived from the code of `basic' completion. +(defcustom completion-substring-use-pcm nil + "If non-nil, the substring completion style performs partial-completion. + +This means that in addition to expanding at the start of the +completion region, all text will be expanded following the +partial-completion rules.") + (defun completion-substring--all-completions (string table pred point &optional transform-pattern-fn) "Match the presumed substring STRING to the entries in TABLE. @@ -4524,20 +4557,24 @@ completion-substring--all-completions (list all pattern prefix suffix (car bounds)))) (defun completion-substring-try-completion (string table pred point) - (pcase-let ((`(,all ,pattern ,prefix ,suffix ,_carbounds) - (completion-substring--all-completions - string table pred point))) - (if minibuffer-completing-file-name - (setq all (completion-pcm--filename-try-filter all))) - (completion-pcm--merge-try pattern all prefix suffix))) + (if completion-substring-use-pcm + (completion-pcm-try-completion string table pred point t) + (pcase-let ((`(,all ,pattern ,prefix ,suffix ,_carbounds) + (completion-substring--all-completions + string table pred point))) + (if minibuffer-completing-file-name + (setq all (completion-pcm--filename-try-filter all))) + (completion-pcm--merge-try pattern all prefix suffix)))) (defun completion-substring-all-completions (string table pred point) - (pcase-let ((`(,all ,pattern ,prefix ,_suffix ,_carbounds) - (completion-substring--all-completions - string table pred point))) - (when all - (nconc (completion-pcm--hilit-commonality pattern all) - (length prefix))))) + (if completion-substring-use-pcm + (completion-pcm-all-completions string table pred point t) + (pcase-let ((`(,all ,pattern ,prefix ,_suffix ,_carbounds) + (completion-substring--all-completions + string table pred point))) + (when all + (nconc (completion-pcm--hilit-commonality pattern all) + (length prefix)))))) ;;; "flex" completion, also known as flx/fuzzy/scatter completion ;; Completes "foo" to "frodo" and "farfromsober" -- 2.39.3 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Stefan Monnier <monnier@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Wed, 08 May 2024 17:16:02 +0000 Resent-Message-ID: <handler.70217.B70217.171518851223727 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171518851223727 (code B ref 70217); Wed, 08 May 2024 17:16:02 +0000 Received: (at 70217) by debbugs.gnu.org; 8 May 2024 17:15:12 +0000 Received: from localhost ([127.0.0.1]:49867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1s4ksp-0006Ad-M1 for submit <at> debbugs.gnu.org; Wed, 08 May 2024 13:15:11 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:51734) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1s4ksl-0006AG-TE for 70217 <at> debbugs.gnu.org; Wed, 08 May 2024 13:15:10 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C31D244353F; Wed, 8 May 2024 13:14:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1715188474; bh=nv873z3C32Ob9//woA3Y1s2zlWeGWAvw35rSTMgDcV0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=WY9aF9hCwhXOFDzmSUODiOMA3hdnfdDdZDy/dqsATjUzwJrlZU+SLlu56b/y/QJ2I BSPCLuavqdb+bJIkJpzRjAO190ueJojzobw5wUaRr3oPpdoaI2zePPzdqp4TlAVvGb WN0z3XD7w6gDhW9WKcmT6dpehq8h14TnX/qHfB7HIrVFyiqctWR1E+FVWfiV77teRZ dWCgvr64miV6gTLbVpmHiu/cBELYxETbRhBQ9UwqjvpaFguxYWaLbvHNvuT0c0EEWx dIa9Bnn/6+QNwS1gppEadb8i00REStJt7wgiOz1fkXfUCy2haR0Cpx93JC4IaCPy6h 2LdlgEQYFeO/Q== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 70998443542; Wed, 8 May 2024 13:14:34 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 62CAE120472; Wed, 8 May 2024 13:14:34 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> In-Reply-To: <ieredacqmjb.fsf@HIDDEN> (Spencer Baugh's message of "Wed, 08 May 2024 12:46:32 -0400") Message-ID: <jwvedacjkor.fsf-monnier+emacs@HIDDEN> References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> Date: Wed, 08 May 2024 13:14:34 -0400 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.100 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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > * lisp/minibuffer.el (completion-emacs22-use-pcm) > (completion-substring-use-pcm): Add. (bug#70217) > (completion-emacs22-try-completion) > (completion-emacs22-all-completions): Check completion-emacs22-use-pcm. > (completion-pcm--string->pattern, completion-pcm--find-all-completions) > (completion-pcm-all-completions, completion-pcm--merge-try) > (completion-pcm-try-completion): Add "startglob" optional argument and > pass through. > (completion-substring-try-completion) > (completion-substring-all-completions): Check > completion-substring-use-pcm and pass startglob=t. I'm not super happy about this `startglob` everywhere. Two things bother me about it: - Its name and doc (in my view of what "glob" means, there's no such thing as a "leading glob"; I think you're talking about a leading wildcard (which is one of the things that can appear in a glob pattern)). - Its spreading all over the place. I don't have the time to dig into the second problem (which might be fixable by combining this info into the `string` argument (which wouldn't be just a string as more, so it could have too-far reaching consequences)), but for the first I suspect a "standard" name for this idea is `anchored`. Other than that, I don't have a strong opinion on whether to introduce the feature via new styles or as custom vars that affect existing styles. Either way works for me. Stefan
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Thu, 16 May 2024 20:27:03 +0000 Resent-Message-ID: <handler.70217.B70217.171589120613321 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier <monnier@HIDDEN> Cc: 70217 <at> debbugs.gnu.org Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171589120613321 (code B ref 70217); Thu, 16 May 2024 20:27:03 +0000 Received: (at 70217) by debbugs.gnu.org; 16 May 2024 20:26:46 +0000 Received: from localhost ([127.0.0.1]:50821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1s7hgb-0003Sn-TX for submit <at> debbugs.gnu.org; Thu, 16 May 2024 16:26:46 -0400 Received: from mxout6.mail.janestreet.com ([64.215.233.21]:44023) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1s7hgW-0003Sh-NZ for 70217 <at> debbugs.gnu.org; Thu, 16 May 2024 16:26:44 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <jwvedacjkor.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message of "Wed, 08 May 2024 13:14:34 -0400") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> Date: Thu, 16 May 2024 16:26:32 -0400 Message-ID: <ierv83dtsef.fsf@HIDDEN> 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=1715891192; bh=dqrjdlCRAsDPpv5FnMKPp6mUS9NfPWT6lVOe3Tyn30g=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=jk/7HYKN9dA00j1EHNAzVTWciZFEkRbROdptT9hIVB70/zu/1mn22aThUQkyrvNSY bolIFfN0WgtthGvLVD6GWNKFSTqQT/IQnyOx47Y+qYoB8nb+i8GJ3jBs9YMX9D6Whi uFBf3qH8qEgcUObfMDaKs27r/ncU65wpqDcZ/5ceF/tSdwkNgF+Y4+eY+xOdXD4sXa MbLxqEFzXCapTtWk01dVfX6gSmmbChXK6E2t9duym1qgdeoRLf0rnIXqu2eGUXsa02 4mlZT18wjU2614pNGzIOKskNabb69cEgcVpZ+u7TmAlwIMG+R6/wM0cQSIF3jVz5LY /TbehHIcAVUWg== X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Monnier <monnier@HIDDEN> writes: >> * lisp/minibuffer.el (completion-emacs22-use-pcm) >> (completion-substring-use-pcm): Add. (bug#70217) >> (completion-emacs22-try-completion) >> (completion-emacs22-all-completions): Check completion-emacs22-use-pcm. >> (completion-pcm--string->pattern, completion-pcm--find-all-completions) >> (completion-pcm-all-completions, completion-pcm--merge-try) >> (completion-pcm-try-completion): Add "startglob" optional argument and >> pass through. >> (completion-substring-try-completion) >> (completion-substring-all-completions): Check >> completion-substring-use-pcm and pass startglob=t. > > I'm not super happy about this `startglob` everywhere. > Two things bother me about it: > > - Its name and doc (in my view of what "glob" means, there's no such > thing as a "leading glob"; I think you're talking about a leading > wildcard (which is one of the things that can appear in a glob > pattern)). Yes, very true, changed to "anchored". > - Its spreading all over the place. In the attached diff it's a dynamic variable completion-pcm-anchored checked in one place. How's that? > I don't have the time to dig into the second problem (which might be > fixable by combining this info into the `string` argument (which > wouldn't be just a string as more, so it could have too-far reaching > consequences)), but for the first I suspect a "standard" name for this > idea is `anchored`. > > Other than that, I don't have a strong opinion on whether to introduce > the feature via new styles or as custom vars that affect > existing styles. Either way works for me. As part of making it a dynamic variable, I also changed the usage. In the attached diff, an element in completion-styles can contain additional dynamic variable bindings: (setq completion-styles '(basic (partial-completion (completion-pcm-anchored nil)) emacs22)) This is powerful and elegant in some ways - for example now a user could use completion-ignore-case only for an individual style. Also, the overall diff is now much shorter. But it may be a bit too powerful. Also, now completion uses cl-progv, which internally uses eval, which might be undesirable. Maybe that could be solved with a C implementation of cl-progv? I think a C implementation of cl-progv might also be useful for my native modules, so I'd be happy to implement that if it seems like a good idea. Also, it's somewhat hard to expose this new power via customize (I haven't bothered to update the customize type for it yet in this diff) What do you think? diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 5ce5aab5c7e..7110e7f573d 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1218,11 +1218,18 @@ completion--nth-completion (result-and-style (completion--some (lambda (style) - (let ((probe (funcall - (or (nth n (assq style completion-styles-alist)) - (error "Invalid completion style %s" style)) - string table pred point))) - (and probe (cons probe style)))) + (let (symbols values) + (when (consp style) + (dolist (binding (cdr style)) + (push (car binding) symbols) + (push (cadr binding) values)) + (setq style (car style))) + (cl-progv symbols values + (let ((probe (funcall + (or (nth n (assq style completion-styles-alist)) + (error "Invalid completion style %s" style)) + string table pred point))) + (and probe (cons probe style)))))) (completion--styles md))) (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))) (when (and adjust-fn metadata) @@ -3780,6 +3787,17 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) +(defcustom completion-pcm-anchored t + "If nil, the partial-completion style expands at the start of a string. + +If non-nil, then expansion at the start of a string only happens +if the string begins with a wildcard. + +For example, if this is nil then \"b/c\" will match +\"aaa/bbb/ccc\"." + :version "30.1" + :type 'boolean) + (defun completion-pcm--string->pattern (string &optional point) "Split STRING into a pattern. A pattern is a list where each element is either a string @@ -3830,7 +3848,12 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (unless completion-pcm-anchored + (when (stringp (car pattern)) + (push 'prefix pattern))) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a ""
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Daniel Mendler <mail@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Thu, 16 May 2024 22:13:02 +0000 Resent-Message-ID: <handler.70217.B70217.171589754419285 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN> Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171589754419285 (code B ref 70217); Thu, 16 May 2024 22:13:02 +0000 Received: (at 70217) by debbugs.gnu.org; 16 May 2024 22:12:24 +0000 Received: from localhost ([127.0.0.1]:51299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1s7jKp-00050z-Q1 for submit <at> debbugs.gnu.org; Thu, 16 May 2024 18:12:24 -0400 Received: from server.qxqx.de ([49.12.34.165]:40983 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mail@HIDDEN>) id 1s7jKh-00050r-F8 for 70217 <at> debbugs.gnu.org; Thu, 16 May 2024 18:12:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tZHvVlmv5rdZcbKziWiwmMJd0YuYPxiRuvbfgYT9LsE=; b=BpOzRb0nS3n2kusbhOjKdzYUPI nNa5cE7hqBL/C0k/MXzD0yToTMfvzWgIqO+k/60mHh2XQlY/Exq7j3RQ2slteDyrmidxxDhui1YcF qcgMVmKrltmYCDAG2Ona9TGbS3PLl1trguDEkhWK6T/YS7z36JoiBhZkPcibwTj18GkQ=; From: Daniel Mendler <mail@HIDDEN> In-Reply-To: <ierv83dtsef.fsf@HIDDEN> (Spencer Baugh's message of "Thu, 16 May 2024 16:26:32 -0400") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> Date: Fri, 17 May 2024 00:09:54 +0200 Message-ID: <87o795pfwt.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) Spencer Baugh <sbaugh@HIDDEN> writes: > Stefan Monnier <monnier@HIDDEN> writes: > >>> * lisp/minibuffer.el (completion-emacs22-use-pcm) >>> (completion-substring-use-pcm): Add. (bug#70217) >>> (completion-emacs22-try-completion) >>> (completion-emacs22-all-completions): Check completion-emacs22-use-pcm. >>> (completion-pcm--string->pattern, completion-pcm--find-all-completions) >>> (completion-pcm-all-completions, completion-pcm--merge-try) >>> (completion-pcm-try-completion): Add "startglob" optional argument and >>> pass through. >>> (completion-substring-try-completion) >>> (completion-substring-all-completions): Check >>> completion-substring-use-pcm and pass startglob=t. >> >> I'm not super happy about this `startglob` everywhere. >> Two things bother me about it: >> >> - Its name and doc (in my view of what "glob" means, there's no such >> thing as a "leading glob"; I think you're talking about a leading >> wildcard (which is one of the things that can appear in a glob >> pattern)). > > Yes, very true, changed to "anchored". > >> - Its spreading all over the place. > > In the attached diff it's a dynamic variable completion-pcm-anchored > checked in one place. How's that? > >> I don't have the time to dig into the second problem (which might be >> fixable by combining this info into the `string` argument (which >> wouldn't be just a string as more, so it could have too-far reaching >> consequences)), but for the first I suspect a "standard" name for this >> idea is `anchored`. >> >> Other than that, I don't have a strong opinion on whether to introduce >> the feature via new styles or as custom vars that affect >> existing styles. Either way works for me. > > As part of making it a dynamic variable, I also changed the usage. In > the attached diff, an element in completion-styles can contain > additional dynamic variable bindings: > > (setq completion-styles '(basic (partial-completion (completion-pcm-anchored nil)) emacs22)) > > This is powerful and elegant in some ways - for example now a user could > use completion-ignore-case only for an individual style. Also, the > overall diff is now much shorter. This sounds great. It will also be useful in other settings. For example the Orderless completion style can be configured via a bunch of dynamic variables. Right now, in orderless.el we provide the helper macro `orderless-define-completion-style' which creates a derived completion style with a bunch of let-bound dynamic variables. Your new feature will make it easier and more direct to configure custom derived completion styles. Daniel
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Fri, 17 May 2024 06:24:01 +0000 Resent-Message-ID: <handler.70217.B70217.17159269997753 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.17159269997753 (code B ref 70217); Fri, 17 May 2024 06:24:01 +0000 Received: (at 70217) by debbugs.gnu.org; 17 May 2024 06:23:19 +0000 Received: from localhost ([127.0.0.1]:53347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1s7qzv-00020z-9L for submit <at> debbugs.gnu.org; Fri, 17 May 2024 02:23:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1s7qzs-00020q-Pi for 70217 <at> debbugs.gnu.org; Fri, 17 May 2024 02:23:17 -0400 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 <eliz@HIDDEN>) id 1s7qzj-0005Uo-Qo; Fri, 17 May 2024 02:23:07 -0400 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=zrnauGMvjDTND4L/v/P1pAoJXgY6m6EYqdf/BQtmQlo=; b=AETTZpID/CdM FX9T4KsQ+pDB5iY8nMNj1mcaPeTaLLQuhcoQ0ltgNgKD3nu+q6MJ7yWhkFE6jbDLInQy+Sz3kq78t BtB8VxvgvJKfnLOX2SXdpMTjaaHRV9N9gl5QHJmqC9jC7UJr9Qr4TLWMbejtOa401cjzS+72dK7Rh v7ApBhcRklp9Vl34NN0ma0niSBKH7hNpr5+0IPjhS1Noj+kiCIQbVJzsJHVQr9FiQhmt0qW5xPQp+ DQo85zM/NR//TYcFI1Fdl0dcWSuthe1ISbPr+/qQjTYi7VbCuhv0PXzbRuwAndbjS56FUxiMADMmH 4qZKqzmHJhLg7Z4MaqekTg==; Date: Fri, 17 May 2024 09:23:04 +0300 Message-Id: <86a5kpgdo7.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ierv83dtsef.fsf@HIDDEN> (message from Spencer Baugh on Thu, 16 May 2024 16:26:32 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Cc: 70217 <at> debbugs.gnu.org > From: Spencer Baugh <sbaugh@HIDDEN> > Date: Thu, 16 May 2024 16:26:32 -0400 > > +(defcustom completion-pcm-anchored t > + "If nil, the partial-completion style expands at the start of a string. How can a style "expand at the start of a string"? This sentence needs to be reworded to tell the effect of the variable more clear. > +If non-nil, then expansion at the start of a string only happens > +if the string begins with a wildcard. What is a "wildcard" in this context? This is a user option, so the doc string should be understandable by users, not just by Lisp programmers who tinker with completion stuff. Also, this new option should be in NEWS, I think. Thanks.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 25 May 2024 21:23:01 +0000 Resent-Message-ID: <handler.70217.B70217.171667215012209 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171667215012209 (code B ref 70217); Sat, 25 May 2024 21:23:01 +0000 Received: (at 70217) by debbugs.gnu.org; 25 May 2024 21:22:30 +0000 Received: from localhost ([127.0.0.1]:47599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sAyqT-0003Aq-Sw for submit <at> debbugs.gnu.org; Sat, 25 May 2024 17:22:30 -0400 Received: from mxout6.mail.janestreet.com ([64.215.233.21]:33431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sAyqS-0003Ad-25 for 70217 <at> debbugs.gnu.org; Sat, 25 May 2024 17:22:28 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86a5kpgdo7.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 17 May 2024 09:23:04 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> Date: Sat, 25 May 2024 17:22:14 -0400 Message-ID: <ierbk4t7fjt.fsf@HIDDEN> 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=1716672134; bh=Zq1MPXvvPqBSN0pGxCFnzTTQxspLQEu/lJYiyRCxBW8=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=WOTz/qokE9zIrBDAG8XBYvnH08kkkgovbHAMovlibKxU1HDO7oNpStjESq1Nu9vNj Z3t49LzPtzk5oB7eqaearb+HkcvW9KQpwkvNyUooDqa/146OIRoE0KVZKrprPfYKqq UfiG7Elx6QtZfgms6NR5QrzrQUpQZF2CTp/j4FsRxNsnTmzMepZvakswhZHh/K94qi cW4WUMmDU8AP9onJaCQx5g2k+tEMKmee0HM90oX7O/1NCD2JewoRY995nHRg2MWjQD 1q6V+itQLK5woPFNIFoku97m1Hz7UH1Cctqd/A1t6WSlmZp5eCfpukg94oxI5i+5f4 osOZPp3O/Xwgg== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii <eliz@HIDDEN> writes: >> Cc: 70217 <at> debbugs.gnu.org >> From: Spencer Baugh <sbaugh@HIDDEN> >> Date: Thu, 16 May 2024 16:26:32 -0400 >> >> +(defcustom completion-pcm-anchored t >> + "If nil, the partial-completion style expands at the start of a string. > > How can a style "expand at the start of a string"? This sentence > needs to be reworded to tell the effect of the variable more clear. > >> +If non-nil, then expansion at the start of a string only happens >> +if the string begins with a wildcard. > > What is a "wildcard" in this context? > > This is a user option, so the doc string should be understandable by > users, not just by Lisp programmers who tinker with completion stuff. OK, reworded that docstring heavily. Maybe it's better now? > > Also, this new option should be in NEWS, I think. Added to NEWS and documentation, and the same for the new possible values of completion-styles. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-customizing-partial-completion-to-be-more-like.patch From d042041accf927b6425a5e0331b19facbff20983 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Sat, 25 May 2024 16:29:43 -0400 Subject: [PATCH] Allow customizing partial-completion to be more like substring The substring completion style completes "foo-bar" as "*foo-bar*". The partial-completion completion style completes "foo-bar" as "foo*bar*". Previously, it was not possible to get completion of "foo-bar" to act as "*foo*bar*", e.g. combining the partial-completion and substring styles. This would be especially useful for things like project-find-file. Now it is possible by customizing the completion-pcm-anchored variable to a non-nil value. Furthermore, it's convenient to be able to run regular (completion-pcm-anchored=t, non-substring) partial-completion before running completion-pcm-anchored=nil partial-completion, since the former provides more narrowly targeted completions. It's possible to do this by customizing completion-styles. Just add '(partial-completion ((completion-pcm-anchored t))) and '(partial-completion ((completion-pcm-anchored nil))) in that order. Then the completion machinery will first run partial-completion with completion-pcm-anchored=t, and if that returns no completions, run partial-completion with completion-pcm-anchored=nil. * lisp/minibuffer.el (completion--nth-completion): Allow an element of completion-styles to contain a list of bindings. (completion-styles): Document that. (completion-pcm-anchored): Add. (completion-pcm--string->pattern): Check completion-pcm-anchored. (bug#70217) --- doc/emacs/mini.texi | 17 ++++++++++-- etc/NEWS | 20 ++++++++++++++ lisp/minibuffer.el | 63 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 90 insertions(+), 10 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 4557f41c3f7..2e9766eb50c 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -535,8 +535,14 @@ Completion Styles @vindex completion-styles The list variable @code{completion-styles} specifies the completion -styles to use. Each list element is the name of a completion style (a -Lisp symbol). The available style symbols are stored in the variable +styles to use. Each list element is either the name of a completion +style (a Lisp symbol) or a list starting with the name of a completion +style followed by @code{let}-style list of bindings which will be in +effect for that completion style. Multiple elements of +@code{completion-styles} can name the same completion style with +different variable bindings. + +The available style symbols are stored in the variable @code{completion-styles-alist} (@pxref{Completion Variables,,, elisp, The Emacs Lisp Reference Manual}). The default completion styles are (in order): @@ -561,6 +567,13 @@ Completion Styles @dfn{wildcard}---it matches any string of characters at the corresponding position in the completion alternative. +@vindex completion-pcm-anchored +By default, a matching completion alternative must have the same +beginning as the first word of the minibuffer text, but if +@code{completion-pcm-anchored} is nil, the first word of the minibuffer +text can start anywhere in a completion alternative. For example, +@samp{l-m} completes to @samp{emacs-lisp-mode}. + @item emacs22 @cindex @code{emacs22}, completion style This completion style is similar to @code{basic}, except that it diff --git a/etc/NEWS b/etc/NEWS index d058acc3572..be59cf37ad0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1848,6 +1848,26 @@ customization group control exactly when Emacs displays this preview. 'completion-preview-mode' is buffer-local, to enable it globally use 'global-completion-preview-mode'. ++++ +*** New user option 'completion-pcm-anchored'. +This option configures how the partial-completion style does completion. +It defaults to t, which preserves the existing behavior. When it is set +to nil, the partial-completion style behaves more like the substring +style, in that a string being completed can match against a candidate +anywhere in the candidate string. + ++++ +*** 'completion-styles' now can contain lists of bindings +An element of 'completion-styles' can be a symbol naming a completion +style in 'completion-styles-alist'. Now it can also be a list of the +form '(style ((variable value) ...))' where style is a symbol naming a +completion style. 'variable' will be bound to 'value' (without +evaluating it) while the style is executing. This allows duplicating a +completion style with different values for completion-affecting +variables like 'completion-pcm-anchored' or 'completion-ignore-case'. +This also applies for the styles configuration in +'completion-category-overrides' and 'completion-category-defaults'. + --- ** The highly accessible Modus themes collection has eight items. The 'modus-operandi' and 'modus-vivendi' are the main themes that have diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f62cb2566b2..10bab12b3ba 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1141,10 +1141,22 @@ completion-styles ;; and simply add "bar" to the end of the result. emacs22) "List of completion styles to use. -The available styles are listed in `completion-styles-alist'. +An element should be a symbol which is listed in +`completion-styles-alist'. + +An element can also be a list of the form \"(style ((variable value) +...))\". \"style\" must be a symbol listed in +`completion-styles-alist', followed by a `let'-style list of +variable/value pairs. \"variable\" will be bound to \"value\" (without +evaluating it) while the style is handling completion. This allows +repeating the same style with different configurations. Note that `completion-category-overrides' may override these -styles for specific categories, such as files, buffers, etc." +styles for specific categories, such as files, buffers, etc. + +Note that Tramp host name completion (e.g., \"/ssh:ho<TAB>\") +currently doesn't work if this list doesn't contain at least one +of `basic', `emacs22' or `emacs21'." :type completion--styles-type :version "23.1") @@ -1284,11 +1296,18 @@ completion--nth-completion (result-and-style (seq-some (lambda (style) - (let ((probe (funcall - (or (nth n (assq style completion-styles-alist)) - (error "Invalid completion style %s" style)) - string table pred point))) - (and probe (cons probe style)))) + (let (symbols values) + (when (consp style) + (dolist (binding (cadr style)) + (push (car binding) symbols) + (push (cadr binding) values)) + (setq style (car style))) + (cl-progv symbols values + (let ((probe (funcall + (or (nth n (assq style completion-styles-alist)) + (error "Invalid completion style %s" style)) + string table pred point))) + (and probe (cons probe style)))))) (completion--styles md))) (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))) (when (and adjust-fn metadata) @@ -3864,6 +3883,30 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) +(defcustom completion-pcm-anchored t + "If non-nil, PCM matches only against the start of completions. + +The partial-completion completion style filters the completion +candidates based on whether they match the string being +completed, according to the partial-completion rules. + +If this variable is non-nil, the string's match must begin at the +start of a completion candidate. + +If this variable is nil, the string's match can begin anywhere in +the completion candidate, similar to the substring completion +style. The behavior is identical to inserting a \"*\" at the +start of the completion string. Note that this can be slower to +compute since less filtering of the completion candidates is +possible. + +For example: when the string being completed is \"b/c\", +\"bbb/ccc\" is a valid completion according to +partial-completion. If this is nil, then \"aaa/bbb/ccc\" and +\"aaabbb/ccc\" are also valid completions." + :version "30.1" + :type 'boolean) + (defun completion-pcm--string->pattern (string &optional point) "Split STRING into a pattern. A pattern is a list where each element is either a string @@ -3914,7 +3957,11 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (unless completion-pcm-anchored + (when (stringp (car pattern)) + (push 'prefix pattern))) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" -- 2.39.3 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Michael Albinus <michael.albinus@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 26 May 2024 07:57:02 +0000 Resent-Message-ID: <handler.70217.B70217.171671020528327 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: Eli Zaretskii <eliz@HIDDEN>, 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171671020528327 (code B ref 70217); Sun, 26 May 2024 07:57:02 +0000 Received: (at 70217) by debbugs.gnu.org; 26 May 2024 07:56:45 +0000 Received: from localhost ([127.0.0.1]:38268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sB8kG-0007Mo-VU for submit <at> debbugs.gnu.org; Sun, 26 May 2024 03:56:45 -0400 Received: from mout.gmx.net ([212.227.15.19]:58239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <michael.albinus@HIDDEN>) id 1sB8kF-0007MZ-1h for 70217 <at> debbugs.gnu.org; Sun, 26 May 2024 03:56:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1716710182; x=1717314982; i=michael.albinus@HIDDEN; bh=R5SFdbbCe3ymbI7BWTUzjGBTii/d4OP9wXcJz+DF+rs=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=hTNk3VfFggTl91La9TIPoJsncyj88oMk3241Jc9TF9ii38S4SxehqYZCJYJNKGiz 8JfxWFo0lP6g0zidgRV57mQG/0seEox2c8O4oJBDCGsrNxmhfwIefVl/xYz3yksdJ 6AkRH4424m+iSCBMwvNk9pvk/Xo9umX9yLfyMgYwcinfZ5H33fWVyXjciZEW1qoD6 EEHFTIyVqTK2zyw0qGIhOC1I4lYU/Hjh9hG1JloOoz59Un5WNbNch6TQt9eYywfe4 lzKzcBiA3p2cqXLA/C3zWnCEBv2cEOnLWR1kBk/AU2ARC4/yFWoup7LNkEoJUctxJ V+zUPhSkp2UT2HQeig== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.38.151]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbzyP-1snDa50Yrn-00aFyG; Sun, 26 May 2024 09:56:22 +0200 From: Michael Albinus <michael.albinus@HIDDEN> In-Reply-To: <ierbk4t7fjt.fsf@HIDDEN> (Spencer Baugh's message of "Sat, 25 May 2024 17:22:14 -0400") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> Date: Sun, 26 May 2024 09:56:20 +0200 Message-ID: <87ttilt3a3.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:lOWVo6YNqalxwW8UTg3ZU7bc9uniJbwOs3EFgxbx6E1y7Ce3RIW MlvcOOoqdQDolisjSpheEB+nTIez62MoMdKMi2IETI2P7hFeTAmIxiF24LN103OlChU7BAc CksmyoEXKAMz9LvonKlzI2Kw4HKvkCSAtxkM74wXMvGWW3TqnyaNDjCMnnP41BFxUMio7VI Atz7JOTb25rwSe498DRXg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:TyrgNMYxrW4=;BeIKAPw9bM0m886TFE9lO87Tkmh 4PK8HAXXFeYSPjenK6lmnGQ7XfZaWmfMW325Gk3RpU5k7MHBkS3cLH0UjOZ39rBqYzfLIdOhq n4kHzW2zUQ0XPDKQrHK+FXlWuIWmHSEc24OBbWsdLvnyDwtL5uTw5fjZbspFzqMgKva36RnUB 9+oWfPNjJclSWbzg7Wiic1YcQpbcGBTu05Zbo040YtVjMr8pVoNDcqiW3PrLSVukBZMdk8RIi WcH2NuXhAQnXSB5bya8Sar3UU7sY7RiaJkZJw75Yvd18CD9ndBUisabKsqpi7bKPSWrpocn7Q uD8nqZGhhtF+LE3fnyX5YNiDcDBzU8COArJaC9Wk3MpS6poCSUWpG5P9gUy8Gt72+oKEqowrB hTQSyRCFk9y5uecAChuiuhQKJgUBuyAJA1osaRo/F5Ysfb9ez0I8JDvmbhQbJbOOxYXFaDwGf ya680xv/Y2TAEvkUeQDEk017EDBFyjR7MCMZgOkZMYx5al5uuLk/wTb8zUuuXA9RUEExeKVHy b6ix1OdLeCgX6dGThDCvSPJL9p/0+/IWH7V7AVdoc387933Ravt+PGJMT5CuLMGT2p9xkpmuU WNeJjufgGTOYESszJDbaSFDE3tG1DfLTfaiN18SEW+1Y96McTldIHSvI+1GDo/vDyXIl1EFPg 5DXgASl+mxPaXNlmq/nq+TdwqwrOY9gbj/iYrKgEV8kVuU+4Xa9F4B7uZZDXx3Cf659gXUk83 kKT7VD9n+wJd4+BOYZNGq3X5+QGzVy7Anw1XvFqe+tFICS0KdN2QRd08rSzMNmmAf0IG/6zxC d1PjAWd7nzeAvGxiK+faMDHfjek9r/9GHWNhcxW0tdEk4D2k9L5Bb0zRX2Z2G4t5rR Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Spencer Baugh writes: Hi Spencer, > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -1141,10 +1141,22 @@ completion-styles > ; ; and simply add "bar" to the end of the result. > emacs22) > "List of completion styles to use. > [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [185.89.38.151 listed in zen.spamhaus.org] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.227.15.19 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (michael.albinus[at]gmx.de) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.15.19 listed in wl.mailspike.net] X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Spencer Baugh writes: Hi Spencer, > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -1141,10 +1141,22 @@ completion-styles > ;; and simply add "bar" to the end of the result. > emacs22) > "List of completion styles to use. > [...] Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.15.19 listed in wl.mailspike.net] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [185.89.38.151 listed in zen.spamhaus.org] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.227.15.19 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (michael.albinus[at]gmx.de) -0.0 SPF_PASS SPF: sender matches SPF record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager Spencer Baugh <sbaugh@HIDDEN> writes: Hi Spencer, > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -1141,10 +1141,22 @@ completion-styles > ;; and simply add "bar" to the end of the result. > emacs22) > "List of completion styles to use. > -The available styles are listed in `completion-styles-alist'. > +An element should be a symbol which is listed in > +`completion-styles-alist'. > + > +An element can also be a list of the form \"(style ((variable value) > +...))\". \"style\" must be a symbol listed in > +`completion-styles-alist', followed by a `let'-style list of > +variable/value pairs. \"variable\" will be bound to \"value\" (without > +evaluating it) while the style is handling completion. This allows > +repeating the same style with different configurations. > > Note that `completion-category-overrides' may override these > -styles for specific categories, such as files, buffers, etc." > +styles for specific categories, such as files, buffers, etc. > + > +Note that Tramp host name completion (e.g., \"/ssh:ho<TAB>\") > +currently doesn't work if this list doesn't contain at least one > +of `basic', `emacs22' or `emacs21'." Are you sure? I thought this general problem was fixed in Tramp 2.6.1 (Emacs 29.2). What's left are problems of Tramp with the `initials' and `shorthand' completion styles. See `tramp-test26-interactive-file-name-completion': =2D-8<---------------cut here---------------start------------->8--- (dolist (style (if (tramp--test-expensive-test-p) ;; It doesn't work for `initials' and `shorthand' ;; completion styles. Should it? ;; `orderless' passes the tests, but it is an ELPA package. '(emacs21 emacs22 basic partial-completion substring fl= ex) '(basic))) ... =2D-8<---------------cut here---------------end--------------->8--- Shall I extend the test for `substring-partial-completion'? Best regards, Michael.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 26 May 2024 09:12:02 +0000 Resent-Message-ID: <handler.70217.B70217.171671469013767 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171671469013767 (code B ref 70217); Sun, 26 May 2024 09:12:02 +0000 Received: (at 70217) by debbugs.gnu.org; 26 May 2024 09:11:30 +0000 Received: from localhost ([127.0.0.1]:38364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sB9ub-0003Zy-Pk for submit <at> debbugs.gnu.org; Sun, 26 May 2024 05:11:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1sB9uZ-0003Zl-VF for 70217 <at> debbugs.gnu.org; Sun, 26 May 2024 05:11:28 -0400 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 <eliz@HIDDEN>) id 1sB9uM-0003bi-88; Sun, 26 May 2024 05:11:14 -0400 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=9dFQYcNxp8SbvKCrAGyLrA2dfZyJg9lJ/YJjmKvfrn8=; b=e76TGrmolCtd oGWTun6VZj88OJLwY4wiuSD4iHtfwwYkQBmyNJzymLBG1jEXbW8MeqwZKijFV7fG+bPRRcokMb0mc M2m9GNG3W/oHlpSweVm2EpJEQWXaIIOz5AI02QRQc60eH4iQJmsnP2gxaX7roQoRdcuKNl5wo9qQK LctpO90HgzD9zZo8sn0NUkSB56zowrIAqE9feC/2aWQV68hPi2JCmkdclpPM6CBAnqrG0l3U/9RUI zNlzBwuf8cxKXSqhrd6M/8vPDO2G1bgtDrbRCf6aRqZp8PPPgVv+kz5kfRyNdIkr9BWznUXikx0zv I7HgofB58AgRf0h8/Z/HvQ==; Date: Sun, 26 May 2024 12:11:11 +0300 Message-Id: <86ttilvsy8.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ierbk4t7fjt.fsf@HIDDEN> (message from Spencer Baugh on Sat, 25 May 2024 17:22:14 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > Date: Sat, 25 May 2024 17:22:14 -0400 > > > This is a user option, so the doc string should be understandable by > > users, not just by Lisp programmers who tinker with completion stuff. > > OK, reworded that docstring heavily. Maybe it's better now? See below. > > Also, this new option should be in NEWS, I think. > > Added to NEWS and documentation, and the same for the new possible > values of completion-styles. Thanks. > ++++ > +*** 'completion-styles' now can contain lists of bindings ^ A period is missing there > +An element of 'completion-styles' can be a symbol naming a completion > +style in 'completion-styles-alist'. Now it can also be a list of the This is better rephrased like this: In addition to being a symbol naming a completion style, an element of 'completion-styles' can now be a list of the form... > +form '(style ((variable value) ...))' where style is a symbol naming a We usually up-case the meta-syntactic variables in these cases, so (STYLE ((VARIABLE VALUE) ...) > +completion style. 'variable' will be bound to 'value' (without Up-case "variable" and "value", and don't quote them. > +evaluating it) while the style is executing. This allows duplicating a > +completion style with different values for completion-affecting Not "duplicating" (which sounds negative), but something like "multiple references to the same style". > +An element can also be a list of the form \"(style ((variable value) > +...))\". \"style\" must be a symbol listed in > +`completion-styles-alist', followed by a `let'-style list of > +variable/value pairs. \"variable\" will be bound to \"value\" (without > +evaluating it) while the style is handling completion. This allows > +repeating the same style with different configurations. Here, too, up-case STYLE, VARIABLE, and VALUE, and don't quote them, since they are not literal symbols, they are "placeholders" -- references to something else. > +(defcustom completion-pcm-anchored t > + "If non-nil, PCM matches only against the start of completions. What is a "PCM"? And what are "completions"? I'm guessing you meant something like If non-nil, completion candidates must match at beginning of completed string. > +For example: when the string being completed is \"b/c\", > +\"bbb/ccc\" is a valid completion according to > +partial-completion. If this is nil, then \"aaa/bbb/ccc\" and > +\"aaabbb/ccc\" are also valid completions." Isn't this not the best example? "b/c" does NOT match "bbb/ccc" at the beginning. Or what am I missing? Thanks.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 26 May 2024 12:51:02 +0000 Resent-Message-ID: <handler.70217.B70217.17167278123946 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Michael Albinus <michael.albinus@HIDDEN> Cc: Eli Zaretskii <eliz@HIDDEN>, 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.17167278123946 (code B ref 70217); Sun, 26 May 2024 12:51:02 +0000 Received: (at 70217) by debbugs.gnu.org; 26 May 2024 12:50:12 +0000 Received: from localhost ([127.0.0.1]:38571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sBDKF-00011Z-Vp for submit <at> debbugs.gnu.org; Sun, 26 May 2024 08:50:12 -0400 Received: from mxout6.mail.janestreet.com ([64.215.233.21]:53467) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sBDKE-00011J-0R for 70217 <at> debbugs.gnu.org; Sun, 26 May 2024 08:50:10 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <87ttilt3a3.fsf@HIDDEN> (Michael Albinus's message of "Sun, 26 May 2024 09:56:20 +0200") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <87ttilt3a3.fsf@HIDDEN> Date: Sun, 26 May 2024 08:49:56 -0400 Message-ID: <ier5xv07n63.fsf@HIDDEN> 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=1716727796; bh=Oy4N9UewF8LjGwd6NW2MgRkM6CnLffaCeXuHDQoH6OQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=al/6pxdqz9HYdm8P9LXZHKFVWttw5vyLw/verucujxdBF6SezVu11YBygDnAbcHdE oZXOPpO/4/+YazGxcB96l7Yvi85nUZisqYp/9aA/UlT4qgQv82RCQF6Cm6RBn3lhOX c3doVO6uCYb0hXSPFi2MQf9HP0owf8F5srzS2llOfTDKkd+UjmzSN4WT/qi3bgieY9 Q1YR5/MfV3mGmGIsIl0bjYEViws9sUpecuhE8+HZ2ka50DZ0dITor0aEfL9kRJzqz7 bkSiYGE50KGezaEJiKx/H+0a5jCWYHa8RbQW4ITeQ2Li9dBiRxC5FS4qPEWRMsKcgi jk5kHkGa0EF/Q== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Michael Albinus <michael.albinus@HIDDEN> writes: > Spencer Baugh <sbaugh@HIDDEN> writes: > > Hi Spencer, > >> --- a/lisp/minibuffer.el >> +++ b/lisp/minibuffer.el >> @@ -1141,10 +1141,22 @@ completion-styles >> ;; and simply add "bar" to the end of the result. >> emacs22) >> "List of completion styles to use. >> -The available styles are listed in `completion-styles-alist'. >> +An element should be a symbol which is listed in >> +`completion-styles-alist'. >> + >> +An element can also be a list of the form \"(style ((variable value) >> +...))\". \"style\" must be a symbol listed in >> +`completion-styles-alist', followed by a `let'-style list of >> +variable/value pairs. \"variable\" will be bound to \"value\" (without >> +evaluating it) while the style is handling completion. This allows >> +repeating the same style with different configurations. >> >> Note that `completion-category-overrides' may override these >> -styles for specific categories, such as files, buffers, etc." >> +styles for specific categories, such as files, buffers, etc. >> + >> +Note that Tramp host name completion (e.g., \"/ssh:ho<TAB>\") >> +currently doesn't work if this list doesn't contain at least one >> +of `basic', `emacs22' or `emacs21'." > > Are you sure? I thought this general problem was fixed in Tramp 2.6.1 > (Emacs 29.2). Oh, sorry, this was just an accident, I wrote this docstring on emacs-29 (which has this note about Tramp) then copy-pasted it to master. Will delete.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 26 May 2024 13:03:02 +0000 Resent-Message-ID: <handler.70217.B70217.17167285505138 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.17167285505138 (code B ref 70217); Sun, 26 May 2024 13:03:02 +0000 Received: (at 70217) by debbugs.gnu.org; 26 May 2024 13:02:30 +0000 Received: from localhost ([127.0.0.1]:38581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sBDW9-0001Kn-Qk for submit <at> debbugs.gnu.org; Sun, 26 May 2024 09:02:30 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:44479) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sBDW6-0001KZ-RM for 70217 <at> debbugs.gnu.org; Sun, 26 May 2024 09:02:27 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86ttilvsy8.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 26 May 2024 12:11:11 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> Date: Sun, 26 May 2024 09:02:13 -0400 Message-ID: <ier34q47mlm.fsf@HIDDEN> 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=1716728533; bh=pP9TMPDHVRFYvRqfJpNSIg2CVb+/tN5npx8cmfgFLqE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=EtCjmmUf2k3ejNSZVZvrrVv6ULexOdcC0tBx8pb263e4Pq0P1E39BAghWYPrsyPCj ZsFeqQcmcQVABwqmRv03rY15dIbGa+7vl5g2zyn445RRco6gsACWp2gUvmsIKLPOA/ DSSBrhgQgUB4fmwfg+/fiu1/UGVpHBP9yJhm+oaXFUpussf8AE0ur8iosX8ZMcUqs4 7MsExpnOY6HJZ6/x8P4KBuMYD5PykkjTxtJhMNEbsxhBoVMvg/vLkM/ksu3AtFA1pH dKB7Qhuo3P+CsDcv9wHXRqOACJL7WdrTQwl9A25ej5qhaFT2Y12ByVGp2zKWGSzyX2 i9v4ze28HNv0w== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN >> Date: Sat, 25 May 2024 17:22:14 -0400 >> >> > This is a user option, so the doc string should be understandable by >> > users, not just by Lisp programmers who tinker with completion stuff. >> >> OK, reworded that docstring heavily. Maybe it's better now? > > See below. > >> > Also, this new option should be in NEWS, I think. >> >> Added to NEWS and documentation, and the same for the new possible >> values of completion-styles. > > Thanks. > >> ++++ >> +*** 'completion-styles' now can contain lists of bindings > ^ > A period is missing there Fixed. >> +An element of 'completion-styles' can be a symbol naming a completion >> +style in 'completion-styles-alist'. Now it can also be a list of the > > This is better rephrased like this: > > In addition to being a symbol naming a completion style, an element > of 'completion-styles' can now be a list of the form... Fixed >> +form '(style ((variable value) ...))' where style is a symbol naming a > > We usually up-case the meta-syntactic variables in these cases, so > > (STYLE ((VARIABLE VALUE) ...) Fixed >> +completion style. 'variable' will be bound to 'value' (without > > Up-case "variable" and "value", and don't quote them. Fixed >> +evaluating it) while the style is executing. This allows duplicating a >> +completion style with different values for completion-affecting > > Not "duplicating" (which sounds negative), but something like > "multiple references to the same style". Fixed >> +An element can also be a list of the form \"(style ((variable value) >> +...))\". \"style\" must be a symbol listed in >> +`completion-styles-alist', followed by a `let'-style list of >> +variable/value pairs. \"variable\" will be bound to \"value\" (without >> +evaluating it) while the style is handling completion. This allows >> +repeating the same style with different configurations. > > Here, too, up-case STYLE, VARIABLE, and VALUE, and don't quote them, > since they are not literal symbols, they are "placeholders" -- > references to something else. Fixed >> +(defcustom completion-pcm-anchored t >> + "If non-nil, PCM matches only against the start of completions. > > What is a "PCM"? And what are "completions"? I'm guessing you meant > something like > > If non-nil, completion candidates must match at beginning of completed string. PCM is the abbreviation for partial-completion. This variable only affects the partial-completion style. I was having trouble including the entire string "partial-completion" in the first line, and also explaining what the variable does, in under 80 characters. Changed to not mention partial-completion in the first line for now at least. >> +For example: when the string being completed is \"b/c\", >> +\"bbb/ccc\" is a valid completion according to >> +partial-completion. If this is nil, then \"aaa/bbb/ccc\" and >> +\"aaabbb/ccc\" are also valid completions." > > Isn't this not the best example? "b/c" does NOT match "bbb/ccc" at > the beginning. Or what am I missing? b/c does match bbb/ccc at the beginning, according to the partial-completion rules. Explained as a glob, partial-completion turns b/c into b*c which then can expand to bbb/ccc. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-customizing-partial-completion-to-be-more-like.patch From 04d8524363c90a79a8ebb82ede85c977bdfeebd7 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Sun, 26 May 2024 08:57:37 -0400 Subject: [PATCH] Allow customizing partial-completion to be more like substring The substring completion style completes "foo-bar" as "*foo-bar*". The partial-completion completion style completes "foo-bar" as "foo*bar*". Previously, it was not possible to get completion of "foo-bar" to act as "*foo*bar*", e.g. combining the partial-completion and substring styles. This would be especially useful for things like project-find-file. Now it is possible by customizing the completion-pcm-anchored variable to a non-nil value. Furthermore, it's convenient to be able to run regular (completion-pcm-anchored=t, non-substring) partial-completion before running completion-pcm-anchored=nil partial-completion, since the former provides more narrowly targeted completions. It's possible to do this by customizing completion-styles. Just add '(partial-completion ((completion-pcm-anchored t))) and '(partial-completion ((completion-pcm-anchored nil))) in that order. Then the completion machinery will first run partial-completion with completion-pcm-anchored=t, and if that returns no completions, run partial-completion with completion-pcm-anchored=nil. * lisp/minibuffer.el (completion--nth-completion): Allow an element of completion-styles to contain a list of bindings. (completion-styles): Document that. (completion-pcm-anchored): Add. (completion-pcm--string->pattern): Check completion-pcm-anchored. (bug#70217) --- doc/emacs/mini.texi | 17 ++++++++++++-- etc/NEWS | 20 ++++++++++++++++ lisp/minibuffer.el | 57 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 4557f41c3f7..2e9766eb50c 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -535,8 +535,14 @@ Completion Styles @vindex completion-styles The list variable @code{completion-styles} specifies the completion -styles to use. Each list element is the name of a completion style (a -Lisp symbol). The available style symbols are stored in the variable +styles to use. Each list element is either the name of a completion +style (a Lisp symbol) or a list starting with the name of a completion +style followed by @code{let}-style list of bindings which will be in +effect for that completion style. Multiple elements of +@code{completion-styles} can name the same completion style with +different variable bindings. + +The available style symbols are stored in the variable @code{completion-styles-alist} (@pxref{Completion Variables,,, elisp, The Emacs Lisp Reference Manual}). The default completion styles are (in order): @@ -561,6 +567,13 @@ Completion Styles @dfn{wildcard}---it matches any string of characters at the corresponding position in the completion alternative. +@vindex completion-pcm-anchored +By default, a matching completion alternative must have the same +beginning as the first word of the minibuffer text, but if +@code{completion-pcm-anchored} is nil, the first word of the minibuffer +text can start anywhere in a completion alternative. For example, +@samp{l-m} completes to @samp{emacs-lisp-mode}. + @item emacs22 @cindex @code{emacs22}, completion style This completion style is similar to @code{basic}, except that it diff --git a/etc/NEWS b/etc/NEWS index d058acc3572..596a2186db5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1848,6 +1848,26 @@ customization group control exactly when Emacs displays this preview. 'completion-preview-mode' is buffer-local, to enable it globally use 'global-completion-preview-mode'. ++++ +*** New user option 'completion-pcm-anchored'. +This option configures how the partial-completion style does completion. +It defaults to t, which preserves the existing behavior. When it is set +to nil, the partial-completion style behaves more like the substring +style, in that a string being completed can match against a candidate +anywhere in the candidate string. + ++++ +*** 'completion-styles' now can contain lists of bindings. +In addition to being a symbol naming a completion style, an element of +'completion-styles' can now be a list of the form '(STYLE ((VARIABLE +VALUE) ...))' where STYLE is a symbol naming a completion style. +VARIABLE will be bound to VALUE (without evaluating it) while the style +is executing. This allows multiple references to the same style with +different values for completion-affecting variables like +'completion-pcm-anchored' or 'completion-ignore-case'. This also +applies for the styles configuration in 'completion-category-overrides' +and 'completion-category-defaults'. + --- ** The highly accessible Modus themes collection has eight items. The 'modus-operandi' and 'modus-vivendi' are the main themes that have diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f62cb2566b2..48e41492515 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1141,7 +1141,15 @@ completion-styles ;; and simply add "bar" to the end of the result. emacs22) "List of completion styles to use. -The available styles are listed in `completion-styles-alist'. +An element should be a symbol which is listed in +`completion-styles-alist'. + +An element can also be a list of the form +(STYLE ((VARIABLE VALUE) ...)) +STYLE must be a symbol listed in `completion-styles-alist', followed by +a `let'-style list of variable/value pairs. VARIABLE will be bound to +VALUE (without evaluating it) while the style is handling completion. +This allows repeating the same style with different configurations. Note that `completion-category-overrides' may override these styles for specific categories, such as files, buffers, etc." @@ -1284,11 +1292,18 @@ completion--nth-completion (result-and-style (seq-some (lambda (style) - (let ((probe (funcall - (or (nth n (assq style completion-styles-alist)) - (error "Invalid completion style %s" style)) - string table pred point))) - (and probe (cons probe style)))) + (let (symbols values) + (when (consp style) + (dolist (binding (cadr style)) + (push (car binding) symbols) + (push (cadr binding) values)) + (setq style (car style))) + (cl-progv symbols values + (let ((probe (funcall + (or (nth n (assq style completion-styles-alist)) + (error "Invalid completion style %s" style)) + string table pred point))) + (and probe (cons probe style)))))) (completion--styles md))) (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))) (when (and adjust-fn metadata) @@ -3864,6 +3879,30 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) +(defcustom completion-pcm-anchored t + "If non-nil, completion candidates must match at beginning of completed string. + +This only affects the partial-completion style, which filters the +completion candidates based on whether they match the string being +completed, according to the partial-completion rules. + +If this variable is non-nil, the string's match must begin at the +start of a completion candidate. + +If this variable is nil, the string's match can begin anywhere in +the completion candidate, similar to the substring completion +style. The behavior is identical to inserting a \"*\" at the +start of the completion string. Note that this can be slower to +compute since less filtering of the completion candidates is +possible. + +For example: when the string being completed is \"b/c\", +\"bbb/ccc\" is a valid completion according to +partial-completion. If this is nil, then \"aaa/bbb/ccc\" and +\"aaabbb/ccc\" are also valid completions." + :version "30.1" + :type 'boolean) + (defun completion-pcm--string->pattern (string &optional point) "Split STRING into a pattern. A pattern is a list where each element is either a string @@ -3914,7 +3953,11 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (unless completion-pcm-anchored + (when (stringp (car pattern)) + (push 'prefix pattern))) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" -- 2.39.3 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 26 May 2024 15:52:02 +0000 Resent-Message-ID: <handler.70217.B70217.171673871625533 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171673871625533 (code B ref 70217); Sun, 26 May 2024 15:52:02 +0000 Received: (at 70217) by debbugs.gnu.org; 26 May 2024 15:51:56 +0000 Received: from localhost ([127.0.0.1]:42307 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sBGA8-0006dl-Eg for submit <at> debbugs.gnu.org; Sun, 26 May 2024 11:51:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1sBGA5-0006dX-Tw for 70217 <at> debbugs.gnu.org; Sun, 26 May 2024 11:51:54 -0400 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 <eliz@HIDDEN>) id 1sBG9s-0007SD-5f; Sun, 26 May 2024 11:51:40 -0400 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=RF6GeJlEgNTUcFeMjW7NP/FiOsQAUKVZB1f6lKla8Eg=; b=IGE4S5UnefH5 q4Sk/zFOoMpo5MIoy3CnVFJkg6yJoq7uuqEdKzuud19jbbcvXo8SAB12BZPeeNvX4R6n16pmDVhSY yBlZgUZIsoMn3fV7mfh16c7tEY0fx4FsMmkIqMZ/x4KGuDGcLnmBppTcfR5ODlwzdZ7WshiTik8Hx zrdBbzs/GvR52+Ps0AdIjNOvWWvyQUBTBZT12GYxiMoApU4/2tikoJ/juTzISb9Uj8TxFyg8mDGvh GsBxL1aXpaPO9x5l1k67Nxnnzy6FmjsuqPlxf2uKbElvcw9xeb1EwdVNEfZXbslfwEXzUvt+/PU/2 Uszr3Zz7OWQbZlCuru9tWA==; Date: Sun, 26 May 2024 18:51:35 +0300 Message-Id: <86ikz0wozc.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ier34q47mlm.fsf@HIDDEN> (message from Spencer Baugh on Sun, 26 May 2024 09:02:13 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > Date: Sun, 26 May 2024 09:02:13 -0400 > > >> +For example: when the string being completed is \"b/c\", > >> +\"bbb/ccc\" is a valid completion according to > >> +partial-completion. If this is nil, then \"aaa/bbb/ccc\" and > >> +\"aaabbb/ccc\" are also valid completions." > > > > Isn't this not the best example? "b/c" does NOT match "bbb/ccc" at > > the beginning. Or what am I missing? > > b/c does match bbb/ccc at the beginning, according to the > partial-completion rules. Explained as a glob, partial-completion turns > b/c into b*c which then can expand to bbb/ccc. Sorry, I don't understand what you are saying and how it addresses my concern. To me, this example contradicts what was explained in the documentation earlier, so we must clarify this, whether in the example or in the preceding descriptions. Please re-read how you described the effect of this option, and go from there.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 14:41:02 +0000 Resent-Message-ID: <handler.70217.B70217.171690721212952 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171690721212952 (code B ref 70217); Tue, 28 May 2024 14:41:02 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 14:40:12 +0000 Received: from localhost ([127.0.0.1]:46789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sBxzn-0003Mm-82 for submit <at> debbugs.gnu.org; Tue, 28 May 2024 10:40:12 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:44445) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sBxzj-0003MT-G9 for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 10:40:08 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86ikz0wozc.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 26 May 2024 18:51:35 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> Date: Tue, 28 May 2024 10:39:52 -0400 Message-ID: <ierjzje57bb.fsf@HIDDEN> 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=1716907192; bh=GsmVRCWtG+fKQlVBnhSeQdmIfdwdeOXJHVlgsasvJ8s=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=QeMk66DEPiRaexQTKwW2YaR4B1mtc1DFXUUbOKMjoAnh3KznT7tCUvqR+u+E09bJY RWaiqwFS7C/g5T0KN6gdpW+HzTYOcgQjQWzoiBF6VOSini95Mp8gM1urukW5kUw3v9 +4DsKMrSIEXw316M1qlFkIE0+v1Yt2uwolT5wjLEBXgDlRgbC/r1LmheXYc68rH+zZ 3Qjk3/EXzQCz3lYSGY/sUo/MRQpLP5NI1/2nXeRFv2qQWn6diZ7EsaDDlJ6OweJyXV h/EtwRJsNBmo4/UaSxhFxgL1lxkCREf6RiMieAxcqwSg9alSIxbVXWRiBQKl5jv9JX uZjP5zYCcsPnw== X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN >> Date: Sun, 26 May 2024 09:02:13 -0400 >> >> >> +For example: when the string being completed is \"b/c\", >> >> +\"bbb/ccc\" is a valid completion according to >> >> +partial-completion. If this is nil, then \"aaa/bbb/ccc\" and >> >> +\"aaabbb/ccc\" are also valid completions." >> > >> > Isn't this not the best example? "b/c" does NOT match "bbb/ccc" at >> > the beginning. Or what am I missing? >> >> b/c does match bbb/ccc at the beginning, according to the >> partial-completion rules. Explained as a glob, partial-completion turns >> b/c into b*c which then can expand to bbb/ccc. > > Sorry, I don't understand what you are saying and how it addresses my > concern. To me, this example contradicts what was explained in the > documentation earlier, so we must clarify this, whether in the example > or in the preceding descriptions. Please re-read how you described > the effect of this option, and go from there. Okay, how about this completely reworked explanation? (It also changes the name of the variable and inverts its effect) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-customizing-partial-completion-to-be-more-like.patch From 2190bd795c907e100636ffecd7822d7cd760bf10 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Sun, 26 May 2024 08:57:37 -0400 Subject: [PATCH] Allow customizing partial-completion to be more like substring The substring completion style completes "foo-bar" as "*foo-bar*". The partial-completion completion style completes "foo-bar" as "foo*bar*". Previously, it was not possible to get completion of "foo-bar" to act as "*foo*bar*", e.g. combining the partial-completion and substring styles. This would be especially useful for things like project-find-file. Now it is possible by customizing the completion-pcm-anchored variable to a non-nil value. Furthermore, it's convenient to be able to run regular (completion-pcm-anchored=t, non-substring) partial-completion before running completion-pcm-anchored=nil partial-completion, since the former provides more narrowly targeted completions. It's possible to do this by customizing completion-styles. Just add '(partial-completion ((completion-pcm-anchored t))) and '(partial-completion ((completion-pcm-anchored nil))) in that order. Then the completion machinery will first run partial-completion with completion-pcm-anchored=t, and if that returns no completions, run partial-completion with completion-pcm-anchored=nil. * lisp/minibuffer.el (completion--nth-completion): Allow an element of completion-styles to contain a list of bindings. (completion-styles): Document that. (completion-pcm-anchored): Add. (completion-pcm--string->pattern): Check completion-pcm-anchored. (bug#70217) --- doc/emacs/mini.texi | 16 +++++++++++++-- etc/NEWS | 20 +++++++++++++++++++ lisp/minibuffer.el | 48 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 4557f41c3f7..cfb5df4d586 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -535,8 +535,14 @@ Completion Styles @vindex completion-styles The list variable @code{completion-styles} specifies the completion -styles to use. Each list element is the name of a completion style (a -Lisp symbol). The available style symbols are stored in the variable +styles to use. Each list element is either the name of a completion +style (a Lisp symbol) or a list starting with the name of a completion +style followed by @code{let}-style list of bindings which will be in +effect for that completion style. Multiple elements of +@code{completion-styles} can name the same completion style with +different variable bindings. + +The available style symbols are stored in the variable @code{completion-styles-alist} (@pxref{Completion Variables,,, elisp, The Emacs Lisp Reference Manual}). The default completion styles are (in order): @@ -561,6 +567,12 @@ Completion Styles @dfn{wildcard}---it matches any string of characters at the corresponding position in the completion alternative. +@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}. + @item emacs22 @cindex @code{emacs22}, completion style This completion style is similar to @code{basic}, except that it diff --git a/etc/NEWS b/etc/NEWS index d058acc3572..8eecc1d2aa3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1848,6 +1848,26 @@ customization group control exactly when Emacs displays this preview. 'completion-preview-mode' is buffer-local, to enable it globally use 'global-completion-preview-mode'. ++++ +*** New user option 'completion-pcm-leading-wildcard'. +This option configures how the partial-completion style does completion. +It defaults to nil, which preserves the existing behavior. When it is set +to t, the partial-completion style behaves more like the substring +style, in that a string being completed can match against a candidate +anywhere in the candidate string. + ++++ +*** 'completion-styles' now can contain lists of bindings. +In addition to being a symbol naming a completion style, an element of +'completion-styles' can now be a list of the form '(STYLE ((VARIABLE +VALUE) ...))' where STYLE is a symbol naming a completion style. +VARIABLE will be bound to VALUE (without evaluating it) while the style +is executing. This allows multiple references to the same style with +different values for completion-affecting variables like +'completion-pcm-leading-wildcard or 'completion-ignore-case'. This also +applies for the styles configuration in 'completion-category-overrides' +and 'completion-category-defaults'. + --- ** The highly accessible Modus themes collection has eight items. The 'modus-operandi' and 'modus-vivendi' are the main themes that have diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f62cb2566b2..c59f1edd410 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1141,7 +1141,15 @@ completion-styles ;; and simply add "bar" to the end of the result. emacs22) "List of completion styles to use. -The available styles are listed in `completion-styles-alist'. +An element should be a symbol which is listed in +`completion-styles-alist'. + +An element can also be a list of the form +(STYLE ((VARIABLE VALUE) ...)) +STYLE must be a symbol listed in `completion-styles-alist', followed by +a `let'-style list of variable/value pairs. VARIABLE will be bound to +VALUE (without evaluating it) while the style is handling completion. +This allows repeating the same style with different configurations. Note that `completion-category-overrides' may override these styles for specific categories, such as files, buffers, etc." @@ -1284,11 +1292,18 @@ completion--nth-completion (result-and-style (seq-some (lambda (style) - (let ((probe (funcall - (or (nth n (assq style completion-styles-alist)) - (error "Invalid completion style %s" style)) - string table pred point))) - (and probe (cons probe style)))) + (let (symbols values) + (when (consp style) + (dolist (binding (cadr style)) + (push (car binding) symbols) + (push (cadr binding) values)) + (setq style (car style))) + (cl-progv symbols values + (let ((probe (funcall + (or (nth n (assq style completion-styles-alist)) + (error "Invalid completion style %s" style)) + string table pred point))) + (and probe (cons probe style)))))) (completion--styles md))) (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))) (when (and adjust-fn metadata) @@ -3864,6 +3879,21 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) +(defcustom completion-pcm-leading-wildcard nil + "If non-nil, partial-completion completes as if there's a leading wildcard. + +If nil (the default), the partial-completion style completes a string +like \"b/c\" as if it was the glob \"b*/c*\". This means \"bbb/ccc\" is +a valid completion, but not \"aaa/bbb/ccc\" or \"aaabbb/ccc\". + +If non-nil, the partial-completion style completes \"b/c\" as if it was +the glob \"*b*/c*\". This means \"bbb/ccc\", \"aaa/bbb/ccc\" and +\"aaabbb/ccc\" are all valid completions. Note that this can be slower +to compute since less filtering of the completion candidates is +possible." + :version "30.1" + :type 'boolean) + (defun completion-pcm--string->pattern (string &optional point) "Split STRING into a pattern. A pattern is a list where each element is either a string @@ -3914,7 +3944,11 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (when completion-pcm-leading-wildcard + (when (stringp (car pattern)) + (push 'prefix pattern))) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" -- 2.39.3 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 15:13:01 +0000 Resent-Message-ID: <handler.70217.B70217.171690913416391 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171690913416391 (code B ref 70217); Tue, 28 May 2024 15:13:01 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 15:12:14 +0000 Received: from localhost ([127.0.0.1]:46795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sByUn-0004GJ-Pv for submit <at> debbugs.gnu.org; Tue, 28 May 2024 11:12:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1sByUl-0004G4-A8 for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 11:12:12 -0400 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 <eliz@HIDDEN>) id 1sByUV-0000QP-5E; Tue, 28 May 2024 11:11:55 -0400 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=ojhczd2jQ/J891ZdGkJbdAVnes27QPFXY0pUgW+zAuA=; b=bTsWpGJftJkK pF7ZSUvg3insgZYY1jz5EvAg9eni23P3KlHAA7n0B67eV/NRNTxEeH8pXuq/7LVbJuIytPWBKz9dd u4HchFQkUSME3aGyqBdzFL7XFC+VMPvPbjQiba5esPsgbm80d8y9BgjmWuC6MBSXsCd1whlXtaq1L GRaTVWvyWtYyA1OpgBA7pTs5iuy7Ms4k0NLOYumaLchdf/2C7Z00CQjbD+C+F9f9smTIEiEihbaPU tJvQVJleWZbafJAMTFI6AiaUiKYkSom/26H+DSDcyfnG4dwV7H/cFz1qI/l1HiVwTt21JRJnCxM37 Y5ox3plyEajxgLurk1Enlw==; Date: Tue, 28 May 2024 18:11:50 +0300 Message-Id: <86o78qt1hl.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ierjzje57bb.fsf@HIDDEN> (message from Spencer Baugh on Tue, 28 May 2024 10:39:52 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > Date: Tue, 28 May 2024 10:39:52 -0400 > > Eli Zaretskii <eliz@HIDDEN> writes: > > >> b/c does match bbb/ccc at the beginning, according to the > >> partial-completion rules. Explained as a glob, partial-completion turns > >> b/c into b*c which then can expand to bbb/ccc. > > > > Sorry, I don't understand what you are saying and how it addresses my > > concern. To me, this example contradicts what was explained in the > > documentation earlier, so we must clarify this, whether in the example > > or in the preceding descriptions. Please re-read how you described > > the effect of this option, and go from there. > > Okay, how about this completely reworked explanation? (It also changes > the name of the variable and inverts its effect) Thanks, this is more clear now. But please (a) don't use "glob" and file wildcard notation, use regexps instead; and (b) please do not use examples with repeated characters, because they can lead readers to make the wrong conclusions due to accidental situations. For example, AFAIU valid candidates for "b*/c*" include "bcdxyz/c1234" and also "b/x/y/z/c/1/2/3", but readers might mistakenly think that "b*" stands for a string made only of "b", or that there can be only one slash and it must precede "c". Avoiding repeated characters prevents such misunderstandings.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 18:17:02 +0000 Resent-Message-ID: <handler.70217.B70217.171692020827107 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171692020827107 (code B ref 70217); Tue, 28 May 2024 18:17:02 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 18:16:48 +0000 Received: from localhost ([127.0.0.1]:50518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sC1NO-000734-Ra for submit <at> debbugs.gnu.org; Tue, 28 May 2024 14:16:48 -0400 Received: from mxout1.mail.janestreet.com ([38.105.200.78]:37531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sC1NN-00072h-3r for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 14:16:45 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86o78qt1hl.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 28 May 2024 18:11:50 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> Date: Tue, 28 May 2024 14:16:30 -0400 Message-ID: <ierbk4p6bup.fsf@HIDDEN> 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=1716920190; bh=7vxyNvVBdW5c0030wT8TIAal0who7PnRMlrdo1pPm/A=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=hRH0Gyr/8jS0DjbS4+jLwPlbDvimtBpUOD6BN1I9r9aSSckgLTVfzcXswlukg4SeQ NRvx5OWKW4Os2lQ9NSQiR/Yc19I6JExktnV/jMo3g38WUh4UOuJFPCtnwQNgqNBWz/ jwj/yhwG7yCnnDH1Wr8/mUi1S/bzoFhnZgdzmgNi+9Z9c1Y16O+7iudoga7FBFqlmw ivFyyz0TVQG8bk9J+kX01vf/hJp/ZhtJX1lcs6F/LXWPAbc+qC8ZJ0tYJ8czO+oXs+ X0rs+dH2gHgERDMupASkJGaxgLQ60TROnchhafghw6pCN1LNZtx3tkYpMn5X5UQfKy sLx7wmZsJsBpg== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN >> Date: Tue, 28 May 2024 10:39:52 -0400 >> >> Eli Zaretskii <eliz@HIDDEN> writes: >> >> >> b/c does match bbb/ccc at the beginning, according to the >> >> partial-completion rules. Explained as a glob, partial-completion turns >> >> b/c into b*c which then can expand to bbb/ccc. >> > >> > Sorry, I don't understand what you are saying and how it addresses my >> > concern. To me, this example contradicts what was explained in the >> > documentation earlier, so we must clarify this, whether in the example >> > or in the preceding descriptions. Please re-read how you described >> > the effect of this option, and go from there. >> >> Okay, how about this completely reworked explanation? (It also changes >> the name of the variable and inverts its effect) > > Thanks, this is more clear now. > [snip] > and (b) please do not use examples with repeated characters, because > they can lead readers to make the wrong conclusions due to accidental > situations. For example, AFAIU valid candidates for "b*/c*" include > "bcdxyz/c1234" and also "b/x/y/z/c/1/2/3", but readers might > mistakenly think that "b*" stands for a string made only of "b", or > that there can be only one slash and it must precede "c". Avoiding > repeated characters prevents such misunderstandings. Excellent point, fixed. > But please (a) don't use "glob" and file wildcard notation, use > regexps instead; True, I removed the word "glob", I agree that's confusing since e.g. [a-z] or {foo,bar} are valid globs but not valid in partial-completion. Note however that "*" is literally valid syntax with partial-completion, where as the regexp notation (".*") is not. The partial-completion documentation already mentions this in (info "(emacs) Completion Styles"). So I slightly reworded it and continued using "*". --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-customizing-partial-completion-to-be-more-like.patch From b789f57aefd565bdbb8626fce129aa65e7a23af3 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Sun, 26 May 2024 08:57:37 -0400 Subject: [PATCH] Allow customizing partial-completion to be more like substring The substring completion style completes "foo-bar" as "*foo-bar*". The partial-completion completion style completes "foo-bar" as "foo*bar*". Previously, it was not possible to get completion of "foo-bar" to act as "*foo*bar*", e.g. combining the partial-completion and substring styles. This would be especially useful for things like project-find-file. Now it is possible by customizing the completion-pcm-anchored variable to a non-nil value. Furthermore, it's convenient to be able to run regular (completion-pcm-anchored=t, non-substring) partial-completion before running completion-pcm-anchored=nil partial-completion, since the former provides more narrowly targeted completions. It's possible to do this by customizing completion-styles. Just add '(partial-completion ((completion-pcm-anchored t))) and '(partial-completion ((completion-pcm-anchored nil))) in that order. Then the completion machinery will first run partial-completion with completion-pcm-anchored=t, and if that returns no completions, run partial-completion with completion-pcm-anchored=nil. * lisp/minibuffer.el (completion--nth-completion): Allow an element of completion-styles to contain a list of bindings. (completion-styles): Document that. (completion-pcm-anchored): Add. (completion-pcm--string->pattern): Check completion-pcm-anchored. (bug#70217) --- doc/emacs/mini.texi | 16 +++++++++++++-- etc/NEWS | 20 +++++++++++++++++++ lisp/minibuffer.el | 48 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 4557f41c3f7..cfb5df4d586 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -535,8 +535,14 @@ Completion Styles @vindex completion-styles The list variable @code{completion-styles} specifies the completion -styles to use. Each list element is the name of a completion style (a -Lisp symbol). The available style symbols are stored in the variable +styles to use. Each list element is either the name of a completion +style (a Lisp symbol) or a list starting with the name of a completion +style followed by @code{let}-style list of bindings which will be in +effect for that completion style. Multiple elements of +@code{completion-styles} can name the same completion style with +different variable bindings. + +The available style symbols are stored in the variable @code{completion-styles-alist} (@pxref{Completion Variables,,, elisp, The Emacs Lisp Reference Manual}). The default completion styles are (in order): @@ -561,6 +567,12 @@ Completion Styles @dfn{wildcard}---it matches any string of characters at the corresponding position in the completion alternative. +@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}. + @item emacs22 @cindex @code{emacs22}, completion style This completion style is similar to @code{basic}, except that it diff --git a/etc/NEWS b/etc/NEWS index d058acc3572..8eecc1d2aa3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1848,6 +1848,26 @@ customization group control exactly when Emacs displays this preview. 'completion-preview-mode' is buffer-local, to enable it globally use 'global-completion-preview-mode'. ++++ +*** New user option 'completion-pcm-leading-wildcard'. +This option configures how the partial-completion style does completion. +It defaults to nil, which preserves the existing behavior. When it is set +to t, the partial-completion style behaves more like the substring +style, in that a string being completed can match against a candidate +anywhere in the candidate string. + ++++ +*** 'completion-styles' now can contain lists of bindings. +In addition to being a symbol naming a completion style, an element of +'completion-styles' can now be a list of the form '(STYLE ((VARIABLE +VALUE) ...))' where STYLE is a symbol naming a completion style. +VARIABLE will be bound to VALUE (without evaluating it) while the style +is executing. This allows multiple references to the same style with +different values for completion-affecting variables like +'completion-pcm-leading-wildcard or 'completion-ignore-case'. This also +applies for the styles configuration in 'completion-category-overrides' +and 'completion-category-defaults'. + --- ** The highly accessible Modus themes collection has eight items. The 'modus-operandi' and 'modus-vivendi' are the main themes that have diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f62cb2566b2..355fd23eed8 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1141,7 +1141,15 @@ completion-styles ;; and simply add "bar" to the end of the result. emacs22) "List of completion styles to use. -The available styles are listed in `completion-styles-alist'. +An element should be a symbol which is listed in +`completion-styles-alist'. + +An element can also be a list of the form +(STYLE ((VARIABLE VALUE) ...)) +STYLE must be a symbol listed in `completion-styles-alist', followed by +a `let'-style list of variable/value pairs. VARIABLE will be bound to +VALUE (without evaluating it) while the style is handling completion. +This allows repeating the same style with different configurations. Note that `completion-category-overrides' may override these styles for specific categories, such as files, buffers, etc." @@ -1284,11 +1292,18 @@ completion--nth-completion (result-and-style (seq-some (lambda (style) - (let ((probe (funcall - (or (nth n (assq style completion-styles-alist)) - (error "Invalid completion style %s" style)) - string table pred point))) - (and probe (cons probe style)))) + (let (symbols values) + (when (consp style) + (dolist (binding (cadr style)) + (push (car binding) symbols) + (push (cadr binding) values)) + (setq style (car style))) + (cl-progv symbols values + (let ((probe (funcall + (or (nth n (assq style completion-styles-alist)) + (error "Invalid completion style %s" style)) + string table pred point))) + (and probe (cons probe style)))))) (completion--styles md))) (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))) (when (and adjust-fn metadata) @@ -3864,6 +3879,21 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) +(defcustom completion-pcm-leading-wildcard nil + "If non-nil, partial-completion completes as if there's a leading wildcard. + +If nil (the default), the partial-completion style completes a string +like \"o/t\" as if it was \"o*/t*\". This means \"one/two\" is a valid +completion, but not \"zero/one/two\" or \"zeroone/two\". + +If non-nil, the partial-completion style completes \"o/t\" as if it was +\"*o*/t*\". This means \"one/two\", \"zero/one/two\" and +\"zeroone/two\" are all valid completions. Note that this can be slower +to compute since less filtering of the completion candidates is +possible." + :version "30.1" + :type 'boolean) + (defun completion-pcm--string->pattern (string &optional point) "Split STRING into a pattern. A pattern is a list where each element is either a string @@ -3914,7 +3944,11 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (when completion-pcm-leading-wildcard + (when (stringp (car pattern)) + (push 'prefix pattern))) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" -- 2.39.3 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 18:38:01 +0000 Resent-Message-ID: <handler.70217.B70217.171692142630052 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171692142630052 (code B ref 70217); Tue, 28 May 2024 18:38:01 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 18:37:06 +0000 Received: from localhost ([127.0.0.1]:51414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sC1h3-0007oe-Q3 for submit <at> debbugs.gnu.org; Tue, 28 May 2024 14:37:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1sC1h1-0007o1-DP for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 14:37:04 -0400 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 <eliz@HIDDEN>) id 1sC1gl-00049G-RO; Tue, 28 May 2024 14:36:48 -0400 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=eGTLQ5UJ22QqCa6RC9EQCVTbEeydm4z3LTGLzTsxcoE=; b=TlGfXkRXS8ny P9XleMibDwWVDsrWyZyaxmuk6qwREy/iskRcrE2XSR6Pz4eFb1tH7FX5iiOrfy6cr23DbKBns2ZEj znUmaPY+g99TPhDwAtLmfWwORor2qFYg7Okue7kL5PaeoBy+mghF9f/rcj7yk4A7ru+lNjno77wZy 0m0kdkkAdN+Y9Iu53eSNLD5+dW+Yg+zaKtIuffS2SDYgtSYc8XVJ7ZrezfKMg3Q4uXC+ROnDemP7R Rc4B+CHWl+/vL5HuM7NVs/ITxo6FOvYtVTP0gRzGhUPQ0qGcgCZkldnbE/HMeLRbcDm4nqbCloG3r pDViT9uYywrGiKrZuNN/tQ==; Date: Tue, 28 May 2024 21:36:41 +0300 Message-Id: <86fru1u6km.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ierbk4p6bup.fsf@HIDDEN> (message from Spencer Baugh on Tue, 28 May 2024 14:16:30 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > Date: Tue, 28 May 2024 14:16:30 -0400 > > > and (b) please do not use examples with repeated characters, because > > they can lead readers to make the wrong conclusions due to accidental > > situations. For example, AFAIU valid candidates for "b*/c*" include > > "bcdxyz/c1234" and also "b/x/y/z/c/1/2/3", but readers might > > mistakenly think that "b*" stands for a string made only of "b", or > > that there can be only one slash and it must precede "c". Avoiding > > repeated characters prevents such misunderstandings. > > Excellent point, fixed. Thanks. > > But please (a) don't use "glob" and file wildcard notation, use > > regexps instead; > > True, I removed the word "glob", I agree that's confusing since > e.g. [a-z] or {foo,bar} are valid globs but not valid in > partial-completion. > > Note however that "*" is literally valid syntax with partial-completion, > where as the regexp notation (".*") is not. The partial-completion > documentation already mentions this in (info "(emacs) Completion > Styles"). So I slightly reworded it and continued using "*". Please don't. I really meant what I wrote: "glob" is confusing to users, because of the file-name wildcards connotation. The natural way of describing string patterns in Emacs is regular expressions, not globs.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 18:52:02 +0000 Resent-Message-ID: <handler.70217.B70217.171692231532204 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171692231532204 (code B ref 70217); Tue, 28 May 2024 18:52:02 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 18:51:55 +0000 Received: from localhost ([127.0.0.1]:52137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sC1vP-0008NM-2d for submit <at> debbugs.gnu.org; Tue, 28 May 2024 14:51:55 -0400 Received: from mxout1.mail.janestreet.com ([38.105.200.78]:33063) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sC1vM-0008N0-Gh for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 14:51:53 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86fru1u6km.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 28 May 2024 21:36:41 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> <86fru1u6km.fsf@HIDDEN> Date: Tue, 28 May 2024 14:51:37 -0400 Message-ID: <ier34q16a86.fsf@HIDDEN> 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=1716922297; bh=6KIu0FQSGworhQhaSSXklnS/3cIN2jYLBQNoHFlfkMw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=ZqaQ4P0Al7PpV6ocrC4yUuZLu3DiE9c4DpDoTFK4H3+5LcmU3UQzrQDIsRmx0sXzf aHyh/p0A9rmcwucjHfeRHXRRA7cbbPFlWaf8WvqIHg8KbPRlFyLr9yozrF5EtdkA6u 6j+rQiu5w6ElZFCz0J0rofCwyXNVPqjd3tdjd+ho8LnldMtc6EJDdwUbEwe5J2NSEZ LgLNLbzY4A323zRpDtfm6RFaN+ZYlLnPMBnFCQh2+5+cucbbuC1NCJe7DzYoge9XB6 rg5GzvqhbPkRlU5PKxEtL8f9oED2Xara608WIbuSduW6ZN6fN2Ymup6Pd4vVv5T4Lg ouq3tr52ngmag== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN >> Date: Tue, 28 May 2024 14:16:30 -0400 >> >> > and (b) please do not use examples with repeated characters, because >> > they can lead readers to make the wrong conclusions due to accidental >> > situations. For example, AFAIU valid candidates for "b*/c*" include >> > "bcdxyz/c1234" and also "b/x/y/z/c/1/2/3", but readers might >> > mistakenly think that "b*" stands for a string made only of "b", or >> > that there can be only one slash and it must precede "c". Avoiding >> > repeated characters prevents such misunderstandings. >> >> Excellent point, fixed. > > Thanks. > >> > But please (a) don't use "glob" and file wildcard notation, use >> > regexps instead; >> >> True, I removed the word "glob", I agree that's confusing since >> e.g. [a-z] or {foo,bar} are valid globs but not valid in >> partial-completion. >> >> Note however that "*" is literally valid syntax with partial-completion, >> where as the regexp notation (".*") is not. The partial-completion >> documentation already mentions this in (info "(emacs) Completion >> Styles"). So I slightly reworded it and continued using "*". > > Please don't. I really meant what I wrote: "glob" is confusing to > users, because of the file-name wildcards connotation. > > The natural way of describing string patterns in Emacs is regular > expressions, not globs. Just to be clear, if you type C-h v ffap-*-path TAB it will complete to variables whose name starts with "ffap-" and end with "-path". This is a partial-completion feature which has nothing to do with globs. I agree that the natural way of describing string patterns in Emacs is regular expressions, not globs. There are no globs in this docstring. I am mentioning only * which is what partial-completion natively supports. * has nothing to do with globs, it is a feature of partial-completion which is similar but distinct from shell globs. partial-completion works in terms of * not regular expressions, so it would be confusing to use a regular expression here.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 19:22:01 +0000 Resent-Message-ID: <handler.70217.B70217.17169240844039 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.17169240844039 (code B ref 70217); Tue, 28 May 2024 19:22:01 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 19:21:24 +0000 Received: from localhost ([127.0.0.1]:53389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sC2Nv-000131-LE for submit <at> debbugs.gnu.org; Tue, 28 May 2024 15:21:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1sC2Nt-00012S-L4 for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 15:21:22 -0400 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 <eliz@HIDDEN>) id 1sC2Ne-0002Dn-5O; Tue, 28 May 2024 15:21:06 -0400 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=zovdfYTYdZGrHj6/NG7Pyec8uv8J3+Iy++Rx7DvLwHg=; b=kdhsj/VctYEu /bD+qMxTAS6Ny+kzpRo4Wf46p7n6Nlb8wSJNuXSVksjWmoESRxcRspZd9DzOxlTQmorzny4Vmwxw6 F46iH1/cD3m1gB6HFrjmSePbzRayJPRuZrGNhIy/Yw7JlRAK9Z9FpEAPBBAKN1svwLnk9YEclb9Rp mtpORZpP4qoJ5/NliwRkJvF0lMdKAcS7XThH54t3UUx9mDJUNtPP/7joJkdFEhM1oxmb//nSygITs w0mSsw4zEFvxcEpujDyOmn3KJ5T4FhCQ7EkYlxa3FcDY1w4j8u2OTl/sc3Imea1jwbukhsliYLq8L J6FCTqm04glG4EBEGKKm6g==; Date: Tue, 28 May 2024 22:21:02 +0300 Message-Id: <86bk4pu4ip.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ier34q16a86.fsf@HIDDEN> (message from Spencer Baugh on Tue, 28 May 2024 14:51:37 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> <86fru1u6km.fsf@HIDDEN> <ier34q16a86.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > Date: Tue, 28 May 2024 14:51:37 -0400 > > Eli Zaretskii <eliz@HIDDEN> writes: > > >> From: Spencer Baugh <sbaugh@HIDDEN> > >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > >> Date: Tue, 28 May 2024 14:16:30 -0400 > >> > >> > and (b) please do not use examples with repeated characters, because > >> > they can lead readers to make the wrong conclusions due to accidental > >> > situations. For example, AFAIU valid candidates for "b*/c*" include > >> > "bcdxyz/c1234" and also "b/x/y/z/c/1/2/3", but readers might > >> > mistakenly think that "b*" stands for a string made only of "b", or > >> > that there can be only one slash and it must precede "c". Avoiding > >> > repeated characters prevents such misunderstandings. > >> > >> Excellent point, fixed. > > > > Thanks. > > > >> > But please (a) don't use "glob" and file wildcard notation, use > >> > regexps instead; > >> > >> True, I removed the word "glob", I agree that's confusing since > >> e.g. [a-z] or {foo,bar} are valid globs but not valid in > >> partial-completion. > >> > >> Note however that "*" is literally valid syntax with partial-completion, > >> where as the regexp notation (".*") is not. The partial-completion > >> documentation already mentions this in (info "(emacs) Completion > >> Styles"). So I slightly reworded it and continued using "*". > > > > Please don't. I really meant what I wrote: "glob" is confusing to > > users, because of the file-name wildcards connotation. > > > > The natural way of describing string patterns in Emacs is regular > > expressions, not globs. > > Just to be clear, if you type C-h v ffap-*-path TAB it will complete to > variables whose name starts with "ffap-" and end with "-path". This is > a partial-completion feature which has nothing to do with globs. > > I agree that the natural way of describing string patterns in Emacs is > regular expressions, not globs. There are no globs in this docstring. > I am mentioning only * which is what partial-completion natively > supports. * has nothing to do with globs, it is a feature of > partial-completion which is similar but distinct from shell globs. > > partial-completion works in terms of * not regular expressions, so it > would be confusing to use a regular expression here. I know. But you are not talking about partial completion in that text, you are talking about strings that match or don't match. The natural way of describing those is regular expressions. If you don't want to use regular expressions here, you will need to explain them in words. That's fine by me, but it will make the job harder for you, and the text will be longer. That's why I suggested to use regexps.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 28 May 2024 20:03:02 +0000 Resent-Message-ID: <handler.70217.B70217.17169265329837 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.17169265329837 (code B ref 70217); Tue, 28 May 2024 20:03:02 +0000 Received: (at 70217) by debbugs.gnu.org; 28 May 2024 20:02:12 +0000 Received: from localhost ([127.0.0.1]:55085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sC31P-0002YY-Uo for submit <at> debbugs.gnu.org; Tue, 28 May 2024 16:02:12 -0400 Received: from mxout1.mail.janestreet.com ([38.105.200.78]:48581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sC31N-0002YH-8m for 70217 <at> debbugs.gnu.org; Tue, 28 May 2024 16:02:10 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86bk4pu4ip.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 28 May 2024 22:21:02 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> <86fru1u6km.fsf@HIDDEN> <ier34q16a86.fsf@HIDDEN> <86bk4pu4ip.fsf@HIDDEN> Date: Tue, 28 May 2024 16:01:53 -0400 Message-ID: <ierzfs94sem.fsf@HIDDEN> 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=1716926513; bh=4sAsnBE7ppoONy3dy59AdRm8ndJ9u/qqEi0b/utwa2I=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=STjbBA/N8A4QUTqERXcaL1r+uc6VoabpDwi3x4GncgL7tbHnmiMqVTw74cQu96aO7 ONkwm9gg/zW8sz6XhoSGBRhSBSlorCKsTYaEEw3/JXwlOHw4KxThGHxEPObbDpPeXJ xMtTkAp5ojj3JavzZFvQ/3NFrLfktvOOJ5/P2Ud9j19nm+0LsbTFe874Dzeezmjphn J2wjhWiKxPZZQ+iDusIXwkh56NLkyagdOV9A8kNTIZg3QqbjZq7I4sGFm7IlkMib7X V7XvxrvhcMKp3AoduaG+tbFa74dBestmzEVDlhCBD6ya2NhWgxIOd794Vv+A1+DyJT pCKS1Mt1DS3SQ== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN >> Date: Tue, 28 May 2024 14:51:37 -0400 >> >> Eli Zaretskii <eliz@HIDDEN> writes: >> >> >> From: Spencer Baugh <sbaugh@HIDDEN> >> >> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN >> >> Date: Tue, 28 May 2024 14:16:30 -0400 >> >> >> >> > and (b) please do not use examples with repeated characters, because >> >> > they can lead readers to make the wrong conclusions due to accidental >> >> > situations. For example, AFAIU valid candidates for "b*/c*" include >> >> > "bcdxyz/c1234" and also "b/x/y/z/c/1/2/3", but readers might >> >> > mistakenly think that "b*" stands for a string made only of "b", or >> >> > that there can be only one slash and it must precede "c". Avoiding >> >> > repeated characters prevents such misunderstandings. >> >> >> >> Excellent point, fixed. >> > >> > Thanks. >> > >> >> > But please (a) don't use "glob" and file wildcard notation, use >> >> > regexps instead; >> >> >> >> True, I removed the word "glob", I agree that's confusing since >> >> e.g. [a-z] or {foo,bar} are valid globs but not valid in >> >> partial-completion. >> >> >> >> Note however that "*" is literally valid syntax with partial-completion, >> >> where as the regexp notation (".*") is not. The partial-completion >> >> documentation already mentions this in (info "(emacs) Completion >> >> Styles"). So I slightly reworded it and continued using "*". >> > >> > Please don't. I really meant what I wrote: "glob" is confusing to >> > users, because of the file-name wildcards connotation. >> > >> > The natural way of describing string patterns in Emacs is regular >> > expressions, not globs. >> >> Just to be clear, if you type C-h v ffap-*-path TAB it will complete to >> variables whose name starts with "ffap-" and end with "-path". This is >> a partial-completion feature which has nothing to do with globs. >> >> I agree that the natural way of describing string patterns in Emacs is >> regular expressions, not globs. There are no globs in this docstring. >> I am mentioning only * which is what partial-completion natively >> supports. * has nothing to do with globs, it is a feature of >> partial-completion which is similar but distinct from shell globs. >> >> partial-completion works in terms of * not regular expressions, so it >> would be confusing to use a regular expression here. > > I know. But you are not talking about partial completion in that > text, you are talking about strings that match or don't match. The > natural way of describing those is regular expressions. Okay, I'll remove mention of matching, and try to make it clear that I'm just talking about completion. How about one of the following two options? If non-nil, partial-completion completes as if there's a leading 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 `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. Or: If non-nil, partial-completion completes as if there's a leading wildcard. partial-completion interprets "*" as a wildcard, replacing it with any string of characters while completing. partial-completion also adds wildcards before characters in `completion-pcm-word-delimiters', and adds a wildcard at the end of the minibuffer text; the behavior is identical to typing "*" at all of those sites. If nil (the default), "a/b" will complete the same as if you had typed "a*/b*". If non-nil, partial-completion additionally adds a wildcard at the start of the string; then "a/b" will complete the same as if you had typed "*a*/b*". This makes partial-completion behave more like the substring completion style.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 01 Jun 2024 14:21:02 +0000 Resent-Message-ID: <handler.70217.B70217.171725165827509 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171725165827509 (code B ref 70217); Sat, 01 Jun 2024 14:21:02 +0000 Received: (at 70217) by debbugs.gnu.org; 1 Jun 2024 14:20:58 +0000 Received: from localhost ([127.0.0.1]:56987 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sDPbO-00079d-4A for submit <at> debbugs.gnu.org; Sat, 01 Jun 2024 10:20:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1sDPbL-00079Q-Nu for 70217 <at> debbugs.gnu.org; Sat, 01 Jun 2024 10:20:56 -0400 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 <eliz@HIDDEN>) id 1sDPb4-00036D-Nj; Sat, 01 Jun 2024 10:20:38 -0400 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=otoTtiaK3ad1E/Au2Nn0+5fWfpGp5ShAq/7alNkKUHw=; b=DMmn4b7q74Gs fg7vOmkRZCtQ9ou4x+mLqbhS/1Dte86PA369AJ8MAZi4f0exrHT1W2uAW2hD8SrkDTTtUASOYG9DR U7VOse8CX0JNm37xQF4bJ8pFed5+PyRPkW31PO9W/bwGZpNbKbtr0iE5y5aMK4nCBSKMJkDOLw4X1 LKcxRbPtw6Rm14VK4lG621D4GHhs2m9KdMqzXI0Kw0zOBbUxbgxyWe0LBCZSOxWFOt06DIuUruDSV 4vxH9IBysPWhm2vRW4niwPqo4jM/EWLfgzKJA+QEocAf5UEcU3ghqEDQZHKR67EcjiojnroPrcoDH p0KlXoqucSfsZY12eflS2w==; Date: Sat, 01 Jun 2024 17:20:36 +0300 Message-Id: <86plt0oibv.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <ierzfs94sem.fsf@HIDDEN> (message from Spencer Baugh on Tue, 28 May 2024 16:01:53 -0400) References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> <86fru1u6km.fsf@HIDDEN> <ier34q16a86.fsf@HIDDEN> <86bk4pu4ip.fsf@HIDDEN> <ierzfs94sem.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN > Date: Tue, 28 May 2024 16:01:53 -0400 > > Okay, I'll remove mention of matching, and try to make it clear that I'm > just talking about completion. How about one of the following two > options? Thanks, I think the first one is better.
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 02 Jun 2024 12:17:02 +0000 Resent-Message-ID: <handler.70217.B70217.171733058429840 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii <eliz@HIDDEN> Cc: 70217 <at> debbugs.gnu.org, monnier@HIDDEN Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171733058429840 (code B ref 70217); Sun, 02 Jun 2024 12:17:02 +0000 Received: (at 70217) by debbugs.gnu.org; 2 Jun 2024 12:16:24 +0000 Received: from localhost ([127.0.0.1]:58006 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sDk8N-0007lD-7E for submit <at> debbugs.gnu.org; Sun, 02 Jun 2024 08:16:24 -0400 Received: from mxout6.mail.janestreet.com ([64.215.233.21]:45683) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1sDk8J-0007ke-JJ for 70217 <at> debbugs.gnu.org; Sun, 02 Jun 2024 08:16:22 -0400 From: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <86plt0oibv.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 01 Jun 2024 17:20:36 +0300") References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> <86fru1u6km.fsf@HIDDEN> <ier34q16a86.fsf@HIDDEN> <86bk4pu4ip.fsf@HIDDEN> <ierzfs94sem.fsf@HIDDEN> <86plt0oibv.fsf@HIDDEN> Date: Sun, 02 Jun 2024 08:16:01 -0400 Message-ID: <ierbk4jh75q.fsf@HIDDEN> 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=1717330561; bh=N7lEOIuoxJXe1y2/Oo5xe6QxjqxjFvKRFO39zhfisJg=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=LDdXcZeQtOyzn5fIPWPUQJZ1Ei6uGPlYLTW79aCNOaqVl6DvVuJLkjpQUIDeOkCXn lIfTHk42Ht/jbsSzQvJhn6kuqa5Zz+6U+ATLXKLo3zLwikQ5KrqBSdbU+oT9F9/FHn yISU06pFYh3H0yiVIFkbSvHQAUTTybK8KycDE+boWlZaxJzDkD1zFqs8SlU4+tQdH8 aQBl1UASx9hiLQU8F00XcM+GeJZ9tYx87pkmLfUTu1D/jBE4hdealU4NvIpNCCKfJt 0Ta+pXKA3+iDkg/QkdV0YqayWSFjL8rGF9EpHJQJcB/krsFzmmjNUePBhzPib1KOTd eZY3mGBZxTzig== X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain It seems like we're almost ready to install this patch. Stefan - it would be nice to know if you think this approach of including dynamic variable bindings in completion-styles is a good idea, or at least an acceptable idea. I can go back to the drawing board if this clashes with your vision/design/theory for completion styles. Eli Zaretskii <eliz@HIDDEN> writes: > Thanks, I think the first one is better. Updated with the new docstring. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-customizing-partial-completion-to-be-more-like.patch From 9f90123afe89e64861d6dca6d4c39a6387e0e720 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Sun, 26 May 2024 08:57:37 -0400 Subject: [PATCH] Allow customizing partial-completion to be more like substring The substring completion style completes "foo-bar" as "*foo-bar*". The partial-completion completion style completes "foo-bar" as "foo*bar*". Previously, it was not possible to get completion of "foo-bar" to act as "*foo*bar*", e.g. combining the partial-completion and substring styles. This would be especially useful for things like project-find-file. Now it is possible by customizing the completion-pcm-anchored variable to a non-nil value. Furthermore, it's convenient to be able to run regular (completion-pcm-anchored=t, non-substring) partial-completion before running completion-pcm-anchored=nil partial-completion, since the former provides more narrowly targeted completions. It's possible to do this by customizing completion-styles. Just add '(partial-completion ((completion-pcm-anchored t))) and '(partial-completion ((completion-pcm-anchored nil))) in that order. Then the completion machinery will first run partial-completion with completion-pcm-anchored=t, and if that returns no completions, run partial-completion with completion-pcm-anchored=nil. * lisp/minibuffer.el (completion--nth-completion): Allow an element of completion-styles to contain a list of bindings. (completion-styles): Document that. (completion-pcm-anchored): Add. (completion-pcm--string->pattern): Check completion-pcm-anchored. (bug#70217) --- doc/emacs/mini.texi | 16 +++++++++++++-- etc/NEWS | 20 +++++++++++++++++++ lisp/minibuffer.el | 48 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 4557f41c3f7..cfb5df4d586 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -535,8 +535,14 @@ Completion Styles @vindex completion-styles The list variable @code{completion-styles} specifies the completion -styles to use. Each list element is the name of a completion style (a -Lisp symbol). The available style symbols are stored in the variable +styles to use. Each list element is either the name of a completion +style (a Lisp symbol) or a list starting with the name of a completion +style followed by @code{let}-style list of bindings which will be in +effect for that completion style. Multiple elements of +@code{completion-styles} can name the same completion style with +different variable bindings. + +The available style symbols are stored in the variable @code{completion-styles-alist} (@pxref{Completion Variables,,, elisp, The Emacs Lisp Reference Manual}). The default completion styles are (in order): @@ -561,6 +567,12 @@ Completion Styles @dfn{wildcard}---it matches any string of characters at the corresponding position in the completion alternative. +@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}. + @item emacs22 @cindex @code{emacs22}, completion style This completion style is similar to @code{basic}, except that it diff --git a/etc/NEWS b/etc/NEWS index 3c672ffed8f..db1582b86f6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1868,6 +1868,26 @@ customization group control exactly when Emacs displays this preview. 'completion-preview-mode' is buffer-local, to enable it globally use 'global-completion-preview-mode'. ++++ +*** New user option 'completion-pcm-leading-wildcard'. +This option configures how the partial-completion style does completion. +It defaults to nil, which preserves the existing behavior. When it is set +to t, the partial-completion style behaves more like the substring +style, in that a string being completed can match against a candidate +anywhere in the candidate string. + ++++ +*** 'completion-styles' now can contain lists of bindings. +In addition to being a symbol naming a completion style, an element of +'completion-styles' can now be a list of the form '(STYLE ((VARIABLE +VALUE) ...))' where STYLE is a symbol naming a completion style. +VARIABLE will be bound to VALUE (without evaluating it) while the style +is executing. This allows multiple references to the same style with +different values for completion-affecting variables like +'completion-pcm-leading-wildcard or 'completion-ignore-case'. This also +applies for the styles configuration in 'completion-category-overrides' +and 'completion-category-defaults'. + --- ** The highly accessible Modus themes collection has eight items. The 'modus-operandi' and 'modus-vivendi' are the main themes that have diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index f62cb2566b2..62d113499dd 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1141,7 +1141,15 @@ completion-styles ;; and simply add "bar" to the end of the result. emacs22) "List of completion styles to use. -The available styles are listed in `completion-styles-alist'. +An element should be a symbol which is listed in +`completion-styles-alist'. + +An element can also be a list of the form +(STYLE ((VARIABLE VALUE) ...)) +STYLE must be a symbol listed in `completion-styles-alist', followed by +a `let'-style list of variable/value pairs. VARIABLE will be bound to +VALUE (without evaluating it) while the style is handling completion. +This allows repeating the same style with different configurations. Note that `completion-category-overrides' may override these styles for specific categories, such as files, buffers, etc." @@ -1284,11 +1292,18 @@ completion--nth-completion (result-and-style (seq-some (lambda (style) - (let ((probe (funcall - (or (nth n (assq style completion-styles-alist)) - (error "Invalid completion style %s" style)) - string table pred point))) - (and probe (cons probe style)))) + (let (symbols values) + (when (consp style) + (dolist (binding (cadr style)) + (push (car binding) symbols) + (push (cadr binding) values)) + (setq style (car style))) + (cl-progv symbols values + (let ((probe (funcall + (or (nth n (assq style completion-styles-alist)) + (error "Invalid completion style %s" style)) + string table pred point))) + (and probe (cons probe style)))))) (completion--styles md))) (adjust-fn (get (cdr result-and-style) 'completion--adjust-metadata))) (when (and adjust-fn metadata) @@ -3864,6 +3879,21 @@ completion-pcm--pattern-trivial-p (setq trivial nil))) trivial))) +(defcustom completion-pcm-leading-wildcard nil + "If non-nil, partial-completion completes as if there's a leading 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 +`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." + :version "30.1" + :type 'boolean) + (defun completion-pcm--string->pattern (string &optional point) "Split STRING into a pattern. A pattern is a list where each element is either a string @@ -3914,7 +3944,11 @@ completion-pcm--string->pattern (when (> (length string) p0) (if pending (push pending pattern)) (push (substring string p0) pattern)) - (nreverse pattern)))) + (setq pattern (nreverse pattern)) + (when completion-pcm-leading-wildcard + (when (stringp (car pattern)) + (push 'prefix pattern))) + pattern))) (defun completion-pcm--optimize-pattern (p) ;; Remove empty strings in a separate phase since otherwise a "" -- 2.39.3 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#70217: [PATCH] Add substring-partial-completion style Resent-From: Stefan Monnier <monnier@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 02 Jun 2024 14:35:02 +0000 Resent-Message-ID: <handler.70217.B70217.171733887626374 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 70217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh <sbaugh@HIDDEN> Cc: Eli Zaretskii <eliz@HIDDEN>, 70217 <at> debbugs.gnu.org Received: via spool by 70217-submit <at> debbugs.gnu.org id=B70217.171733887626374 (code B ref 70217); Sun, 02 Jun 2024 14:35:02 +0000 Received: (at 70217) by debbugs.gnu.org; 2 Jun 2024 14:34:36 +0000 Received: from localhost ([127.0.0.1]:60113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sDmI7-0006rK-Rx for submit <at> debbugs.gnu.org; Sun, 02 Jun 2024 10:34:36 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16331) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1sDmI4-0006r6-VM for 70217 <at> debbugs.gnu.org; Sun, 02 Jun 2024 10:34:34 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2E89A8089D; Sun, 2 Jun 2024 10:34:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1717338854; bh=PkGAVoZGmUQQwu2XuMbeu7sSKEqqrDP82Slxx1ewPhE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=VTodBKcO6MwcnV0UCHBHrp3kaB7hc6ddWTiOVG71pX7dO3Ut9wty8Rcpsvye9KtmZ veCq7wjNIQxtlVNU6LZuv5hmSGBHkV9r16x23FvnHy2NtS/Glc2dLuEzAGUklcKGxm VijPNwM6cZEBSFbcXTS2yABO7XpmhtE1xkCropy2cGPfKmXANrFwP49smblF/FIIbk 816E3xcSFH+8Yf8/C4Ccyd+GeeDp+x4S3QYvpxhmtaDngEoeblNdZxJPRGGAP4rnR3 qEAhrmpzY+YsmRycqejF39qYM2VzDftZNlJ2Zj0v+E1BJIYStVzY3TJIc5Du3Bbscn lHwBiqGOXZd/Q== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0F29A806EF; Sun, 2 Jun 2024 10:34:14 -0400 (EDT) Received: from pastel (unknown [24.140.236.196]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D7B421201A6; Sun, 2 Jun 2024 10:34:13 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> In-Reply-To: <ierbk4jh75q.fsf@HIDDEN> (Spencer Baugh's message of "Sun, 02 Jun 2024 08:16:01 -0400") Message-ID: <jwvttibpg7k.fsf-monnier+emacs@HIDDEN> References: <ier5xwwugl0.fsf@HIDDEN> <jwvplv3acwc.fsf-monnier+emacs@HIDDEN> <ieril0ebswn.fsf@HIDDEN> <ieredacqmjb.fsf@HIDDEN> <jwvedacjkor.fsf-monnier+emacs@HIDDEN> <ierv83dtsef.fsf@HIDDEN> <86a5kpgdo7.fsf@HIDDEN> <ierbk4t7fjt.fsf@HIDDEN> <86ttilvsy8.fsf@HIDDEN> <ier34q47mlm.fsf@HIDDEN> <86ikz0wozc.fsf@HIDDEN> <ierjzje57bb.fsf@HIDDEN> <86o78qt1hl.fsf@HIDDEN> <ierbk4p6bup.fsf@HIDDEN> <86fru1u6km.fsf@HIDDEN> <ier34q16a86.fsf@HIDDEN> <86bk4pu4ip.fsf@HIDDEN> <ierzfs94sem.fsf@HIDDEN> <86plt0oibv.fsf@HIDDEN> <ierbk4jh75q.fsf@HIDDEN> Date: Sun, 02 Jun 2024 10:34:13 -0400 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.039 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Stefan - it would be nice to know if you think this approach of > including dynamic variable bindings in completion-styles is a good idea, > or at least an acceptable idea. I can go back to the drawing board if > this clashes with your vision/design/theory for completion styles. I think it's acceptable, yes. Stefan
Received: (at control) by debbugs.gnu.org; 30 Jun 2024 05:51:50 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 30 01:51:50 2024 Received: from localhost ([127.0.0.1]:54572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1sNnTa-0007Rd-4R for submit <at> debbugs.gnu.org; Sun, 30 Jun 2024 01:51:50 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:46537) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1sNnTY-0007RO-FT for control <at> debbugs.gnu.org; Sun, 30 Jun 2024 01:51:48 -0400 Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-57d10354955so2377795a12.1 for <control <at> debbugs.gnu.org>; Sat, 29 Jun 2024 22:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719726643; x=1720331443; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=n39RZj3ZU8NvXcBTTryaGrJKsxji89pr0ezc7LknxAI=; b=cFG8QPkvMhb4q8mKNARKw9t0Z7RprF6IQ8VRtqoxmBdrr0SuTKHsnMocSVBsOtj373 z129rYBcS9wlQmfuI3TXE27/1Ae7Vvjc6v1V1vVj5RySL2yKArY0Cb8Zm06ygFPR6IWk rRg64IeQ2rf1t/T8Y1wVjqF4/U2XqevDM1LPDOmrMpI7qjhpIatFWQKLt7NWfelmNbKz eDx/LYmHzkHXPzA0wyM+bTmk6NvGx4ju7xq0RCCrmX4XETFoc2JMFMSlZhxl/ttEENfX UGKbtwhD3/koq4K55Rwhlno5OTZyTG+emnxoKVCJHOB/3orqqxohBB7aTVbCwtfybZKW lzcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719726643; x=1720331443; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=n39RZj3ZU8NvXcBTTryaGrJKsxji89pr0ezc7LknxAI=; b=plPUwtGDTcDBzS0j9h0Ab0d7NwBliF+PM5E8T/Q5u+GY47WU1rL3F0f7QL9P7bx1EH 2xklxo0Spc/2TjiA+1i3LQLGLOguXLyqPn+z7GR/YTjABtdFVEuuaClWFisOEQRuwL3X 8mT5+X3O0TdiLv1YIl/UaSltJ16woHy1PGt1UF6htioTG42VR+uhglXUc17JVAy4dnaR ejc8argNVNtL4rogdnnXrWMcygPoxI9VZOPCIbytprgYA7OPC6ABxNI1ED/Ew6zqlILN 0VUwikANyauSw9HGlA2NYkn8i1u3/3WPCWwrkOmQFyDEpu9r4IBwgMcCYmib+VdSJRIx VDPg== X-Gm-Message-State: AOJu0Yys2UYwj9RPB5L8IgsPxksjRm7XT3bP/2HwE26OY3+BUuJjE4sJ ppSbxWnwLnrmxDqF4Qzs1B3WAnS/qzP6t5itU7X/ulP3tDN98zpF6PM1Y/YUpqXEIItI16dR2so jBB886Zm4mK6c67v/Sk4aoUYeCtV6vXO+YsI= X-Google-Smtp-Source: AGHT+IHBVyv2DLQxe9zRcy7Z166lcIWO4pefzp+Ttmu0iVDwDyP97R+0vDQ/KVwIUhnAmrdiLKSQ+JQ30e6pYz7mPQ0= X-Received: by 2002:a05:6402:1941:b0:57c:5fcf:b570 with SMTP id 4fb4d7f45d1cf-587a0bfc728mr1583660a12.32.1719726643035; Sat, 29 Jun 2024 22:50:43 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 29 Jun 2024 22:50:42 -0700 From: Stefan Kangas <stefankangas@HIDDEN> MIME-Version: 1.0 Date: Sat, 29 Jun 2024 22:50:42 -0700 Message-ID: <CADwFkmnca1dqDA_NpFYaCD2S-DpR=p+Pb3gUCTavw81OyXpDNw@HIDDEN> Subject: control message for bug #70217 To: control <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) severity 70217 wishlist quit
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.