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: Marcin Borkowski
Subject: Re: How to determine (from Elisp) whether the Emacs frame has focus?
Date: Sat, 14 Nov 2015 13:34:06 +0100
User-agent: mu4e 0.9.15; emacs 25.0.50.1

On 2015-11-14, at 10:36, Eli Zaretskii <address@hidden> wrote:

>> From: Random832 <address@hidden>
>> Date: Sat, 14 Nov 2015 03:36:03 -0500
>> 
>> Eli Zaretskii <address@hidden> writes:
>> > I'm probably missing something very important, because I don't
>> > understand what you are looking for.  The selected frame by definition
>> > has focus, at least AFAIK.  What am I missing?
>> 
>> Well that may be true who never leave their Emacs instance, but for the
>> rest of us some non-Emacs application might have focus instead.
>
> Ah, so he meant detect when some other application has focus?  That's
> what I was missing, thanks.
>
> 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.

Would it be possible to introduce a function like (emacs-has-focus-p)
for that?  Would it make sense?

>> (Also I suspect by "selected" he meant a frame the programmer "selects"
>> to pass in to e.g. a function that answers the question, rather than
>> selected-frame.)
>
> I indeed feel there might still be aspects of the original question
> that need to be further clarified.

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.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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