[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: |
Sun, 15 Nov 2015 21:45:24 +0200 |
> From: Marcin Borkowski <mbork@mbork.pl>
> Cc: help-gnu-emacs@gnu.org
> Date: Sun, 15 Nov 2015 08:45:03 +0100
>
> >> 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?
>
> Well, it could do it without using those hooks, if it were in C. But
> you're probably right (again), there's no need to add that to the core.
In any case, I see no way for Emacs to provide this information,
except by tracking these focus events. So doing it in an application
will not lose anything, I think.
> >> 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.
>
> Of course. However, what I really mean is not exactly (current-buffer),
> but "the buffer I'm working in now". This means that if
> e.g. current-buffer is the minibuffer (as might be the case during
> search or M-x or whatever), I would prefer /the buffer I'll get back to
> when I finish doing whatever I'm doing in the minibuffer/, or /the
> buffer I was in when I switched to the minibuffer/ (these two need not
> coincide, of course, e.g. in case of C-x b - in such a case I'm fine
> with whichever one). This might be the other-buffer, I'm not sure -
> I'll have to study the docs a bit more.
At least wrt to being in the minibuffer, Emacs already does what you
want, otherwise "M-: (current-buffer) RET" would not do what you
expect.
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, (continued)
Re: How to determine (from Elisp) whether the Emacs frame has focus?, Eli Zaretskii, 2015/11/14
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Random832, 2015/11/14
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Eli Zaretskii, 2015/11/14
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Marcin Borkowski, 2015/11/14
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Eli Zaretskii, 2015/11/14
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Marcin Borkowski, 2015/11/16
- Re: How to determine (from Elisp) whether the Emacs frame has focus?,
Eli Zaretskii <=
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Nicolas Richard, 2015/11/16
- Re: How to determine (from Elisp) whether the Emacs frame has focus?, Marcin Borkowski, 2015/11/16
Re: How to determine (from Elisp) whether the Emacs frame has focus?, Stefan Monnier, 2015/11/16
Re: How to determine (from Elisp) whether the Emacs frame has focus?, Marcin Borkowski, 2015/11/16
Re: How to determine (from Elisp) whether the Emacs frame has focus?, Michael Heerdegen, 2015/11/14
Re: How to determine (from Elisp) whether the Emacs frame has focus?, Marcin Borkowski, 2015/11/14