From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#51862: after-focus-change-function: hard to understand documentation Date: Tue, 20 Sep 2022 16:45:18 +0200 Message-ID: <87h712ds01.fsf@gnus.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3807"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Daniel Colascione , 51862@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 20 20:49:14 2022 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 1oaiIz-0000oP-El for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Sep 2022 20:49:13 +0200 Original-Received: from localhost ([::1]:33954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaiIy-0006fk-De for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Sep 2022 14:49:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaeVe-0008NI-Vy for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 10:46:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaeVe-0000s7-2R for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 10:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oaeVd-0004bF-KO for bug-gnu-emacs@gnu.org; Tue, 20 Sep 2022 10:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Sep 2022 14:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51862 X-GNU-PR-Package: emacs Original-Received: via spool by 51862-submit@debbugs.gnu.org id=B51862.166368513317647 (code B ref 51862); Tue, 20 Sep 2022 14:46:01 +0000 Original-Received: (at 51862) by debbugs.gnu.org; 20 Sep 2022 14:45:33 +0000 Original-Received: from localhost ([127.0.0.1]:59167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaeVA-0004aY-Nc for submit@debbugs.gnu.org; Tue, 20 Sep 2022 10:45:33 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:47584) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oaeV9-0004aL-4G for 51862@debbugs.gnu.org; Tue, 20 Sep 2022 10:45:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eNpZDrJaBKcu6B6tJThWoj9geYPCZVKXltKGIxy+8YE=; b=sof9rLOVhsqPZFVcGZa4OEhC8N yrKX7/cwLfiys2G7x0VYAeB29IAxUkV7E85RxruSx8JAHmRZ001dHx9otb3ntIQewUOhwqPKjyJNs 1urUv0ghgtJ4diIJzxztZ19QgTM3iAGbuMQUFHief5xPqsafx/9Io5+6gGErefgslcMY=; Original-Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaeUz-0002xK-43; Tue, 20 Sep 2022 16:45:23 +0200 In-Reply-To: (Stefan Kangas's message of "Mon, 15 Nov 2021 03:00:35 -0800") X-Now-Playing: Sylvester's _Sylvester-Step II_: "Down, Down, Down" 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" Xref: news.gmane.io gmane.emacs.bugs:243204 Archived-At: Stefan Kangas writes: > This for me comes off as pretty scary. It sounds to me like I would > need to invest couple of hours at least into understanding all this, > when all I really want to do call a very simple function whenever focus > leaves a frame. I think the reason is to be found in the doc string of the obsoleted variables. That is: --- This hook is obsolete. Despite its name, this hook may be run in situations other than when a frame obtains input focus: for example, we also run this hook when switching the selected frame internally to handle certain input events (like mouse wheel scrolling) even when the user's notion of input focus hasn't changed. --- So it's not reliable (any more?), and that's why the new variable is the way it is. Probably (but it'd be helpful if Daniel could chime in). But looking at the code, I don't understand these caveats at all. In addition to the calls from xterm.el, the only place after-focus-change-function is called is from handle-focus-in/handle-focus-out -- which also call the old, obsolete hooks. So it doesn't seem to be more reliable, but just more incomprehensible. In addition, handle-focus-in/out know which frame they got the event for, but that's discarded. I guess the idea here might be that since you can get more than one focus-in event per real event, you should write your code to ensure that you don't trigger it more than once per frame? I.e., since this is all apparently probabilistic, we leave the hard stuff to the user. So I've tried to make the documentation here clearer and less scary, and I've added a really un-scary example.