unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to determine (from Elisp) whether the Emacs frame has focus?
Date: Sun, 15 Nov 2015 08:45:03 +0100	[thread overview]
Message-ID: <876113wvv3.fsf@mbork.pl> (raw)
In-Reply-To: <831tbsem1g.fsf@gnu.org>


On 2015-11-14, at 14:40, Eli Zaretskii <eliz@gnu.org> wrote:

>> 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?

Well, you're probably right, I'm just overthinking it.

>> 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.

>> 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.

Best,

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



  reply	other threads:[~2015-11-15  7:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 21:45 How to determine (from Elisp) whether the Emacs frame has focus? Marcin Borkowski
2015-11-14  3:48 ` Emanuel Berg
2015-11-14  4:05 ` John Mastro
2015-11-14  7:30   ` tomas
2015-11-14  8:44     ` Marcin Borkowski
2015-11-14 10:45       ` tomas
2015-11-14 20:28         ` Marcin Borkowski
2015-11-14  8:06 ` Eli Zaretskii
2015-11-14  8:36   ` Random832
2015-11-14  9:36     ` Eli Zaretskii
2015-11-14 12:34       ` Marcin Borkowski
2015-11-14 13:40         ` Eli Zaretskii
2015-11-15  7:45           ` Marcin Borkowski [this message]
2015-11-15 19:45             ` Eli Zaretskii
2015-11-16 14:08             ` Nicolas Richard
2015-11-16 16:58               ` Marcin Borkowski
2015-11-14 21:10         ` Stefan Monnier
2015-11-16 17:00           ` Marcin Borkowski
2015-11-14  8:42   ` Marcin Borkowski
2015-11-14  8:59     ` Eli Zaretskii
2015-11-14 10:54       ` Yuri Khan
2015-11-14 11:04         ` Eli Zaretskii
2015-11-14  8:44   ` Michael Heerdegen
2015-11-14 10:15     ` Marcin Borkowski
     [not found] <mailman.2293.1447451126.7904.help-gnu-emacs@gnu.org>
2015-11-16  6:53 ` Dan Espen
2015-11-17  0:10   ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=876113wvv3.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).