From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: How to determine (from Elisp) whether the Emacs frame has focus? Date: Sat, 14 Nov 2015 15:40:59 +0200 Message-ID: <831tbsem1g.fsf@gnu.org> References: <87fv09o9p5.fsf@mbork.pl> <83twopdmz4.fsf@gnu.org> <83d1vcexdp.fsf@gnu.org> <871tbsbw01.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1447546338 10373 80.91.229.3 (15 Nov 2015 00:12:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Nov 2015 00:12:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 15 01:12:09 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZxkvQ-0003ut-EZ for geh-help-gnu-emacs@m.gmane.org; Sun, 15 Nov 2015 01:12:08 +0100 Original-Received: from localhost ([::1]:38415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxkvP-0001FU-PE for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Nov 2015 19:12:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zxb4q-0002xg-N7 for help-gnu-emacs@gnu.org; Sat, 14 Nov 2015 08:41:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zxb4n-0002IR-Fy for help-gnu-emacs@gnu.org; Sat, 14 Nov 2015 08:41:12 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:49854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zxb4n-0002ID-8k for help-gnu-emacs@gnu.org; Sat, 14 Nov 2015 08:41:09 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NXT0070043EIZ00@a-mtaout20.012.net.il> for help-gnu-emacs@gnu.org; Sat, 14 Nov 2015 15:41:08 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NXT007M24OJE270@a-mtaout20.012.net.il> for help-gnu-emacs@gnu.org; Sat, 14 Nov 2015 15:41:08 +0200 (IST) In-reply-to: <871tbsbw01.fsf@mbork.pl> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.166 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108068 Archived-At: > From: Marcin Borkowski > Cc: help-gnu-emacs@gnu.org > Date: Sat, 14 Nov 2015 13:34:06 +0100 > > > Then I don't understand why the solution of focus-in/out-hook was > > rejected as "hackish". These hooks are there precisely for situations > > like these, AFAIK. IMO, there's nothing hackish about that. > > AFAIU, these hooks are best suited to situations like "run LaTeX on > switching to a pdf viewer". That does not require global variables; my > use case does. Sorry, I still don't understand: why cannot the hook modify values of global variables, and thus serve your needs in this context? > Would it be possible to introduce a function like (emacs-has-focus-p) > for that? Would it make sense? What would that function do except test the value of some global variable, set by the focus-in and focus-out hooks? > For starters, I only want to know whether it is Emacs which has focus or > not. Then, I would like to know e.g. the mode of the current buffer; in > that case, I'm not sure what I should do when the current buffer is the > minibuffer or something. But this is less important for me now. There's only one current buffer in the entire Emacs session, and it doesn't change when Emacs loses focus. Its value is returned by the function current-buffer, as I'm sure you know. Or did you mean the buffer displayed in the selected window of the selected frame?