From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Espen Newsgroups: gmane.emacs.help Subject: Re: Detect window switches? Date: Fri, 27 Sep 2013 11:27:36 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380295828 25758 80.91.229.3 (27 Sep 2013 15:30:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Sep 2013 15:30:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 27 17:30:32 2013 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 1VPZzm-0005uP-9f for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Sep 2013 17:30:18 +0200 Original-Received: from localhost ([::1]:37144 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPZzl-0003mZ-R7 for geh-help-gnu-emacs@m.gmane.org; Fri, 27 Sep 2013 11:30:17 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 64 Injection-Info: mx05.eternal-september.org; posting-host="5d070289bfddab8debea427f21ca33d2"; logging-data="882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wkqev154YO3hj1eonuNvb7t54TecQ3Zo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) Cancel-Lock: sha1:xQlmXOi/rGTrzbRLGGan6CIvla0= sha1:gw2fJejvlBKpwgyOA+pZMSTFY9s= Original-Xref: usenet.stanford.edu gnu.emacs.help:201399 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:93668 Archived-At: Eli Zaretskii writes: >> From: Dan Espen >> Date: Thu, 26 Sep 2013 16:15:52 -0400 >> >> Eli Zaretskii writes: >> >> >> From: Dan Espen >> >> Date: Thu, 26 Sep 2013 15:22:58 -0400 >> >> >> >> Eli Zaretskii writes: >> >> >> >> >> From: Dan Espen >> >> >> Date: Thu, 26 Sep 2013 14:22:15 -0400 >> >> >> >> >> >> My mode line changes color when a buffer changes from active/inactive. >> >> >> Isn't that what the OP is looking for? >> >> > >> >> > That's done on the C level, and Lisp programs cannot hook into this. >> >> >> >> Hmm, starting to sound like a bug. >> >> Here's an event that Emacs acts on but doesn't make the >> >> event visible to ELisp. >> > >> > No, Emacs doesn't act on this as an event. What happens is that the >> > next redisplay after a window switch redraws the mode line in a >> > different face. The redisplay isn't triggered by an event (because >> > there is no such event), it is triggered by other means, mostly >> > because Emacs becomes idle. That could happen many seconds after the >> > switch, if Emacs becomes busy calculating something, for example. >> >> I only meant event with the meaning that something happens. > > But that's just it: nothing happened, as far as Emacs is concerned. > As part of routine redisplay, Emacs displays the mode line of the > selected window differently than it does with other windows. It > doesn't track whether a particular window was selected earlier and > became non-selected now, so it doesn't know that "something's > happened". It just reflects the current state of affairs on the > screen. > >> Here Emacs sees a buffer become active or inactive > > No, it doesn't know a buffer _became_ active, it just _finds_ it to be > current or not current. > >> Well, it also changes the physical appearance of the keyboard cursor. >> Mine goes from 3 pixels wide to 1. > > More of the same. I think I understand. Switching buffers tells Emacs to redraw everything. Something else set the state flag to active or inactive and the redraw routines just see the new flag. So the place the hook is needed is where that state flag is set. And Emacs may need to add a test while setting that state flag to see if it's a change in state so it could run the new hook. -- Dan Espen