help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to determine (from Elisp) whether the Emacs frame has focus?


From: Eli Zaretskii
Subject: Re: How to determine (from Elisp) whether the Emacs frame has focus?
Date: Sat, 14 Nov 2015 15:40:59 +0200

> From: Marcin Borkowski <mbork@mbork.pl>
> 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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]