From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: foucs-in-hook uses the last tty no the current. Date: Thu, 24 Nov 2016 21:35:38 +0200 Message-ID: <831sy06585.fsf@gnu.org> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1480016202 21468 195.159.176.226 (24 Nov 2016 19:36:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 Nov 2016 19:36:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 24 20:36:34 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9zou-00041O-Ra for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Nov 2016 20:36:32 +0100 Original-Received: from localhost ([::1]:41899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9zow-0007dY-Hc for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Nov 2016 14:36:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9zoQ-0007dH-L9 for help-gnu-emacs@gnu.org; Thu, 24 Nov 2016 14:36:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9zoL-000571-IK for help-gnu-emacs@gnu.org; Thu, 24 Nov 2016 14:36:02 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9zoL-00056t-EW for help-gnu-emacs@gnu.org; Thu, 24 Nov 2016 14:35:57 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4908 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1c9zoJ-0002sC-RN for help-gnu-emacs@gnu.org; Thu, 24 Nov 2016 14:35:57 -0500 In-reply-to: (message from Shiyao Ma on Wed, 23 Nov 2016 20:29:51 -0800 (PST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111787 Archived-At: > Date: Wed, 23 Nov 2016 20:29:51 -0800 (PST) > From: Shiyao Ma > > In emacs25, I found 'focus-in-hook uses the last focus-ed tty, not the to be focus-ed tty. > For example, > (add-hook 'focus-in-hook (lambda () (princ (terminal-name)))) > > It will print the last focus-ed tty. terminal-name is documented to return the name of the terminal of the selected frame, so I don't think you can assume it will return the terminal of the frame which _will_ be selected after the focus-in event is processed. > This is semantically wrong and makes this hook not useful at all, (we already have 'foucs-out-hook). focus-in-hook is useful for doing something when Emacs gets focus, not necessarily related to the frame which was or will be the selected frame. For example, blink-cursor-mode uses this hook just fine. It sounds like you want to use some other hook or feature for your purpose. Did you try to bind your function to the switch-frame pseudo-key, for example?