From unknown Sun Jun 15 08:16:49 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: Sun, 15 Jun 2025 15:16:49 +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?