From unknown Sun Jun 22 17:13:37 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#67650 <67650@debbugs.gnu.org> To: bug#67650 <67650@debbugs.gnu.org> Subject: Status: [PATCH] ; Hide completion preview when switching windows Reply-To: bug#67650 <67650@debbugs.gnu.org> Date: Mon, 23 Jun 2025 00:13:37 +0000 retitle 67650 [PATCH] ; Hide completion preview when switching windows reassign 67650 emacs submitter 67650 Eshel Yaron severity 67650 normal tag 67650 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 05 15:26:53 2023 Received: (at submit) by debbugs.gnu.org; 5 Dec 2023 20:26:53 +0000 Received: from localhost ([127.0.0.1]:38485 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAc0L-0006ZZ-Fg for submit@debbugs.gnu.org; Tue, 05 Dec 2023 15:26:53 -0500 Received: from lists.gnu.org ([2001:470:142::17]:46114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAc0I-0006ZI-D7 for submit@debbugs.gnu.org; Tue, 05 Dec 2023 15:26:51 -0500 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 1rAc01-000401-5F for bug-gnu-emacs@gnu.org; Tue, 05 Dec 2023 15:26:33 -0500 Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rAbzy-00065M-EJ for bug-gnu-emacs@gnu.org; Tue, 05 Dec 2023 15:26:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1701807989; bh=fsZ+11wUKFk5n3ud84qvrn0FlrtUqgRLoTNFXnSQ1Z8=; h=From:To:Subject:Date:From; b=NVhu9ArP5p6o5zygKFEpuBLr0bWMzCd5LtqklGRXEZ9Sz9Cbpf9URaWFEJnK/x3qB X7NtLaO8gZ3ETLOdWrGK6SFaemnpApV/3qC7IrFOI2pRN1YGpHZ1joX35bolUb9kza 5A8lRunTaKe1eJAUU9E0MUQYh0iiLxtebABVvCEzfAR+w1DCtmFTw6N43uPZpIYgbZ 0sbHWqhcUXDYdpNMTWTz0VjBJKaJNqyGnhL24TZllnC18T83poQmDAqZjq4PGvOWhW lBqab80vti225m+QuSm5KOX+xVliRq670J4BWTIf7s3jjco1GHvgcrUmpuOfRCv/H9 DhrSH+mq0WQZA== From: Eshel Yaron To: bug-gnu-emacs@gnu.org Subject: [PATCH] ; Hide completion preview when switching windows X-Hashcash: 1:20:231205:bug-gnu-emacs@gnu.org::E+D3hA7JDobIMlhu:2iB5 Date: Tue, 05 Dec 2023 21:26:27 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 This patch ensures that we dismiss the completion preview when users switch to another window. Previously, the completion preview would remain in a window after switching to another window showing another buffer, since the `post-command-hook` that Completion Preview mode sets up locally doesn't run after a command switches to another buffer. Thanks, Eshel --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Hide-completion-preview-when-switching-windows.patch >From 1edb324d5c47fab96eb8131393b1fd38f7dee7ce Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 5 Dec 2023 21:04:43 +0100 Subject: [PATCH] ; Hide completion preview when switching windows * lisp/completion-preview.el (completion-preview--window-selection-change): New function. (completion-preview-mode): Add it to 'window-selection-change-functions'. --- lisp/completion-preview.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 1d5f1253702..b4f35d436b3 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -377,6 +377,15 @@ completion-preview--active-p completion-preview-next-candidate)) (put cmd 'completion-predicate #'completion-preview--active-p)) +(defun completion-preview--window-selection-change (window) + "Hide completion preview in WINDOW after switching to another window. +Completion Preview mode adds this function to +`window-selection-change-functions', which see." + (unless (or (eq window (selected-window)) + (eq window (minibuffer-selected-window))) + (with-current-buffer (window-buffer window) + (completion-preview-active-mode -1)))) + ;;;###autoload (define-minor-mode completion-preview-mode "Show in-buffer completion suggestions in a preview as you type. @@ -391,8 +400,13 @@ completion-preview-mode cycles backward." :lighter " CP" (if completion-preview-mode - (add-hook 'post-command-hook #'completion-preview--post-command nil t) + (progn + (add-hook 'post-command-hook #'completion-preview--post-command nil t) + (add-hook 'window-selection-change-functions + #'completion-preview--window-selection-change nil t)) (remove-hook 'post-command-hook #'completion-preview--post-command t) + (remove-hook 'window-selection-change-functions + #'completion-preview--window-selection-change t) (completion-preview-active-mode -1))) (provide 'completion-preview) -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 07:05:07 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 12:05:07 +0000 Received: from localhost ([127.0.0.1]:38972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAqeI-0006Vh-Li for submit@debbugs.gnu.org; Wed, 06 Dec 2023 07:05:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAqeH-0006VB-CH for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 07:05:05 -0500 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 1rAqdz-0000vL-An; Wed, 06 Dec 2023 07:04:47 -0500 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=b+nzy7kSyosWk29IjbP5FIsuwXfAUhQaujMU642Q9to=; b=TqclJQ85k2/y pKXxcozDlcN5uKkF1EbKn2zvWMRUSvNv+zZ6YQtPH280xPNIb0PDhU8OZLchEEcIZ28jCrn8o2yBJ UwdvYV2m0DDbj2XJrQSAGYl3l5pjQw1/LSZDkzP6cCw66QPb1kdMdoW8agC1iYaCZIkNRVgASH/Y/ jIx/8GpLJNB/pUp2/+jpAaDcIWFUENhKCf7eU9hCjtKYiX8i4Srjp1iijbuu7bRm5X9OGEc5LJr7+ Jc5/pxQSeaNEDaKB+bKgE9NSYNZ/BnNSTr4yi03fBLFholF+i6J0x83auTu/5ijqGD0AgFk/KqDJZ L8fCSNqcyVgtUO8RpGkR4w==; Date: Wed, 06 Dec 2023 14:04:54 +0200 Message-Id: <83r0jz4jvd.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron In-Reply-To: (bug-gnu-emacs@gnu.org) Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (---) > Date: Tue, 05 Dec 2023 21:26:27 +0100 > From: Eshel Yaron via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > This patch ensures that we dismiss the completion preview when users > switch to another window. Previously, the completion preview would > remain in a window after switching to another window showing another > buffer, since the `post-command-hook` that Completion Preview mode sets > up locally doesn't run after a command switches to another buffer. Sorry, I don't understand: why does it matter whether post-command-hook runs _after_ switching to another buffer? When and why would a command that caused post-command-hook invocation NOT need to dismiss the preview? If post-command-hook should always dismiss the preview, then we shouldn't need another hook, right? From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 08:33:19 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 13:33:19 +0000 Received: from localhost ([127.0.0.1]:39108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAs1e-00033b-SH for submit@debbugs.gnu.org; Wed, 06 Dec 2023 08:33:19 -0500 Received: from mail.eshelyaron.com ([107.175.124.16]:52958 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAs1c-00033R-6V for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 08:33:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1701869583; bh=U8k2tz2lHzvfvT//MlunJCbhrCNW1tb/08PR2Bi/WdE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=akSjJz8pocn7CYNwg0B76LxaErOetzZM1st2heq1lloEBpzPDmOfuXkvybeaAaGVB dNPyFECjdK5i9vtFQJh9ft33Qx75xEDTH+HIXc7narwkV1+96QxxpGonGDQTUfYX7y 6q32l48jwEhPZZp9KZUjixPV8zNcqSz5wB5L22zTrLfMnS0dwz/foWMFWayMVd7dGM NgjZTutkkIEdwVYQeR0mS4/D9JGdkzwtWP25Xy5kc743CXBLLt5MwZzneaw9i6QXKO mmvF6vuHmKYucxJEoxN2yNtx31LB8ySUbXzna4YuZzOOu+zc8KIm60wvJKTA4PJCK+ p8rajfxSxdpDg== From: Eshel Yaron To: Eli Zaretskii Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows In-Reply-To: <83r0jz4jvd.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Dec 2023 14:04:54 +0200") References: <83r0jz4jvd.fsf@gnu.org> X-Hashcash: 1:20:231206:eliz@gnu.org::FMkIrYXjlwHm8oTq:qzp X-Hashcash: 1:20:231206:67650@debbugs.gnu.org::sQOp1YM2QEDvHaSW:EO8M Date: Wed, 06 Dec 2023 14:33:01 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (-) Hi Eli, Eli Zaretskii writes: >> Date: Tue, 05 Dec 2023 21:26:27 +0100 >> From: Eshel Yaron via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> This patch ensures that we dismiss the completion preview when users >> switch to another window. Previously, the completion preview would >> remain in a window after switching to another window showing another >> buffer, since the `post-command-hook` that Completion Preview mode sets >> up locally doesn't run after a command switches to another buffer. > > Sorry, I don't understand: No problem, let's clarify. > why does it matter whether post-command-hook runs _after_ switching to > another buffer? Since then the value of `post-command-hook` is no longer the buffer-local value you had in the buffer where you invoked the command, and in our case that buffer-local value is the one that includes `completion-preview--post-command`, where we would update (or dismiss) the completion preview for that (original) buffer. > When and why would a command that caused post-command-hook invocation > NOT need to dismiss the preview? What do you mean? All commands "cause `post-command-hook`", no? We show/hide/update the preview during `post-command-hook`. So for example, when `post-command-hook` runs after `self-insert-command`, we don't dismiss the preview, in fact we show it. Does that make sense? > If post-command-hook should always dismiss the preview That's not the case, see above. > then we shouldn't need another hook, right? Even if it were the case, we would need to handle the case when `post-command-hook` runs in a different buffer, with a different buffer-local value, after switching. And indeed we need to handle that case, which is what this patch does. Here's a recipe that you can try to see this patch in action: 1. emacs -Q 2. M-x completion-preview-mode RET 3. Type `(def` and see the preview appears 4. C-x 4 b foo RET Without this patch, you'd now see the preview linger in the window showing the *scratch* buffer. With this patch, the preview disappears as soon as you switch to the other window. Best, Eshel From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 11:44:37 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 16:44:37 +0000 Received: from localhost ([127.0.0.1]:40280 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAv0Y-0000PY-Hv for submit@debbugs.gnu.org; Wed, 06 Dec 2023 11:44:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60328) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAv0T-0000PI-Fk for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 11:44:21 -0500 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 1rAv08-0004XS-KA; Wed, 06 Dec 2023 11:43:59 -0500 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=Dp2oNSaWbTB00zdE4bMN8BUD/YAQVoigv/Weh7SiK38=; b=qVp9pO8fzHbe C82DS9G8xBUKPFEqYrA0z/BhpfC+I6ThZfQuAv1Z7EyF9JouS1MhTrVXRNRNWJRl6vJvlrMGERKR5 WhSvbVn+CGtelL9ILnfPxtcLbGsfoDgS+pQ6nrZCZGwPZjyw3iaPEDQoerFYys2AFG9Q2NTQYc2M/ B1lXoBAny7ASFOyuOVhsGYjC4Yh1fI9VuwoausK+gVpni7Op8e7nT/bzXuQtMZmwpkQDbYohEBi48 sxz1eLDhU9pD7iwcZNDCalT1uf7ZSzBUAvzNMR384KIKQvDfeWHOzpU8dIkbI9s0Ppc1BSTIF203a ZcynSYx5gajWIrGaRP7JTA==; Date: Wed, 06 Dec 2023 18:43:58 +0200 Message-Id: <837clr46y9.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron In-Reply-To: (message from Eshel Yaron on Wed, 06 Dec 2023 14:33:01 +0100) Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows References: <83r0jz4jvd.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (-) > From: Eshel Yaron > Cc: 67650@debbugs.gnu.org > Date: Wed, 06 Dec 2023 14:33:01 +0100 > > > why does it matter whether post-command-hook runs _after_ switching to > > another buffer? > > Since then the value of `post-command-hook` is no longer the > buffer-local value you had in the buffer where you invoked the command, > and in our case that buffer-local value is the one that includes > `completion-preview--post-command`, where we would update (or dismiss) > the completion preview for that (original) buffer. OK, I understand. However, it means that now we will not only slow down every command in the buffer that has the completion-preview mode turned on, but we will also slow down every redisplay cycle, even if the buffer was not switched. I think we should find a better way of doing this. How about that idle timer idea we discussed earlier? I'm beginning to like it more and more, and I have a reason to believe this is not the end of more and more hooks you'd need to add if we stay with this design. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 13:30:02 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 18:30:02 +0000 Received: from localhost ([127.0.0.1]:40426 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAwem-00065e-AA for submit@debbugs.gnu.org; Wed, 06 Dec 2023 13:30:02 -0500 Received: from mail.eshelyaron.com ([107.175.124.16]:50936 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAweZ-00065J-Vn for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 13:29:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1701887375; bh=HH5dXItNU4MpEatgReYJ54T9N2ac7+TW1BkDSzj4tRc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TJFew9ERqVXCUPWSCsuhp0BZNYwZdm6luxt57eKDHYIedl4oh49N1oBxKErF9VuEp kumfhZkAmU5+4NM1F8Cd8CwmmhOuBADHVcG7EfeHRjec2YBH83W8xFOoPiQ+wvEBI/ hRdDzL6hWtrR4IhTPTEm+hRhCS3cMvuyYPNYhc00NHlYJ4gnMSqYFS55QYg9gfIfpm 21ekbtshjq0ifH+6OUNSnawKwXd9T17947vOYE5ZUkSj/b2P9TyubNeBWlpNKxspgB 49xX3UeSRkufM8HAW/x8pzqah23AmrR+ZPCklugHJz9TAtr3O9RISHF7U+8381sC7O H9pLFPvfW35+g== From: Eshel Yaron To: Eli Zaretskii Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows In-Reply-To: <837clr46y9.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Dec 2023 18:43:58 +0200") References: <83r0jz4jvd.fsf@gnu.org> <837clr46y9.fsf@gnu.org> Date: Wed, 06 Dec 2023 19:29:32 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (-) Eli Zaretskii writes: > OK, I understand. However, it means that now we will not only slow > down every command in the buffer that has the completion-preview mode > turned on, but we will also slow down every redisplay cycle, even if > the buffer was not switched. How so? The docstring of `window-selection-change-functions` says: Functions specified buffer-locally are called for each window showing the corresponding buffer if and only if that window has been selected or deselected since the last redisplay. And indeed I see that the function this patch adds to that hook is only called in those circumstances. What performance impact do you envision for other redisplay cycles? > I think we should find a better way of doing this. I was also a bit uneasy with extending another hook at first, so I appreciate your scrutiny, and I'd love to consider different ways to achieve what we want here. But so far this is the best way I came up with, and after testing it and examining the specifics of the case I feel that it's not such a bad solution. > How about that idle timer idea we discussed earlier? I'm not sure I see how that would solve this issue, because we want to dismiss the preview as soon as you switch windows, and I imagine that an ideal timer would instead be less prompt to react to such a change. What do you have in mind? I also feel that we shouldn't underrate the ability of the current approach to display the preview immediately. In fact, one user said that Completion Preview mode "seems more smooth and efficient" then the package he was using before, which I attribute to this exact property of showing the preview without delay. > I'm beginning to like it more and more, and I have a reason to believe > this is not the end of more and more hooks you'd need to add if we > stay with this design. I share the concern that you're expressing towards excessive use of hooks, but I can't currently think of further cases in which we'll /need/ any hook but `post-command-hook` for showing/hiding the preview, and I think that we're still in the safe zone with this patch. Perhaps we should wait a few days to see if other suggestions come up? Thanks, Eshel From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 14:03:00 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 19:03:00 +0000 Received: from localhost ([127.0.0.1]:40444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAxAi-000719-7b for submit@debbugs.gnu.org; Wed, 06 Dec 2023 14:03:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAxAd-00070q-68 for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 14:02:58 -0500 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 1rAxAL-0005NS-QD; Wed, 06 Dec 2023 14:02:37 -0500 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=G5f1zuwHXhemDyH549Mv2N/PuY3XRXV+8FQaBWIy0Bg=; b=PnA9H1CeyGWT Q/ViBCGqY5Yi8tbtq7k64oHjVQx3wndUIFLdEguu6bZ56JgPED8eTL1kCtUQumqNe5lWLkW/sUrzq X1DE0BJ4L0ffGhXzW7z0Ux9+dOBz1g4liTK+CwHf0GOFUg0M9whrdnmItQbDmsnQshEX/t99j3NzJ +YDejAtzEcSpfU4z7E+yJSa1viDWuMw7Ysboflf1pppo2/lQ4DcUyPiKIzLKSliRPgm8rZcTIkvEW fhG6IAhsGzmT9qMeLOxyuqZnMJaMRnZykHorw0GkI6MvnuSq4gPa/RNqCc2AtodMPhpWtEufs5f0b mhV3ougloyDdPcNVedO0kA==; Date: Wed, 06 Dec 2023 21:02:47 +0200 Message-Id: <83v89b2lyg.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron In-Reply-To: (message from Eshel Yaron on Wed, 06 Dec 2023 19:29:32 +0100) Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows References: <83r0jz4jvd.fsf@gnu.org> <837clr46y9.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (---) > From: Eshel Yaron > Cc: 67650@debbugs.gnu.org > Date: Wed, 06 Dec 2023 19:29:32 +0100 > > Eli Zaretskii writes: > > > OK, I understand. However, it means that now we will not only slow > > down every command in the buffer that has the completion-preview mode > > turned on, but we will also slow down every redisplay cycle, even if > > the buffer was not switched. > > How so? The docstring of `window-selection-change-functions` says: > > Functions specified buffer-locally are called for each window showing > the corresponding buffer if and only if that window has been selected > or deselected since the last redisplay. > > And indeed I see that the function this patch adds to that hook is only > called in those circumstances. What performance impact do you envision > for other redisplay cycles? Look at the implementation. Each redisplay cycle we call run_window_change_functions, which then needs to decide whether to run any of the window-change related hooks, and for which windows. IOW, before we determine whether a window was selected or deselected, we need to examine them all. This wastes CPU cycles. I'm also worried about code that runs from with-selected-window and similar macros, about code that selects and then deselects the mini-window, and other similar "temporary changes" of the selected window. > > I think we should find a better way of doing this. > > I was also a bit uneasy with extending another hook at first, so I > appreciate your scrutiny, and I'd love to consider different ways to > achieve what we want here. But so far this is the best way I came up > with, and after testing it and examining the specifics of the case I > feel that it's not such a bad solution. > > > How about that idle timer idea we discussed earlier? > > I'm not sure I see how that would solve this issue, because we want to > dismiss the preview as soon as you switch windows, and I imagine that an > ideal timer would instead be less prompt to react to such a change. > What do you have in mind? Whether a timer will be prompt or not is determined by the time interval programmed into the timer. A small enough interval is indistinguishable from "as soon as". We pop down other features using timers, for example tooltips. It doesn't look bad in practice. Also, window-selection-change-functions cannot perform redisplay (because they are called in the middle of redisplay), so the effect will be seen only upon the next redisplay cycle -- not immediately anyway. > I also feel that we shouldn't underrate the ability of the current > approach to display the preview immediately. In fact, one user said > that Completion Preview mode "seems more smooth and efficient" then the > package he was using before, which I attribute to this exact property of > showing the preview without delay. Maybe so, but adding too much stuff to these hooks is inelegant, to say the least, and basically I'm reluctant to admit more and more of such features. We already have too many features on these hooks. And users rightfully complain that Emacs feels sluggish, except if you invoke "emacs -Q". > I share the concern that you're expressing towards excessive use of > hooks, but I can't currently think of further cases in which we'll > /need/ any hook but `post-command-hook` for showing/hiding the preview, > and I think that we're still in the safe zone with this patch. Well, please try to find alternative implementation ideas, as I'm very unhappy about going this way. Again, I suspect this is not the last hook you'd want to employ for this feature, we are just starting down that road. > Perhaps we should wait a few days to see if other suggestions come up? Fine by me. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 15:02:48 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 20:02:48 +0000 Received: from localhost ([127.0.0.1]:40470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAy6a-0000A6-2D for submit@debbugs.gnu.org; Wed, 06 Dec 2023 15:02:48 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:36441) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAy6Z-00009u-2o for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 15:02:47 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id EFE205C01A6; Wed, 6 Dec 2023 15:02:29 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 06 Dec 2023 15:02:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1701892949; x=1701979349; bh=qTTMdYrue+4yPqzcwI5AXh1je5W/wax8/CF urKEF42c=; b=j0xz0O3q0x7Ngif3c1BiU+6/4EODXvu2MxA1QMR1VtSPOpL1TK+ wwEuvt+I/Gg3yAeCVI/y0V41OKAXEFNCz0T3OrOXFaGiIYeoF4zX3QOI97MvfNuF 53QzyasI9P673CW6A8juZzQYr5jcCYt/f2zuUSIumEiCN5BDRoib8v7XANWyJ7pv XeobYAj76ZMeg1yGA0KWVD9sN7vjWJLMH6IXTfXBEiJdOcilIIN+puWOxNsDiy77 pxrx15ikZTJ3aIJjvm4BckqQIRrc6PGL1V0k0I57kalppP6ZtmcQA25Gst5uiWta 8lhlAXeyUPoyTXA9xcr1RR3gA51+rm3v/0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1701892949; x= 1701979349; bh=qTTMdYrue+4yPqzcwI5AXh1je5W/wax8/CFurKEF42c=; b=K 9JtKgVWyJbnnXf1kRqE36ch9Gc/Zd2e+fXuNw9PpB/BAswZ1Hj8k7GCNxkmGONe6 4UEat52suthizH5mAO+oNH/6EPt6HvYLtcNCc4wf79q9V1kFkMFGch6f5FuuwQrf BC+NM3K2Q2UBtmxNWAsQms62FJwOQJLrq+UvXouJJD2x//qDqQT34ezE4csIEf2x vELRydkOXWWMaru1tI+n7fTcLEE4I/5T3Nl9E2FdnjYvr9QJ1mZlr6GvLwQ75/v/ rjMUucfxH0nCBchSj5N+ZRhp+fn0F9xqCKtZ2X1Qqq4k4PPpHtJ04yaQloyFvTKr DE4UUXtWbYTS7fN0bW1dQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudektddgudefhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesth ejredttdefjeenucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehg uhhtohhvrdguvghvqeenucggtffrrghtthgvrhhnpeeghedthedujeeiteeutddtjeekhe ejteeukeehffdutdejuedvfeevueevieduudenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Dec 2023 15:02:28 -0500 (EST) Message-ID: <3f7a2df8-f673-9098-030e-ed00542d3bdb@gutov.dev> Date: Wed, 6 Dec 2023 22:02:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows Content-Language: en-US To: Eshel Yaron , 67650@debbugs.gnu.org References: From: Dmitry Gutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 67650 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.9 (---) On 05/12/2023 22:26, Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > This patch ensures that we dismiss the completion preview when users > switch to another window. Previously, the completion preview would > remain in a window after switching to another window showing another > buffer, since the `post-command-hook` that Completion Preview mode sets > up locally doesn't run after a command switches to another buffer. Another way to do this would look like this: diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 1d5f1253702..f2560a98b23 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -182,6 +182,7 @@ completion-preview--make-overlay (eq (get-text-property 0 'face previous) (get-text-property 0 'face string))) (add-text-properties 0 1 '(cursor 1) string) + (overlay-put completion-preview--overlay 'window (selected-window)) (overlay-put completion-preview--overlay 'after-string string)) completion-preview--overlay)) Although it depends on whether the overlay itself staying around is a good thing for this feature. You could also move some cleanup logic to pre-command-hook, which should be fine with the buffer-locality of the value. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 15:54:39 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 20:54:39 +0000 Received: from localhost ([127.0.0.1]:40527 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAyuk-0001ZH-IX for submit@debbugs.gnu.org; Wed, 06 Dec 2023 15:54:38 -0500 Received: from mail.eshelyaron.com ([107.175.124.16]:33026 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAyug-0001Z5-VP for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 15:54:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1701896062; bh=Ok3Af0I/vhneleTWhKqtEnMLa2m90yC8ElDUU9Wzrcg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UzuVgUqCqkw7ecI2qPlkq/NRkpVHlw77kG1ojfH/gRjjrtbUOapRLFW2hjxzMSf3d gI/ssJBF+dpFXk1Nl3V7LZSs1jkqfXOVGFinvv7wkViu06LycCgLNB0mir8YidjjPg ExkXZ+6Czj/6x1QDfOxl0HEkqIwu49IpniZpqlWQNVtwpPsnePKTCIoZR1q/ZuWdvV lafjj8Jnqk8fpR/LXqYYfrb3cNybz5S1vHve1IfBlnvHf+jC8FgXz0DLrz30a416S9 uOOAVUTHzMh8zZvDsKqMTZPWTyWTFkQIc79N2HNnhTEVil1cTtlim1HDmKXxozuIuH HznfkYiyUscGA== From: Eshel Yaron To: Dmitry Gutov Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows In-Reply-To: <3f7a2df8-f673-9098-030e-ed00542d3bdb@gutov.dev> (Dmitry Gutov's message of "Wed, 6 Dec 2023 22:02:25 +0200") References: <3f7a2df8-f673-9098-030e-ed00542d3bdb@gutov.dev> Date: Wed, 06 Dec 2023 21:54:20 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (-) Dmitry Gutov writes: > On 05/12/2023 22:26, Eshel Yaron via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: >> This patch ensures that we dismiss the completion preview when users >> switch to another window. Previously, the completion preview would >> remain in a window after switching to another window showing another >> buffer, since the `post-command-hook` that Completion Preview mode sets >> up locally doesn't run after a command switches to another buffer. > > Another way to do this would look like this: > > diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el > index 1d5f1253702..f2560a98b23 100644 > --- a/lisp/completion-preview.el > +++ b/lisp/completion-preview.el > @@ -182,6 +182,7 @@ completion-preview--make-overlay > (eq (get-text-property 0 'face previous) > (get-text-property 0 'face string))) > (add-text-properties 0 1 '(cursor 1) string) > + (overlay-put completion-preview--overlay 'window (selected-window)) > (overlay-put completion-preview--overlay 'after-string string)) > completion-preview--overlay)) > We actually have that already (a few lines above in this function), but it doesn't do the trick. This makes the overlay appear only in the selected window when you're editing a buffer that's displayed in multiple windows, but it doesn't make the overlay go away when you switch to another window. > You could also move some cleanup logic to pre-command-hook, which > should be fine with the buffer-locality of the value. Yes, I'm not sure if that's better than `window-selection-change-functions` though in terms of performance, and we'd need to put in some extra work to know if the command is going to select another window. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 06 16:16:46 2023 Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 21:16:46 +0000 Received: from localhost ([127.0.0.1]:40556 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAzGA-00028j-82 for submit@debbugs.gnu.org; Wed, 06 Dec 2023 16:16:46 -0500 Received: from mail.eshelyaron.com ([107.175.124.16]:58942 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rAzG7-00028X-D4 for 67650@debbugs.gnu.org; Wed, 06 Dec 2023 16:16:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1701897390; bh=jrw/JdyCFXXPKXlJYSDwwzobQrW090lx4/9SpWpagxI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=IaB4v9xfdNbns74/yJiEsRGa9l11z2JDuCiwCW45mYpQXkIY5tffc2QT9qnTT4SWC A1Z0ELTxCd0+qXpm3tWjlJug5VcSm9CbzmbGp6VYKnFSaE3s/N/fdvGxFt7gY9XarA LJJAo41uCX31cUWytVk1UVPx9L5TDF6eJck69s9UZTApvsfPq9l3Hl8m2SX7DCeT6u XQCYlKimtmv1EwXOSLOPiGlbdvu+2MfdN0+i+3Vjf4G3YsLVXaWuNMhsk5j+L+X3SE WxutUEK7Y3Dficf/9hXBUCtruIyXgG1jBAna1Ah34rXel30Jl9PQiLL4z7+5lGJjxY 88nAfPvJIxqQg== From: Eshel Yaron To: Eli Zaretskii Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows In-Reply-To: <83v89b2lyg.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Dec 2023 21:02:47 +0200") References: <83r0jz4jvd.fsf@gnu.org> <837clr46y9.fsf@gnu.org> <83v89b2lyg.fsf@gnu.org> Date: Wed, 06 Dec 2023 22:16:28 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67650 Cc: 67650@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 (-) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Eshel Yaron >> >> Eli Zaretskii writes: >> >> > ...now we will not only slow down every command in the buffer that >> > has the completion-preview mode turned on, but we will also slow >> > down every redisplay cycle, even if the buffer was not switched. >> >> How so? The docstring of `window-selection-change-functions` says: >> >> Functions specified buffer-locally are called for each window showing >> the corresponding buffer if and only if that window has been selected >> or deselected since the last redisplay. >> >> And indeed I see that the function this patch adds to that hook is only >> called in those circumstances. What performance impact do you envision >> for other redisplay cycles? > > Look at the implementation. Each redisplay cycle we call > run_window_change_functions, which then needs to decide whether to run > any of the window-change related hooks, and for which windows. IOW, > before we determine whether a window was selected or deselected, we > need to examine them all. This wastes CPU cycles. I have, and ISTM that the buffer-local value of `window-selection-change-functions` is only ever consulted in `run_window_change_functions_1`, which calls this functions in turn. That means that whenever redisplay happened without invoking our hook function, our hook function did not incur any performance penalty. Is there some fast path for when this hook is nil that I'm missing? > I'm also worried about code that runs from with-selected-window and > similar macros, about code that selects and then deselects the > mini-window, and other similar "temporary changes" of the selected > window. You'll find none of those here. My patch only says `with-current-buffer`, it do any temporary window selections. >> > How about that idle timer idea we discussed earlier? >> >> I'm not sure I see how that would solve this issue, because we want to >> dismiss the preview as soon as you switch windows, and I imagine that an >> ideal timer would instead be less prompt to react to such a change. >> What do you have in mind? > > Whether a timer will be prompt or not is determined by the time > interval programmed into the timer. A small enough interval is > indistinguishable from "as soon as". > > We pop down other features using timers, for example tooltips. It > doesn't look bad in practice. > > Also, window-selection-change-functions cannot perform redisplay > (because they are called in the middle of redisplay), so the effect > will be seen only upon the next redisplay cycle -- not immediately > anyway. Well, I don't see any delay. >> I also feel that we shouldn't underrate the ability of the current >> approach to display the preview immediately. In fact, one user said >> that Completion Preview mode "seems more smooth and efficient" then the >> package he was using before, which I attribute to this exact property of >> showing the preview without delay. > > Maybe so, but adding too much stuff to these hooks is inelegant, to > say the least, and basically I'm reluctant to admit more and more of > such features. We already have too many features on these hooks. And > users rightfully complain that Emacs feels sluggish, except if you > invoke "emacs -Q". > >> I share the concern that you're expressing towards excessive use of >> hooks, but I can't currently think of further cases in which we'll >> /need/ any hook but `post-command-hook` for showing/hiding the preview, >> and I think that we're still in the safe zone with this patch. > > Well, please try to find alternative implementation ideas, as I'm very > unhappy about going this way. Here's one. I'm attaching an updated patch (v2) that does the same thing, except now we only extend `window-selection-change-functions` when the preview is shown, and we remove our function from the hook immediately when hiding the preview. So you can have ten windows showing buffers with Completion Preview mode and only the selected buffer will have any `window-selection-change-functions`, and only when it's showing the preview. > Again, I suspect this is not the last hook you'd want to employ for > this feature, we are just starting down that road. Noted. >> Perhaps we should wait a few days to see if other suggestions come up? > > Fine by me. In the meantime, here's the updated patch: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v2-0001-Hide-completion-preview-when-switching-windows.patch >From ff0d83513f17d4f15ba46a8354dfb67507da1824 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 5 Dec 2023 21:04:43 +0100 Subject: [PATCH v2] ; Hide completion preview when switching windows * lisp/completion-preview.el (completion-preview--window-selection-change): New function. (completion-preview-active-mode): Add it to 'window-selection-change-functions'. (Bug#67650) --- lisp/completion-preview.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index 1d5f1253702..2ed2e5dd001 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -189,10 +189,24 @@ completion-preview--get "Return property PROP of the completion preview overlay." (overlay-get completion-preview--overlay prop)) +(defun completion-preview--window-selection-change (window) + "Hide completion preview in WINDOW after switching to another window. +Completion Preview mode adds this function to +`window-selection-change-functions', which see." + (unless (or (eq window (selected-window)) + (eq window (minibuffer-selected-window))) + (with-current-buffer (window-buffer window) + (completion-preview-active-mode -1)))) + (define-minor-mode completion-preview-active-mode "Mode for when the completion preview is shown." :interactive nil - (unless completion-preview-active-mode (completion-preview-hide))) + (if completion-preview-active-mode + (add-hook 'window-selection-change-functions + #'completion-preview--window-selection-change nil t) + (remove-hook 'window-selection-change-functions + #'completion-preview--window-selection-change t) + (completion-preview-hide))) (defun completion-preview--try-table (table beg end props) "Check TABLE for a completion matching the text between BEG and END. -- 2.42.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 09 04:09:00 2023 Received: (at 67650-done) by debbugs.gnu.org; 9 Dec 2023 09:09:00 +0000 Received: from localhost ([127.0.0.1]:46816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBtKV-0003dh-TN for submit@debbugs.gnu.org; Sat, 09 Dec 2023 04:09:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rBtKT-0003dT-Pk for 67650-done@debbugs.gnu.org; Sat, 09 Dec 2023 04:08:58 -0500 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 1rBtKA-0005JY-Tn; Sat, 09 Dec 2023 04:08:38 -0500 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=oplZJlWmog3OZE/qR8tVmDAy2uTGz+PoG/hyLA/2J1Q=; b=VGk1t1EbB8BV XgHeSh3uBiy3s5sqRQsCeTWSvNDQiNqZ+Joqoo95gNMtt4rps8u+932SFMs/+LhMl7DOANVT0EIt6 ctvrssOkvvC7GtWECEfNND6IHoiAYhV2ZIKr3zTGesg1lx8+w+fiVBeuAI0XVHAvMk5cQ8hMpjMS/ O+am+0IdCYj7J2BMME/dGLJrKEYC4FwhwcsS9TQNk7XZdKF2eBUW4AJgpx96mlw62QCHkTi3sI8QI pZ2Ixa1qCCpVq/X6whl2W6bCpVS7SERaEm+EuW3/pU8hbI3+fRsvTNb3Uea7YawjZsygnFXjbQGP8 Fw/53oRq7bS7VVf7Acr45Q==; Date: Sat, 09 Dec 2023 11:08:22 +0200 Message-Id: <83jzpnyc8p.fsf@gnu.org> From: Eli Zaretskii To: Eshel Yaron In-Reply-To: (message from Eshel Yaron on Wed, 06 Dec 2023 22:16:28 +0100) Subject: Re: bug#67650: [PATCH] ; Hide completion preview when switching windows References: <83r0jz4jvd.fsf@gnu.org> <837clr46y9.fsf@gnu.org> <83v89b2lyg.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67650-done Cc: 67650-done@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 (---) > From: Eshel Yaron > Cc: 67650@debbugs.gnu.org > Date: Wed, 06 Dec 2023 22:16:28 +0100 > > In the meantime, here's the updated patch: Thanks, installed on the master branch, and closing the bug. From unknown Sun Jun 22 17:13:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 06 Jan 2024 12:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator