From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67650: [PATCH] ; Hide completion preview when switching windows Date: Wed, 06 Dec 2023 14:33:01 +0100 Message-ID: References: <83r0jz4jvd.fsf@gnu.org> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26182"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67650@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 06 14:34:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rAs2Z-0006Xl-HP for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Dec 2023 14:34:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rAs2B-0007aH-73; Wed, 06 Dec 2023 08:33:51 -0500 Original-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 1rAs2A-0007a9-Fa for bug-gnu-emacs@gnu.org; Wed, 06 Dec 2023 08:33:50 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rAs2A-00020G-6q for bug-gnu-emacs@gnu.org; Wed, 06 Dec 2023 08:33:50 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rAs2L-00034h-Ta for bug-gnu-emacs@gnu.org; Wed, 06 Dec 2023 08:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Dec 2023 13:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67650 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 67650-submit@debbugs.gnu.org id=B67650.170186959911760 (code B ref 67650); Wed, 06 Dec 2023 13:34:01 +0000 Original-Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 13:33:19 +0000 Original-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 Original-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== In-Reply-To: <83r0jz4jvd.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 06 Dec 2023 14:04:54 +0200") X-Hashcash: 1:20:231206:eliz@gnu.org::FMkIrYXjlwHm8oTq:qzp X-Hashcash: 1:20:231206:67650@debbugs.gnu.org::sQOp1YM2QEDvHaSW:EO8M X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275601 Archived-At: 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