From unknown Sat Aug 09 09:32:23 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#77649 <77649@debbugs.gnu.org> To: bug#77649 <77649@debbugs.gnu.org> Subject: Status: [PATCH] Add support for updating *Completions* as you type Reply-To: bug#77649 <77649@debbugs.gnu.org> Date: Sat, 09 Aug 2025 16:32:23 +0000 retitle 77649 [PATCH] Add support for updating *Completions* as you type reassign 77649 emacs submitter 77649 Spencer Baugh severity 77649 normal tag 77649 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 08 11:17:39 2025 Received: (at submit) by debbugs.gnu.org; 8 Apr 2025 15:17:40 +0000 Received: from localhost ([127.0.0.1]:34673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2Ahm-0006wB-O6 for submit@debbugs.gnu.org; Tue, 08 Apr 2025 11:17:39 -0400 Received: from lists.gnu.org ([2001:470:142::17]:44330) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2Ahg-0006v5-UA for submit@debbugs.gnu.org; Tue, 08 Apr 2025 11:17:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2AhX-0001J9-QW for bug-gnu-emacs@gnu.org; Tue, 08 Apr 2025 11:17:25 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u2AhU-0008EK-FQ for bug-gnu-emacs@gnu.org; Tue, 08 Apr 2025 11:17:23 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: [PATCH] Add support for updating *Completions* as you type X-Debbugs-Cc: Juri Linkov , Daniel Mendler Date: Tue, 08 Apr 2025 11:17:17 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744125437; bh=j7xUin6IA7oI0Rd44lnMlLtDutJF3wRHDPtrQpkvBZo=; h=From:To:Subject:Date; b=viI2vhmiMaBwz4QI4BbeY8Bxdcf2FexExYnJV5cmbq3x8JhJWwR7yJ9qtrXW1kxop gG8gvJZZBdl7GxEi/XX7sN5Kn47sUt6hj2G9dl0v58kAjvtWPsdnD/D4mTDbFIsDo3 QuVJOvYYU520047s04XPhG74Dnu0cZCGuCbHyT1xuVFS/DogMGIJ2qAcOzLYUDN7Z2 ECzc99tfZwiayaR4L6rU3OeMAtPXyeWw2ERXdUkgVebOylaZJXxZZagYt8+KDG248J YqvoJVmJLZXIQEEyIP+kDRXZZf0W0LiyG64VxmbVGCwipkcxh+ci9lRT6DEPLu/jI3 7xBB/SDi9yWNg== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch Add support for updating the *Completions* buffer as you type, controlled by a new completion metadata symbol 'eager-update and new defcustom completion-eager-update. You can configure a completion category to update *Completions* as you type by setting completion-category-overrides appropriately; or set completion-eager-update to t to always update *Completions* as you type. This is similar to the recently added completion-eager-display. In GNU Emacs 30.1.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2025-04-03 built on igm-qws-u22796a Repository revision: e0d429965010d82a05225e53ba6fbb97bea23ae9 Repository branch: emacs-30 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --config-cache --with-x-toolkit=lucid --without-gpm --without-gconf --without-selinux --without-imagemagick --with-modules --with-gif=no --with-cairo --with-rsvg --without-compress-install --with-tree-sitter --with-native-compilation=aot' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-support-for-updating-Completions-as-you-type.patch >From fbfafdc708e8d78ceec4723373ac9bc7da30dd4f Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Thu, 3 Apr 2025 15:38:22 -0400 Subject: [PATCH] Add support for updating *Completions* as you type Add support for updating the *Completions* buffer as you type, controlled by a new completion metadata symbol 'eager-update and new defcustom completion-eager-update. You can configure a completion category to update *Completions* as you type by setting completion-category-overrides appropriately; or set completion-eager-update to t to always update *Completions* as you type. This is similar to the recently added completion-eager-display. * lisp/minibuffer.el (completion-eager-update): Add new defcustom defaulting to 'auto. (completion--eager-update-p, completions--background-update) (completions--post-command-update): Add. (completions--after-change): Call completions--post-command-update via post-command-hook. (minibuffer-completion-help): Check completion-eager-update and install completions--after-change. (completion-help-at-point): Call completion--eager-update-p if ONLY-IF-EAGER is non-nil. --- lisp/minibuffer.el | 59 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 1b78fab3d6e..6d5a96f875c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1070,6 +1070,21 @@ completion-eager-display (const :tag "If requested by the completion command" auto)) :version "31.1") +(defcustom completion-eager-update 'auto + "Whether typing should update the *Completions* buffer eagerly. + +If `t', always update as you type. + +If `auto', only update if the completion table has requested it or +`eager-update' is set in in `completion-category-defaults'. + +This only affects the *Completions* buffer if it is already +displayed." + :type '(choice (const :tag "Do nothing when you type" nil) + (const :tag "Auto-update based on the category" auto) + (const :tag "Always update as you type" t)) + :version "31.1") + (defcustom completion-auto-help t "Non-nil means automatically provide help for invalid completion input. If the value is t, the *Completions* buffer is displayed whenever completion @@ -2646,12 +2661,43 @@ completions--deselect (goto-char (or (next-single-property-change (point) 'completion--string) (point-max))))) +(defun completion--eager-update-p (start) + "Return non-nil if *Completions* should be automatically updated. + +If `completion-eager-update' is the symbol `auto', checks completion +metadata for the string from START to point." + (if (eq completion-eager-update 'auto) + (completion-metadata-get (completion--field-metadata start) 'eager-update) + completion-eager-update)) + +(defun completions--background-update () + "Try to update *Completions* without blocking input. + +This function uses `while-no-input' and sets `non-essential' to t +so that the update is less likely to interfere with user typing." + (while-no-input + (let ((non-essential t)) + (redisplay) + (cond + (completion-in-region-mode (completion-help-at-point t)) + ((completion--eager-update-p (minibuffer-prompt-end)) + (minibuffer-completion-help)))))) + +(defun completions--post-command-update () + "Update displayed *Completions* buffer after command, once." + (remove-hook 'post-command-hook #'completions--post-command-update) + (when (and completion-eager-update (get-buffer-window "*Completions*" 0)) + (completions--background-update))) + (defun completions--after-change (_start _end _old-len) "Update displayed *Completions* buffer after change in buffer contents." - (when completion-auto-deselect + (when (or completion-auto-deselect completion-eager-update) (when-let* ((window (get-buffer-window "*Completions*" 0))) - (with-selected-window window - (completions--deselect))))) + (when completion-auto-deselect + (with-selected-window window + (completions--deselect))) + (when completion-eager-update + (add-hook 'post-command-hook #'completions--post-command-update))))) (defun minibuffer-completion-help (&optional start end) "Display a list of possible completions of the current minibuffer contents." @@ -2742,7 +2788,7 @@ minibuffer-completion-help (body-function . ,#'(lambda (window) (with-current-buffer mainbuf - (when completion-auto-deselect + (when (or completion-auto-deselect completion-eager-update) (add-hook 'after-change-functions #'completions--after-change nil t)) ;; Remove the base-size tail because `sort' requires a properly ;; nil-terminated list. @@ -3131,7 +3177,7 @@ completion-at-point (car res))) (cdr res))))) -(defun completion-help-at-point () +(defun completion-help-at-point (&optional only-if-eager) "Display the completions on the text around point. The completion method is determined by `completion-at-point-functions'." (interactive) @@ -3158,7 +3204,8 @@ completion-help-at-point `(,start ,(copy-marker end t) ,collection ,(plist-get plist :predicate))) (completion-in-region-mode 1) - (minibuffer-completion-help start end))) + (when (or (not only-if-eager) (completion--eager-update-p start)) + (minibuffer-completion-help start end)))) (`(,hookfun . ,_) ;; The hook function already performed completion :-( ;; Not much we can do at this point. -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 08 14:35:26 2025 Received: (at 77649) by debbugs.gnu.org; 8 Apr 2025 18:35:27 +0000 Received: from localhost ([127.0.0.1]:35446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2DnC-0004fU-Iy for submit@debbugs.gnu.org; Tue, 08 Apr 2025 14:35:26 -0400 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]:45335) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2Dn8-0004f3-05 for 77649@debbugs.gnu.org; Tue, 08 Apr 2025 14:35:23 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1C1624434E; Tue, 8 Apr 2025 18:35:05 +0000 (UTC) From: Juri Linkov To: Spencer Baugh Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: Organization: LINKOV.NET References: Date: Tue, 08 Apr 2025 21:33:31 +0300 Message-ID: <87jz7ulczo.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvtdefkeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopehmrghilhesuggrnhhivghlqdhmvghnughlvghrrdguvgdprhgtphhtthhopeejjeeigeelseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepshgsrghughhhsehjrghnvghsthhrvggvthdrtghomh X-GND-Sasl: juri@linkov.net X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 77649 Cc: Daniel Mendler , 77649@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > Add support for updating the *Completions* buffer as you type, > controlled by a new completion metadata symbol 'eager-update and > new defcustom completion-eager-update. > > You can configure a completion category to update *Completions* > as you type by setting completion-category-overrides > appropriately; or set completion-eager-update to t to always > update *Completions* as you type. > > This is similar to the recently added completion-eager-display. Thanks, now finally we'll have this long-needed feature. The first question: should it depend on the value of 'minibuffer-visible-completions'? OTOH, even when it's nil, *Completions* can be displayed by non-nil completion-eager-display. So the only problem is that when the *Completions* window is removed (e.g. when no candidates remains), it never comes back to the display (e.g. after deleting previous characters). Or maybe this is not a problem, I have to test it more. From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 08 15:08:25 2025 Received: (at 77649) by debbugs.gnu.org; 8 Apr 2025 19:08:26 +0000 Received: from localhost ([127.0.0.1]:35519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u2EJ7-0006H6-Ec for submit@debbugs.gnu.org; Tue, 08 Apr 2025 15:08:25 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:51553) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u2EJ3-0006Gq-Nx for 77649@debbugs.gnu.org; Tue, 08 Apr 2025 15:08:22 -0400 From: Spencer Baugh To: Juri Linkov Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: <87jz7ulczo.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 08 Apr 2025 21:33:31 +0300") References: <87jz7ulczo.fsf@mail.linkov.net> Date: Tue, 08 Apr 2025 15:00:35 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1744138835; bh=56xbSoVXF4VFeXKKbOvZS2kqVZn16Ek3XBdGXb3vEZc=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=0M1Fie9hp3FqxZGKpRXxjZVp9YEkA1SQDc9ZAEfzEsBT7/pNDNy6YAyrXHbG6rPdA vsxvuqICed5KI3UjMEsl5HbafQp4Flgg1MMtgF04RFtRO5qAEMRESbmfJdRtmo4Ixb /0dMOiLsGouCsAM+Agc+OLAz7SyJUs08JehInLCrI7jTpqMAOsQLbg3wg5f7LIGrAz sPNnefXwaN0JLvrGnqQnYqBGHA8wH1QHoZM7PwLo7br+ucjkbTx3ZXCeTrScVl/Yyo MpHzkdW7jZ5TK9S5HrZd5U2ZUacyrJutyW+kPQiZLSOwF3mejz4hq7N7YKxci2/IzD fXdzPffDJwohw== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77649 Cc: Daniel Mendler , 77649@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Juri Linkov writes: >> Add support for updating the *Completions* buffer as you type, >> controlled by a new completion metadata symbol 'eager-update and >> new defcustom completion-eager-update. >> >> You can configure a completion category to update *Completions* >> as you type by setting completion-category-overrides >> appropriately; or set completion-eager-update to t to always >> update *Completions* as you type. >> >> This is similar to the recently added completion-eager-display. > > Thanks, now finally we'll have this long-needed feature. Indeed. BTW, I should have mentioned in my first email that this depends, for performance, on the new lazy-inserting-into-*Completions* functionality I added; that makes performance good even when there are many completions. > The first question: should it depend on the value of > 'minibuffer-visible-completions'? OTOH, even when it's nil, > *Completions* can be displayed by non-nil completion-eager-display. Right, or of course the user could just explicitly hit ? to display *Completions*. So I don't currently see a reason why we'd depend on minibuffer-visible-completions. > So the only problem is that when the *Completions* window is removed > (e.g. when no candidates remains), it never comes back to the display > (e.g. after deleting previous characters). > > Or maybe this is not a problem, I have to test it more. The specific scenario of *Completions* disappearing when no candidates remain has not been a problem for me. But it is possible that we want to make other changes in this area (maybe separate from this patch?) *Completions* can be hidden for many reasons, but maybe when eager-display behavior is enabled, *Completions* should not be hidden as readily? Maybe eager-display should cause the behavior to be more like completion-auto-help=visible? From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 17 16:33:42 2025 Received: (at 77649) by debbugs.gnu.org; 17 Jul 2025 20:33:42 +0000 Received: from localhost ([127.0.0.1]:57201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ucVIQ-0003zB-MT for submit@debbugs.gnu.org; Thu, 17 Jul 2025 16:33:42 -0400 Received: from s.wrqvqsbb.outbound-mail.sendgrid.net ([149.72.70.187]:24992) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ucVIM-0003yR-FT for 77649@debbugs.gnu.org; Thu, 17 Jul 2025 16:33:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:date:mime-version:to:cc: content-type:content-transfer-encoding:cc:content-type:date:from:subject:to; s=s1; bh=bxKAhDPw9+681XMvoKqJGlqHUpQLf30eAvWdee4Eu10=; b=n/fOQwJDMPWsfY+Hj97uRQAlYXbMSvxFiwARGTWvc2p2+a+HD5GZkmBykmLFMnE5oz5H nOi2DSLuSIiUk08Kos69PtByH+uvdZ9arPpVhFaveVXCJyyKa/sTnGqFtYExwocpGAoJJ8 K53g1Ui0KTMweX+e9NQoZy6iF7n8WQ/IIloK6/6Mr5++bQMMMVE9xYEbAnn4bLxaITkb9W +7GlXxkbHHbHADCM48ZKs5fFldWXvTG9jOltHSw4NzLtaC9JOxo2H9B6Z4BF43G/pF5V7u QttbDLOGBkPL4dQpJMEN4+GRPh8WMd1/zxdX/He5YO3dLFAD3CUe8SGWmCnxWF4A== Received: by recvd-65696df74f-ll8vq with SMTP id recvd-65696df74f-ll8vq-1-68795E18-64 2025-07-17 20:33:28.857236214 +0000 UTC m=+3728935.361017753 Received: from earth.catern.com (unknown) by geopod-ismtpd-52 (SG) with ESMTP id DlgHarUDTyu0D1a5vMCwVQ Thu, 17 Jul 2025 20:33:28.627 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by earth.catern.com (Postfix) with ESMTPSA id 289116250C; Thu, 17 Jul 2025 16:33:28 -0400 (EDT) From: sbaugh@catern.com Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: (Spencer Baugh's message of "Tue, 08 Apr 2025 15:00:35 -0400") References: <87jz7ulczo.fsf@mail.linkov.net> Date: Thu, 17 Jul 2025 20:33:28 +0000 (UTC) Message-ID: <87jz46zhev.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?u001=2Ev6RTqHFpv1T6krEot6UFAVAJmQ+4h1t8=2FTfqqE2B07OXv382pS28zh3s7?= =?us-ascii?Q?LnqEno85IxmncULnTZhoXbPWrk50mAHK5gUTZ7L?= =?us-ascii?Q?YPte=2FLWlk2NjbX3yMjXL157ycTwGx2hewtsSZoH?= =?us-ascii?Q?HnKxAijwBsPeiJxX38vpgjBoU=2FRxJH8LiKsevV6?= =?us-ascii?Q?WAqQxLdn33Eb1lt0vNSB7cj7ySlLDzD7E2iS9Kf?= =?us-ascii?Q?A=3D=3D?= To: Spencer Baugh X-Entity-ID: u001.oW4JupFKOzCccZAQN2OOFQ== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77649 Cc: Daniel Mendler , 77649@debbugs.gnu.org, Juri Linkov X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Spencer Baugh writes: > Juri Linkov writes: > >>> Add support for updating the *Completions* buffer as you type, >>> controlled by a new completion metadata symbol 'eager-update and >>> new defcustom completion-eager-update. >>> >>> You can configure a completion category to update *Completions* >>> as you type by setting completion-category-overrides >>> appropriately; or set completion-eager-update to t to always >>> update *Completions* as you type. >>> >>> This is similar to the recently added completion-eager-display. >> >> Thanks, now finally we'll have this long-needed feature. Hi, have you gotten a chance to try this out? I have been running this for several completion categories at my site and have had no complaints. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 18 02:51:39 2025 Received: (at 77649) by debbugs.gnu.org; 18 Jul 2025 06:51:39 +0000 Received: from localhost ([127.0.0.1]:59950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ucewU-0007nh-Qb for submit@debbugs.gnu.org; Fri, 18 Jul 2025 02:51:39 -0400 Received: from mout-y-111.mailbox.org ([2001:67c:2050:103:465::111]:47826) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ucewM-0007mJ-BF for 77649@debbugs.gnu.org; Fri, 18 Jul 2025 02:51:31 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-y-111.mailbox.org (Postfix) with ESMTPS id 4bk0nP5KzPz9y7p; Fri, 18 Jul 2025 08:51:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; t=1752821481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zFokQ136Ob8EHeFXVxn7o0K6MjzBwRfdHA+Gl0ayD84=; b=x3u4xm/ZDRpCXvRo8sOrzsMgMidVl9XcJb5iJvIsm+m8ny+T98SEM3LRkGM/CDGhEZre4o JYRenzgpaeMRY55Cqt1v1vGc8FtC70eKQS5bUnwJePO9svAb+gFlla+ddZd7DOqP5EfQfU ZD1UNPt1sL7FNstIdGCsObgLhatCWG1IWRr0oZR0IxqGH6eOZeUPCg1r7oWrmVPk5ZNOTD 49CItDNB0rWuO/dSwMW96KgJACjIelFjvZg/5xHels+B5KKFePOJeE7xa3Dxrj4PHBg9/l ax9dnRLMrbyjw8uvWEZWRjYdy54Ig6l9fyLDPGPKHJzjSLdl8D7exiNL0SKE0A== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of juri@linkov.net designates 2001:67c:2050:b231:465::2 as permitted sender) smtp.mailfrom=juri@linkov.net From: Juri Linkov To: sbaugh@catern.com Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: <87jz46zhev.fsf@catern.com> Organization: LINKOV.NET References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> Date: Fri, 18 Jul 2025 09:40:36 +0300 Message-ID: <87a552vwmr.fsf@mail.linkov.net> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4bk0nP5KzPz9y7p X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 77649 Cc: Spencer Baugh , 77649@debbugs.gnu.org, Daniel Mendler X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >>>> Add support for updating the *Completions* buffer as you type, >>>> controlled by a new completion metadata symbol 'eager-update and >>>> new defcustom completion-eager-update. >>>> >>>> You can configure a completion category to update *Completions* >>>> as you type by setting completion-category-overrides >>>> appropriately; or set completion-eager-update to t to always >>>> update *Completions* as you type. >>>> >>>> This is similar to the recently added completion-eager-display. >>> >>> Thanks, now finally we'll have this long-needed feature. > > Hi, have you gotten a chance to try this out? Yes, I tried it out, and everything worked nicely. > I have been running this for several completion categories at my site > and have had no complaints. Could you send a complete patch with a NEWS entry? From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 21 12:44:06 2025 Received: (at 77649) by debbugs.gnu.org; 21 Jul 2025 16:44:06 +0000 Received: from localhost ([127.0.0.1]:58709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1udtcT-00061p-GH for submit@debbugs.gnu.org; Mon, 21 Jul 2025 12:44:06 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:52883) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1udtcQ-000616-Fz for 77649@debbugs.gnu.org; Mon, 21 Jul 2025 12:44:03 -0400 From: Spencer Baugh To: Juri Linkov Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: <87a552vwmr.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 18 Jul 2025 09:40:36 +0300") References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> <87a552vwmr.fsf@mail.linkov.net> Date: Mon, 21 Jul 2025 12:43:56 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1753116236; bh=+OuMBFt59/n2gWTT0nV4yJdYjXZhvclSX1iDiMyfthM=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=EsdZoIUN2YrEZD1WcfUvWCOR89M47k6XzZOCpUJGCJ7NeIAzeGX1B5Sjs3n2benIi Q2giMobwEvIb2ILqAeQj3ZJcDbXgos6kVO9aRrjyY6ww1/pw2Zkrpg6yAKogB/txi6 aPShAPpxZO8Jt7YunX53vA66geck8lniLo+pFF3KK8IpjxNYUbkkG4bDliPpf38TRp 5QIJ/28T0kMnPEhL7QOQUIYzblEiQzFASvIE3EeB3vJ6U7dgbldJjnUsTQ0poETxUe PdGyHpypyozYiAoPyEU2sYsts1c+R/Wai5vY9v3C9b5ouidwYCY1Y1DYLF/VM+sllT obMmSDdGnorRA== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77649 Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, Daniel Mendler X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Juri Linkov writes: >>>>> Add support for updating the *Completions* buffer as you type, >>>>> controlled by a new completion metadata symbol 'eager-update and >>>>> new defcustom completion-eager-update. >>>>> >>>>> You can configure a completion category to update *Completions* >>>>> as you type by setting completion-category-overrides >>>>> appropriately; or set completion-eager-update to t to always >>>>> update *Completions* as you type. >>>>> >>>>> This is similar to the recently added completion-eager-display. >>>> >>>> Thanks, now finally we'll have this long-needed feature. >> >> Hi, have you gotten a chance to try this out? > > Yes, I tried it out, and everything worked nicely. > >> I have been running this for several completion categories at my site >> and have had no complaints. > > Could you send a complete patch with a NEWS entry? Yes, attached. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-support-for-updating-Completions-as-you-type.patch >From 5c8290de611710c1859c65c37daf961507b20e62 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Thu, 3 Apr 2025 15:38:22 -0400 Subject: [PATCH] Add support for updating *Completions* as you type Add support for updating the *Completions* buffer as you type, controlled by a new completion metadata symbol 'eager-update and new defcustom completion-eager-update. You can configure a completion category to update *Completions* as you type by setting completion-category-overrides appropriately; or set completion-eager-update to t to always update *Completions* as you type. This is similar to the recently added completion-eager-display. * lisp/minibuffer.el (completion-eager-update): Add new defcustom defaulting to 'auto. (bug#77649) (completion--eager-update-p, completions--background-update) (completions--post-command-update): Add. (completions--after-change): Call completions--post-command-update via post-command-hook. (minibuffer-completion-help): Check completion-eager-update and install completions--after-change. (completion-help-at-point): Call completion--eager-update-p if ONLY-IF-EAGER is non-nil. * etc/NEWS: Announce completion-eager-update. Slightly reword the announcement of completion-eager-display for consistency. --- etc/NEWS | 13 +++++++++- lisp/minibuffer.el | 59 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index b469b22aacf..0c0f333319a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -167,11 +167,22 @@ This option configures whether completion commands should display the "*Completions*" buffer immediately. When the option is set to t, all completion commands show "*Completions*" immediately, respectively nil disables the eager display for all commands. The default setting auto -enables eager completion only if requested by the command. +enables eager display only if requested by the command. For more fine-grained control you can also toggle this feature by category using the symbol 'eager-display' in the user option 'completion-category-overrides'. ++++ +*** New user option 'completion-eager-update. +This option configures whether typing should update the contents of the +"*Completions*" buffer, if it is shown. When the option is set to t, +typing will always update the "*Completions*" buffer. Note that for +large or inefficient completion tables, this can slow down typing. The +default setting enables eager updating only if requested by the command. +For more fine-grained control you can also toggle this feature by +category using the symbol 'eager-update in the user option +'completion-category-overrides'. + +++ *** New user option 'completion-pcm-leading-wildcard'. This option configures how the partial-completion style does completion. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 571c4174537..12f66f57747 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1072,6 +1072,21 @@ completion-eager-display (const :tag "If requested by the completion command" auto)) :version "31.1") +(defcustom completion-eager-update 'auto + "Whether typing should update the *Completions* buffer eagerly. + +If `t', always update as you type. + +If `auto', only update if the completion table has requested it or +`eager-update' is set in in `completion-category-defaults'. + +This only affects the *Completions* buffer if it is already +displayed." + :type '(choice (const :tag "Do nothing when you type" nil) + (const :tag "Auto-update based on the category" auto) + (const :tag "Always update as you type" t)) + :version "31.1") + (defcustom completion-auto-help t "Non-nil means automatically provide help for invalid completion input. If the value is t, the *Completions* buffer is displayed whenever completion @@ -2648,12 +2663,43 @@ completions--deselect (goto-char (or (next-single-property-change (point) 'completion--string) (point-max))))) +(defun completion--eager-update-p (start) + "Return non-nil if *Completions* should be automatically updated. + +If `completion-eager-update' is the symbol `auto', checks completion +metadata for the string from START to point." + (if (eq completion-eager-update 'auto) + (completion-metadata-get (completion--field-metadata start) 'eager-update) + completion-eager-update)) + +(defun completions--background-update () + "Try to update *Completions* without blocking input. + +This function uses `while-no-input' and sets `non-essential' to t +so that the update is less likely to interfere with user typing." + (while-no-input + (let ((non-essential t)) + (redisplay) + (cond + (completion-in-region-mode (completion-help-at-point t)) + ((completion--eager-update-p (minibuffer-prompt-end)) + (minibuffer-completion-help)))))) + +(defun completions--post-command-update () + "Update displayed *Completions* buffer after command, once." + (remove-hook 'post-command-hook #'completions--post-command-update) + (when (and completion-eager-update (get-buffer-window "*Completions*" 0)) + (completions--background-update))) + (defun completions--after-change (_start _end _old-len) "Update displayed *Completions* buffer after change in buffer contents." - (when completion-auto-deselect + (when (or completion-auto-deselect completion-eager-update) (when-let* ((window (get-buffer-window "*Completions*" 0))) - (with-selected-window window - (completions--deselect))))) + (when completion-auto-deselect + (with-selected-window window + (completions--deselect))) + (when completion-eager-update + (add-hook 'post-command-hook #'completions--post-command-update))))) (defun minibuffer-completion-help (&optional start end) "Display a list of possible completions of the current minibuffer contents." @@ -2744,7 +2790,7 @@ minibuffer-completion-help (body-function . ,#'(lambda (window) (with-current-buffer mainbuf - (when completion-auto-deselect + (when (or completion-auto-deselect completion-eager-update) (add-hook 'after-change-functions #'completions--after-change nil t)) ;; Remove the base-size tail because `sort' requires a properly ;; nil-terminated list. @@ -3133,7 +3179,7 @@ completion-at-point (car res))) (cdr res))))) -(defun completion-help-at-point () +(defun completion-help-at-point (&optional only-if-eager) "Display the completions on the text around point. The completion method is determined by `completion-at-point-functions'." (interactive) @@ -3160,7 +3206,8 @@ completion-help-at-point `(,start ,(copy-marker end t) ,collection ,(plist-get plist :predicate))) (completion-in-region-mode 1) - (minibuffer-completion-help start end))) + (when (or (not only-if-eager) (completion--eager-update-p start)) + (minibuffer-completion-help start end)))) (`(,hookfun . ,_) ;; The hook function already performed completion :-( ;; Not much we can do at this point. -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 22 08:22:50 2025 Received: (at 77649) by debbugs.gnu.org; 22 Jul 2025 12:22:50 +0000 Received: from localhost ([127.0.0.1]:36048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ueC1C-0003i0-8N for submit@debbugs.gnu.org; Tue, 22 Jul 2025 08:22:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57354) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ueC19-0003hQ-7o for 77649@debbugs.gnu.org; Tue, 22 Jul 2025 08:22:47 -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 ) id 1ueC10-00007E-TO; Tue, 22 Jul 2025 08:22: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=UornkWra7gOZwOjAzLkZuAmLXWyDZ9tKe/wuZne2HFo=; b=l4pRhpAs2gH5 RBB8pZItf0OZyIFJarLbM0Eh/xQpE78Mt7DH9sTrL84RTnLhozspB3G56GafV660nkT86TatWD+Bp VaSSt9SnOGIonnizW9eROX9Rn1dMvJDOEIm2/6tJlnHnRm6Pm5ZqtossnBzEMuN69TXcWTZuVvlZn gL6kXub2Ymb6Pq5l71ZXD9Zv6zwK1rdDwka/bcie/6FB3ujlS/pvxyhEuOMkqv1Nb3Rd0jaeIBZbU yVv29UT8OhY0+NqPtETjyGqTOdxOUrj+zojopAp1pxQPOEc9gH+J/Jh0iH/h9yGk1XNP6TFfMMK3D mZUrgX3OOb9hdzZOnh4jig==; Date: Tue, 22 Jul 2025 15:22:34 +0300 Message-Id: <86plds9zzp.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> <87a552vwmr.fsf@mail.linkov.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77649 Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, mail@daniel-mendler.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, > Daniel Mendler > Date: Mon, 21 Jul 2025 12:43:56 -0400 > From: Spencer Baugh via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > +*** New user option 'completion-eager-update. ^ Closing quote missing there. > +This option configures whether typing should update the contents of the ^^^^^^^^^^ We normally use "controls". > +"*Completions*" buffer, if it is shown. When the option is set to t, > +typing will always update the "*Completions*" buffer. Note that for > +large or inefficient completion tables, this can slow down typing. The > +default setting enables eager updating only if requested by the command. > +For more fine-grained control you can also toggle this feature by > +category using the symbol 'eager-update in the user option > +'completion-category-overrides'. IMO, the last two sentences are too vague/mysterious to be useful (this is a user option, remember?) > +If `auto', only update if the completion table has requested it or > +`eager-update' is set in in `completion-category-defaults'. This should at least hint how would a completion table request the update, or mention some function or variable whose doc string explains that. The doc string should also describe what happens when the value is nil. > + :type '(choice (const :tag "Do nothing when you type" nil) "Do nothing" is incorrect. I think you mean "Do not update completions" or somesuch. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 22 12:32:28 2025 Received: (at 77649) by debbugs.gnu.org; 22 Jul 2025 16:32:28 +0000 Received: from localhost ([127.0.0.1]:38696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ueFul-0001Co-Ds for submit@debbugs.gnu.org; Tue, 22 Jul 2025 12:32:28 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:35465) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ueFui-0001C6-0p for 77649@debbugs.gnu.org; Tue, 22 Jul 2025 12:32:25 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: <86plds9zzp.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 22 Jul 2025 15:22:34 +0300") References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> <87a552vwmr.fsf@mail.linkov.net> <86plds9zzp.fsf@gnu.org> Date: Tue, 22 Jul 2025 12:32:18 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1753201938; bh=NGI1seEaSpG/BiwUi1eMb9wSsrinGcAlpXwpCXSUZ4o=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=WTfzeMpx9vH7UA57LUZ5fYAdXvop/3TQmEnYPQCtlwkYQAXMg/dC2qAnsolPzcxu3 H9+li5B8cdXCCX+ikUvVKFP0LdiEHkEE12IGCynAIS7W6whxsn/3CgCvLiQTSycVFx b8Yle1f8/DBeLSoo2bThRTQYaop92rj31bdLzuCeLEKIcKSjbM5ypKNFWd4iCGos61 dErAqOI1ePUHKz5ZYdD9wS3wYLwPCd/lswGdQzFBhXN6uHWY6tHad1kysmC8M2LHu9 vlnUWWry0sMQQn8eKeUCfDOLG3LaACUV+hMhg1cOk3xGzhtVU78kgQHBNHS9WNyIl1 pcUdAzk9QmAVg== X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77649 Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, juri@linkov.net, mail@daniel-mendler.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, >> Daniel Mendler >> Date: Mon, 21 Jul 2025 12:43:56 -0400 >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> +*** New user option 'completion-eager-update. > ^ > Closing quote missing there. > >> +This option configures whether typing should update the contents of the > ^^^^^^^^^^ > We normally use "controls". > >> +"*Completions*" buffer, if it is shown. When the option is set to t, >> +typing will always update the "*Completions*" buffer. Note that for >> +large or inefficient completion tables, this can slow down typing. The >> +default setting enables eager updating only if requested by the command. >> +For more fine-grained control you can also toggle this feature by >> +category using the symbol 'eager-update in the user option >> +'completion-category-overrides'. > > IMO, the last two sentences are too vague/mysterious to be useful > (this is a user option, remember?) These two sentences are just copied (with a minor change) from the announcement for the very similar option completion-eager-display, just above. Should I reword that one as well in this commit? >> +If `auto', only update if the completion table has requested it or >> +`eager-update' is set in in `completion-category-defaults'. > > This should at least hint how would a completion table request the > update, or mention some function or variable whose doc string explains > that. > > The doc string should also describe what happens when the value is nil. > >> + :type '(choice (const :tag "Do nothing when you type" nil) > > "Do nothing" is incorrect. I think you mean "Do not update > completions" or somesuch. > > Thanks. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 22 13:05:29 2025 Received: (at 77649) by debbugs.gnu.org; 22 Jul 2025 17:05:29 +0000 Received: from localhost ([127.0.0.1]:38871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ueGQi-0003m0-I5 for submit@debbugs.gnu.org; Tue, 22 Jul 2025 13:05:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47248) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ueGQf-0003lG-7n for 77649@debbugs.gnu.org; Tue, 22 Jul 2025 13:05:26 -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 ) id 1ueGQP-0001DF-VM; Tue, 22 Jul 2025 13:05:12 -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=uAnKUih5IQ6BOF7SSuX8r57pkHjuVvK5omMYSGHB7OA=; b=k8zjVqkg1FgY xYd7xkNlphP6Ho0fqhjIERYVibUYli3Vk4H8N187/GjjtgyNFi1yN3UsnynegAqSyCpr7p/eFaRVW 11Et+eFJN4Yw5ERN/uAjaQop3AJMsNP/DINCyrRXS8JwBaGppveoaZDsJGWsKUCR+CW83QFukFZ4V ULuaiqcGufB6LN8T3rmuSuz/Tq5I72rlOSk8SHTJ86aTdvxVM+oFYAsqU4k6ka2XqhgpF6Kg76hpn fW1HGBDCNly4vvBTHZPdW7dauvr7A2qP6iwHgFe/0NlrIcH+Wye5sybrnf/rS8DYQ1IOK9L1i1Zap /N0Sbw0ONbpkdV5Up07zbw==; Date: Tue, 22 Jul 2025 20:05:04 +0300 Message-Id: <86bjpc88cf.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Tue, 22 Jul 2025 12:32:18 -0400) Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> <87a552vwmr.fsf@mail.linkov.net> <86plds9zzp.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77649 Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, juri@linkov.net, mail@daniel-mendler.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, mail@daniel-mendler.de, > juri@linkov.net > Date: Tue, 22 Jul 2025 12:32:18 -0400 > > Eli Zaretskii writes: > > >> Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, > >> Daniel Mendler > >> Date: Mon, 21 Jul 2025 12:43:56 -0400 > >> From: Spencer Baugh via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> +*** New user option 'completion-eager-update. > > ^ > > Closing quote missing there. > > > >> +This option configures whether typing should update the contents of the > > ^^^^^^^^^^ > > We normally use "controls". > > > >> +"*Completions*" buffer, if it is shown. When the option is set to t, > >> +typing will always update the "*Completions*" buffer. Note that for > >> +large or inefficient completion tables, this can slow down typing. The > >> +default setting enables eager updating only if requested by the command. > >> +For more fine-grained control you can also toggle this feature by > >> +category using the symbol 'eager-update in the user option > >> +'completion-category-overrides'. > > > > IMO, the last two sentences are too vague/mysterious to be useful > > (this is a user option, remember?) > > These two sentences are just copied (with a minor change) from the > announcement for the very similar option completion-eager-display, just > above. Should I reword that one as well in this commit? If you wish, yes. From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 22 15:28:04 2025 Received: (at 77649) by debbugs.gnu.org; 22 Jul 2025 19:28:04 +0000 Received: from localhost ([127.0.0.1]:39599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ueIeg-0003aQ-FZ for submit@debbugs.gnu.org; Tue, 22 Jul 2025 15:28:03 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:53007) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ueIec-0003Zb-LS for 77649@debbugs.gnu.org; Tue, 22 Jul 2025 15:28:01 -0400 From: Spencer Baugh To: Eli Zaretskii Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type In-Reply-To: <86bjpc88cf.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 22 Jul 2025 20:05:04 +0300") References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> <87a552vwmr.fsf@mail.linkov.net> <86plds9zzp.fsf@gnu.org> <86bjpc88cf.fsf@gnu.org> Date: Tue, 22 Jul 2025 15:27:53 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1753212473; bh=WGgTAjoJ/zec5+kQnVSJHp1vnOoUwqdOkmju+brN/Og=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=CS4x9VJOdsm5pLl+vPcktMyzJQF3c0+sbHR8YdXgtsvPGz2+sPdiGPZ+pJA7Fg38M o++8woomv1cc3RHzrtBr1hsl6HXr9H+SwsGLphg9LXZm3h07CvIXzv4uB8NhTrt/iN CljCxfMFvbhTu4Rohd2P83YXxSpT2ME5/heYrBYBo+3FiNI6Ajxz3VrwhZlQx/jNFb w3qSpOuw9aLkYnkXUBWDHbZw2J38pcRH8PbJ9gO6z+PIKH8NBND2PhWnE65Pcj/mXm OllvYHEJlFPTNIEHHcstJB0kiAJMQWh2NoqwBN7/D9159vAbgVScIB6Lt6RqlTb6Qh 0JUMzP/RwQnJg== X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77649 Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, mail@daniel-mendler.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, mail@daniel-mendler.de, >> juri@linkov.net >> Date: Tue, 22 Jul 2025 12:32:18 -0400 >> >> Eli Zaretskii writes: >> >> >> Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, >> >> Daniel Mendler >> >> Date: Mon, 21 Jul 2025 12:43:56 -0400 >> >> From: Spencer Baugh via "Bug reports for GNU Emacs, >> >> the Swiss army knife of text editors" >> >> >> >> +*** New user option 'completion-eager-update. >> > ^ >> > Closing quote missing there. >> > >> >> +This option configures whether typing should update the contents of the >> > ^^^^^^^^^^ >> > We normally use "controls". >> > >> >> +"*Completions*" buffer, if it is shown. When the option is set to t, >> >> +typing will always update the "*Completions*" buffer. Note that for >> >> +large or inefficient completion tables, this can slow down typing. The >> >> +default setting enables eager updating only if requested by the command. >> >> +For more fine-grained control you can also toggle this feature by >> >> +category using the symbol 'eager-update in the user option >> >> +'completion-category-overrides'. >> > >> > IMO, the last two sentences are too vague/mysterious to be useful >> > (this is a user option, remember?) >> >> These two sentences are just copied (with a minor change) from the >> announcement for the very similar option completion-eager-display, just >> above. Should I reword that one as well in this commit? > > If you wish, yes. Updated and fixed your feedback. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-support-for-updating-Completions-as-you-type.patch >From 6e6d38974ad142882fd9919f452ae311b418a712 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Thu, 3 Apr 2025 15:38:22 -0400 Subject: [PATCH] Add support for updating *Completions* as you type Add support for updating the *Completions* buffer as you type, controlled by a new completion metadata symbol 'eager-update and new defcustom completion-eager-update. You can configure a completion category to update *Completions* as you type by setting completion-category-overrides appropriately; or set completion-eager-update to t to always update *Completions* as you type. This is similar to the recently added completion-eager-display. * lisp/minibuffer.el (completion-eager-update): Add new defcustom defaulting to 'auto. (bug#77649) (completion--eager-update-p, completions--background-update) (completions--post-command-update): Add. (completions--after-change): Call completions--post-command-update via post-command-hook. (minibuffer-completion-help): Check completion-eager-update and install completions--after-change. (completion-help-at-point): Call completion--eager-update-p if ONLY-IF-EAGER is non-nil. * etc/NEWS: Announce completion-eager-update. Reword the announcement of completion-eager-display for consistency. --- etc/NEWS | 29 +++++++++++++++------- lisp/minibuffer.el | 62 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 15 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2d904614153..f2a08ee3009 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -173,15 +173,26 @@ this behavior is now off by default. You can re-enable it by setting ** Minibuffer and Completions +++ -*** New user option 'completion-eager-display'. -This option configures whether completion commands should display the -"*Completions*" buffer immediately. When the option is set to t, all -completion commands show "*Completions*" immediately, respectively nil -disables the eager display for all commands. The default setting auto -enables eager completion only if requested by the command. -For more fine-grained control you can also toggle this feature by -category using the symbol 'eager-display' in the user option -'completion-category-overrides'. +*** Support for immediate display of the "*Completions*" buffer +Whenever a minibuffer with completion is opened, the "*Completions*" +buffer will now be displayed immediately if the completion property +'eager-display', set by the completion table, is non-nil. This property +can be overridden for different completion categories by customizing +'completion-category-overrides'. Alternatively, the new user option +'completion-eager-display' can be set to t to force eager display of +"*Completions*" for all minibuffers, or nil to suppress this for all +minibuffers. + ++++ +*** Support for updating "*Completions*" as you type +If the "*Completions*" buffer is displayed, it will now be updated as +you type if the completion property 'eager-update', set by the +completion table, is non-nil. This property can be overridden for +different completion categories by customizing +'completion-category-overrides'. Alternatively, the new user option +'completion-eager-update can be set to t to make "*Completions*" always +be updated as you type, or nil to suppress this always. Note that for +large or inefficient completion tables this can slow down typing. +++ *** New user option 'completion-pcm-leading-wildcard'. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 571c4174537..ea2546f7d2c 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1072,6 +1072,24 @@ completion-eager-display (const :tag "If requested by the completion command" auto)) :version "31.1") +(defcustom completion-eager-update 'auto + "Whether the *Completions* buffer should update as you type. + +If `t', always update as you type. + +If `auto', only update if the completion property 'eager-update' is +non-nil, whether set by the completion table or by +`completion-category-overrides' or by `completion-category-defaults'. + +If nil, never update as you type. + +This only affects the *Completions* buffer if it is already +displayed." + :type '(choice (const :tag "Don't update as you type" nil) + (const :tag "Auto-update based on the category" auto) + (const :tag "Always update as you type" t)) + :version "31.1") + (defcustom completion-auto-help t "Non-nil means automatically provide help for invalid completion input. If the value is t, the *Completions* buffer is displayed whenever completion @@ -2648,12 +2666,43 @@ completions--deselect (goto-char (or (next-single-property-change (point) 'completion--string) (point-max))))) +(defun completion--eager-update-p (start) + "Return non-nil if *Completions* should be automatically updated. + +If `completion-eager-update' is the symbol `auto', checks completion +metadata for the string from START to point." + (if (eq completion-eager-update 'auto) + (completion-metadata-get (completion--field-metadata start) 'eager-update) + completion-eager-update)) + +(defun completions--background-update () + "Try to update *Completions* without blocking input. + +This function uses `while-no-input' and sets `non-essential' to t +so that the update is less likely to interfere with user typing." + (while-no-input + (let ((non-essential t)) + (redisplay) + (cond + (completion-in-region-mode (completion-help-at-point t)) + ((completion--eager-update-p (minibuffer-prompt-end)) + (minibuffer-completion-help)))))) + +(defun completions--post-command-update () + "Update displayed *Completions* buffer after command, once." + (remove-hook 'post-command-hook #'completions--post-command-update) + (when (and completion-eager-update (get-buffer-window "*Completions*" 0)) + (completions--background-update))) + (defun completions--after-change (_start _end _old-len) "Update displayed *Completions* buffer after change in buffer contents." - (when completion-auto-deselect + (when (or completion-auto-deselect completion-eager-update) (when-let* ((window (get-buffer-window "*Completions*" 0))) - (with-selected-window window - (completions--deselect))))) + (when completion-auto-deselect + (with-selected-window window + (completions--deselect))) + (when completion-eager-update + (add-hook 'post-command-hook #'completions--post-command-update))))) (defun minibuffer-completion-help (&optional start end) "Display a list of possible completions of the current minibuffer contents." @@ -2744,7 +2793,7 @@ minibuffer-completion-help (body-function . ,#'(lambda (window) (with-current-buffer mainbuf - (when completion-auto-deselect + (when (or completion-auto-deselect completion-eager-update) (add-hook 'after-change-functions #'completions--after-change nil t)) ;; Remove the base-size tail because `sort' requires a properly ;; nil-terminated list. @@ -3133,7 +3182,7 @@ completion-at-point (car res))) (cdr res))))) -(defun completion-help-at-point () +(defun completion-help-at-point (&optional only-if-eager) "Display the completions on the text around point. The completion method is determined by `completion-at-point-functions'." (interactive) @@ -3160,7 +3209,8 @@ completion-help-at-point `(,start ,(copy-marker end t) ,collection ,(plist-get plist :predicate))) (completion-in-region-mode 1) - (minibuffer-completion-help start end))) + (when (or (not only-if-eager) (completion--eager-update-p start)) + (minibuffer-completion-help start end)))) (`(,hookfun . ,_) ;; The hook function already performed completion :-( ;; Not much we can do at this point. -- 2.39.3 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 26 05:42:18 2025 Received: (at 77649) by debbugs.gnu.org; 26 Jul 2025 09:42:18 +0000 Received: from localhost ([127.0.0.1]:40053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ufbQ1-0004qa-J6 for submit@debbugs.gnu.org; Sat, 26 Jul 2025 05:42:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36048) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ufbPy-0004q2-0k for 77649@debbugs.gnu.org; Sat, 26 Jul 2025 05:42:15 -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 ) id 1ufbPq-00052V-8P; Sat, 26 Jul 2025 05:42: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=uaqkC8UpJ63Hkmqf9pAqcDawqb9uac2mvzzEZVPU2cs=; b=eTGkrNIZGkrf o0OZ81qPX8PpSwv8vL1Ubz3HVteGdaT7Ytz5kbLzAin9VrpBzYeqHnLclR19J92Kx4pVkqoNMhpU3 VtJz1sNaYbYb/gPAEj0FdQOQ0gndi3lFWwLcjMDbvkPvciOTWRTNOv9TabKRpmP104CuF938tgEGI yiG3UZ7iks2UoIo4vYzicFpj+bMDCGnklx5MDIJ9+aqvrLjL5lGURDqKqvSuTh6FEhPiSyGVgJ1Ax UbfJgldz/KhpG+43Z9BaBDUq1OmZNjXwExFYawev3smHyylAz0rZ3Ca0OM+HH0iKNHR5eZmxr/IZ9 7NYmnRnfCde/1jGfjrE1jw==; Date: Sat, 26 Jul 2025 12:42:02 +0300 Message-Id: <86cy9n1e6t.fsf@gnu.org> From: Eli Zaretskii To: Spencer Baugh In-Reply-To: (message from Spencer Baugh on Tue, 22 Jul 2025 15:27:53 -0400) Subject: Re: bug#77649: [PATCH] Add support for updating *Completions* as you type References: <87jz7ulczo.fsf@mail.linkov.net> <87jz46zhev.fsf@catern.com> <87a552vwmr.fsf@mail.linkov.net> <86plds9zzp.fsf@gnu.org> <86bjpc88cf.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 77649 Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, mail@daniel-mendler.de, juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, juri@linkov.net, > mail@daniel-mendler.de > Date: Tue, 22 Jul 2025 15:27:53 -0400 > > Eli Zaretskii writes: > >> From: Spencer Baugh > >> Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, mail@daniel-mendler.de, > >> juri@linkov.net > >> Date: Tue, 22 Jul 2025 12:32:18 -0400 > >> > >> Eli Zaretskii writes: > >> > >> >> Cc: sbaugh@catern.com, 77649@debbugs.gnu.org, > >> >> Daniel Mendler > >> >> Date: Mon, 21 Jul 2025 12:43:56 -0400 > >> >> From: Spencer Baugh via "Bug reports for GNU Emacs, > >> >> the Swiss army knife of text editors" > >> >> > >> >> +*** New user option 'completion-eager-update. > >> > ^ > >> > Closing quote missing there. > >> > > >> >> +This option configures whether typing should update the contents of the > >> > ^^^^^^^^^^ > >> > We normally use "controls". > >> > > >> >> +"*Completions*" buffer, if it is shown. When the option is set to t, > >> >> +typing will always update the "*Completions*" buffer. Note that for > >> >> +large or inefficient completion tables, this can slow down typing. The > >> >> +default setting enables eager updating only if requested by the command. > >> >> +For more fine-grained control you can also toggle this feature by > >> >> +category using the symbol 'eager-update in the user option > >> >> +'completion-category-overrides'. > >> > > >> > IMO, the last two sentences are too vague/mysterious to be useful > >> > (this is a user option, remember?) > >> > >> These two sentences are just copied (with a minor change) from the > >> announcement for the very similar option completion-eager-display, just > >> above. Should I reword that one as well in this commit? > > > > If you wish, yes. > > Updated and fixed your feedback. Thanks. > +*** Support for immediate display of the "*Completions*" buffer > +Whenever a minibuffer with completion is opened, the "*Completions*" > +buffer will now be displayed immediately if the completion property > +'eager-display', set by the completion table, is non-nil. This property > +can be overridden for different completion categories by customizing > +'completion-category-overrides'. Alternatively, the new user option > +'completion-eager-display' can be set to t to force eager display of > +"*Completions*" for all minibuffers, or nil to suppress this for all > +minibuffers. > + > ++++ > +*** Support for updating "*Completions*" as you type > +If the "*Completions*" buffer is displayed, it will now be updated as > +you type if the completion property 'eager-update', set by the > +completion table, is non-nil. This property can be overridden for > +different completion categories by customizing > +'completion-category-overrides'. Alternatively, the new user option > +'completion-eager-update can be set to t to make "*Completions*" always > +be updated as you type, or nil to suppress this always. Note that for > +large or inefficient completion tables this can slow down typing. The two heading lines still don't end in a period. No further comments, once those nits are fixed.