From unknown Sat Sep 13 11:13:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79420: 30.2; icomplete-vertical-mode flashes horizontal minibuffer prompt before expanding Resent-From: Chris Roberts Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Sep 2025 10:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 79420 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 79420@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17575015173042 (code B ref -1); Wed, 10 Sep 2025 10:52:01 +0000 Received: (at submit) by debbugs.gnu.org; 10 Sep 2025 10:51:57 +0000 Received: from localhost ([127.0.0.1]:36364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uwIQe-0000mu-0z for submit@debbugs.gnu.org; Wed, 10 Sep 2025 06:51:57 -0400 Received: from lists.gnu.org ([2001:470:142::17]:58428) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uwHRU-0004aE-8Q for submit@debbugs.gnu.org; Wed, 10 Sep 2025 05:48:45 -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 1uwHRM-0006w0-WF for bug-gnu-emacs@gnu.org; Wed, 10 Sep 2025 05:48:37 -0400 Received: from layka.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uwHRF-0001B1-7h for bug-gnu-emacs@gnu.org; Wed, 10 Sep 2025 05:48:35 -0400 Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3295A20EEB for ; Wed, 10 Sep 2025 11:48:21 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id W16hGCFfD3Te for ; Wed, 10 Sep 2025 11:48:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1757497699; bh=+Ajc+qrUgTseziS6hd/pDhFmguWy2Vu3P6jffKfkZl4=; h=Date:From:To:Subject; b=Oa/oRJxgqavD8JRGLbrJBQBOLdM/wWD4qmZ/9/Yf04IUAmuc6WXyBbraMO2lgLykY ADMepQ5hfnnRx4yN1v1L8aTWSyXe28rrhNIvI+7EDIwnxvMLrDEl+f1akHEbnLe03T 2m0aLdPFUkUovw/fQgYSyoVylAXSyTBdjzW4kL/1BWXyQftfrOL37YjVwwDEmRafQZ HfcWCoKlgORy/aOzYVtCZagkMw54bxqiAWNbae/s5Yl8GOYaJ2ZhjdJJezRukMemdu VhD8OgNxhwCbV4wxJyA5Pkm7st9xQUuzrFk1RNS6RuUqlqNd14LtMZSrMvGocd/+Bz muF2Huz44/0Sg== Date: Wed, 10 Sep 2025 11:48:18 +0200 From: Chris Roberts Message-ID: <20250910114818.035c38b4@cdr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=178.21.23.139; envelope-from=frayedultrasonicaligator@disroot.org; helo=layka.disroot.org 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Mailman-Approved-At: Wed, 10 Sep 2025 06:51:54 -0400 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 (/) 1. emacs -Q 2. Evaluate the following: (setq icomplete-show-matches-on-no-input t) (icomplete-vertical-mode +1) 3. M-x Looking at the minibuffer, you will see the text "M-x" flash momentarily, before the minibuffer window expands vertically. This can be made more apparent by setting `icomplete-compute-delay' to a higher value (0.15 by default.) This is caused by the call to `sit-for' inside of the `icomplete-exhibit' function. The wait obviously causes the issue, because the function pauses the setup, including all of the necessary vertical code, and waits for `icomplete-compute-delay' seconds. But even if we set `icomplete-compute-delay' to 0, the prompt will still flash, because redisplay is triggered. In other words, the only way to call `sit-for' that doesn't cause an issue is: (sit-for x t) where x <= 0. Following are my thoughts on how to fix this. The piece of code from `icomplete-exhibit' that we are interested in is the following: (and (or icomplete-show-matches-on-no-input (not (equal (icomplete--field-string) icomplete--initial-input))) (or ;; Don't bother with delay after certain number of chars: (> (- (point) (icomplete--field-beg)) icomplete-max-delay-chars) ;; Don't delay if the completions are known. completion-all-sorted-completions ;; Don't delay if alternatives number is small enough: (and (sequencep (icomplete--completion-table)) (< (length (icomplete--completion-table)) icomplete-delay-completions-threshold)) ;; Delay - give some grace time for next keystroke, before ;; embarking on computing completions: (sit-for icomplete-compute-delay))) We see that `sit-for' will only execute if all the preceding forms return nil (since it's inside `and'). We also see that setting `icomplete-delay-completions-threshold' to a high value, like maybe `most-positive-fixnum' should help us avoid the call to `sit-for' in most situations. Except it doesn't, because `(icomplete--completion-table)' does not return `sequencep'! This can be verified by overriding the function via advice, and capturing the value returned by `icomplete--completion-table': ;; Don't delay if alternatives number is small enough: (progn ;; Important that we return nil to avoid exiting early (setq reimu (icomplete--completion-table)) nil) (and (sequencep (icomplete--completion-table)) (< (length (icomplete--completion-table)) icomplete-delay-completions-threshold)) Repeat the reproduction steps including this advice, press C-g after M-x, and finally C-x C-e `(sequencep reimu)' in the buffer (it's important that we don't do something that reads from the minibuffer, to not change the value), and you will get nil. In fact, `(type-of reimu)' shows that it's a compiled function. After debugging `icomplete--completion-table', I verified that this compiled function is in fact the value of the minibuffer-completion-table at the time. I believe this might be another bug, because the docstring of `minibuffer-completion-table' says: "Alist or obarray used for completion in the minibuffer." But it's evidently neither alist nor obarray (I assume, since `(sequencep obarray)' returns t). Thus, my ideas of fixing the original problem with the flashing prompt are following, from easiest to hardest: 1. Add a check for `icomplete-compute-delay)' <= 0, before the call to `sit-for', like so: ;; Don't delay if the wait is <= 0, to avoid redisplay ;; and prompt flashing in vertical mode. (<= icomplete-compute-delay 0) ;; Delay - give some grace time for next keystroke, before ;; embarking on computing completions: (sit-for icomplete-compute-delay))) 2. Force `sit-for' to never redisplay. This could also be conditionalized on `ido-vertical-mode' variable, to not affect the existing code. I think this is a tricky option, because this line is really ancient (at least 30 years old) and changing it might have unintended consequences, perhaps? 3. Fix the presumed bug with minibuffer-completion-table and adjust the `sequencep' check in `icomplete-exhibit' to compare with `icomplete-delay-completions-threshold' correctly. And finally, as mentioned earlier, this line of code is ancient. Maybe some deliberation is in order on whether it's actually still needed nowadays? ----------------------------------------------------------------------- In GNU Emacs 30.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2025-09-10 built on cdr Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Linux Mint 21.2 Configured using: 'configure --with-cairo --with-x-toolkit=gtk3' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LCMS2 LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB From unknown Sat Sep 13 11:13:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79420: 30.2; icomplete-vertical-mode flashes horizontal minibuffer prompt before expanding Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Sep 2025 10:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79420 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Chris Roberts , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Cc: 79420@debbugs.gnu.org Received: via spool by 79420-submit@debbugs.gnu.org id=B79420.175775768323151 (code B ref 79420); Sat, 13 Sep 2025 10:02:02 +0000 Received: (at 79420) by debbugs.gnu.org; 13 Sep 2025 10:01:23 +0000 Received: from localhost ([127.0.0.1]:53660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uxN4M-00061K-C4 for submit@debbugs.gnu.org; Sat, 13 Sep 2025 06:01:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38782) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uxN4J-00060u-OD for 79420@debbugs.gnu.org; Sat, 13 Sep 2025 06:01:20 -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 1uxN4C-00028Z-NB; Sat, 13 Sep 2025 06:01:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=wwalzKZAT7aeU8ztpwY7wC/M7fryHnK7wBCZ7dW7/oI=; b=oXCb0A51VqbKh1m/8ZbW 7rGhRiyXcAED4J4E4TeM20Z5ZozUmDexqYyPM9KpkievQ5DXMcuaqhJfcnlPMLi/onSlrcNn8vx23 uon1SpL81A9IJykjcJqCudygbBCykn+EgWqYH++XV/5yEgrjgqFE7om1Lrk3u43LMtwlO1NXMWT6c Ii8oYv4+/t6htGDUIYaMBtfWBrKt5sY4p3ZLrZzlfTBSiP/b53Gc7T8XFcgxDXFZLyCsJ0wdSXWcn 7olrmdwMGPt8WwJ0+KaBHTIss0qRojOh46AcNLxnnzw0/GCHGuOcRGEx+8WnWdo9BtNo1BSy8meRt HLnxxCqPJH2JuQ==; Date: Sat, 13 Sep 2025 13:01:04 +0300 Message-Id: <86ikhmr7rz.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <20250910114818.035c38b4@cdr> (bug-gnu-emacs@gnu.org) References: <20250910114818.035c38b4@cdr> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) 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 (---) > Date: Wed, 10 Sep 2025 11:48:18 +0200 > From: Chris Roberts via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > 1. emacs -Q > 2. Evaluate the following: > > (setq icomplete-show-matches-on-no-input t) > (icomplete-vertical-mode +1) > > 3. M-x > > Looking at the minibuffer, you will see the text "M-x" flash > momentarily, before the minibuffer window expands vertically. This can > be made more apparent by setting `icomplete-compute-delay' to a higher > value (0.15 by default.) > > This is caused by the call to `sit-for' inside of the > `icomplete-exhibit' function. The wait obviously causes the issue, > because the function pauses the setup, including all of the necessary > vertical code, and waits for `icomplete-compute-delay' seconds. But > even if we set `icomplete-compute-delay' to 0, the prompt will still > flash, because redisplay is triggered. In other words, the only way to > call `sit-for' that doesn't cause an issue is: > > (sit-for x t) > > where x <= 0. > > Following are my thoughts on how to fix this. > > The piece of code from `icomplete-exhibit' that we are interested in is > the following: > > (and (or icomplete-show-matches-on-no-input > (not (equal (icomplete--field-string) > icomplete--initial-input))) > (or > ;; Don't bother with delay after certain number of chars: > (> (- (point) (icomplete--field-beg)) > icomplete-max-delay-chars) > ;; Don't delay if the completions are known. > completion-all-sorted-completions > ;; Don't delay if alternatives number is small enough: > (and (sequencep (icomplete--completion-table)) > (< (length (icomplete--completion-table)) > icomplete-delay-completions-threshold)) > ;; Delay - give some grace time for next keystroke, before > ;; embarking on computing completions: > (sit-for icomplete-compute-delay))) > > We see that `sit-for' will only execute if all the preceding forms > return nil (since it's inside `and'). We also see that setting > `icomplete-delay-completions-threshold' to a high value, like maybe > `most-positive-fixnum' should help us avoid the call to `sit-for' in > most situations. Except it doesn't, because > `(icomplete--completion-table)' does not return `sequencep'! This can > be verified by overriding the function via advice, and capturing the > value returned by `icomplete--completion-table': > > ;; Don't delay if alternatives number is small enough: > (progn ;; Important that we return nil to avoid exiting early > (setq reimu (icomplete--completion-table)) > nil) > (and (sequencep (icomplete--completion-table)) > (< (length (icomplete--completion-table)) > icomplete-delay-completions-threshold)) > > Repeat the reproduction steps including this advice, press C-g after > M-x, and finally C-x C-e `(sequencep reimu)' in the buffer (it's > important that we don't do something that reads from the minibuffer, > to not change the value), and you will get nil. In fact, `(type-of > reimu)' shows that it's a compiled function. > > After debugging `icomplete--completion-table', I verified that this > compiled function is in fact the value of the > minibuffer-completion-table at the time. I believe this might be > another bug, because the docstring of `minibuffer-completion-table' > says: > > "Alist or obarray used for completion in the minibuffer." > > But it's evidently neither alist nor obarray (I assume, since > `(sequencep obarray)' returns t). > > Thus, my ideas of fixing the original problem with the flashing prompt > are following, from easiest to hardest: > > 1. Add a check for `icomplete-compute-delay)' <= 0, before the call to > `sit-for', like so: > > ;; Don't delay if the wait is <= 0, to avoid redisplay > ;; and prompt flashing in vertical mode. > (<= icomplete-compute-delay 0) > ;; Delay - give some grace time for next keystroke, before > ;; embarking on computing completions: > (sit-for icomplete-compute-delay))) > > 2. Force `sit-for' to never redisplay. This could also be > conditionalized on `ido-vertical-mode' variable, to not affect the > existing code. I think this is a tricky option, because this line is > really ancient (at least 30 years old) and changing it might have > unintended consequences, perhaps? > > 3. Fix the presumed bug with minibuffer-completion-table and adjust the > `sequencep' check in `icomplete-exhibit' to compare with > `icomplete-delay-completions-threshold' correctly. > > And finally, as mentioned earlier, this line of code is ancient. Maybe > some deliberation is in order on whether it's actually still needed > nowadays? Thanks. Joćo, any comments or suggestions?