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 21:54:20 +0100 Message-ID: References: <3f7a2df8-f673-9098-030e-ed00542d3bdb@gutov.dev> 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="3485"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67650@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 06 21:55:09 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 1rAyvE-0000eA-Jp for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Dec 2023 21:55:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rAyv4-0006q3-FP; Wed, 06 Dec 2023 15:54:58 -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 1rAyux-0006pn-Mt for bug-gnu-emacs@gnu.org; Wed, 06 Dec 2023 15:54:52 -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 1rAyux-0001Ki-3Y for bug-gnu-emacs@gnu.org; Wed, 06 Dec 2023 15:54:51 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rAyv8-0001Zz-0t for bug-gnu-emacs@gnu.org; Wed, 06 Dec 2023 15:55:02 -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 20:55: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.17018960796036 (code B ref 67650); Wed, 06 Dec 2023 20:55:01 +0000 Original-Received: (at 67650) by debbugs.gnu.org; 6 Dec 2023 20:54:39 +0000 Original-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 Original-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== In-Reply-To: <3f7a2df8-f673-9098-030e-ed00542d3bdb@gutov.dev> (Dmitry Gutov's message of "Wed, 6 Dec 2023 22:02:25 +0200") 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:275626 Archived-At: 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.