From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: switch-buffer-hook to catch the switch-event? Date: Tue, 26 Feb 2013 05:23:16 +0100 Message-ID: <87wqtvn1or.fsf@gmail.com> References: <87ehg3oqjm.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1361852694 23565 80.91.229.3 (26 Feb 2013 04:24:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 Feb 2013 04:24:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 26 05:25:17 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 1UAC6O-0003wk-NP for geh-help-gnu-emacs@m.gmane.org; Tue, 26 Feb 2013 05:25:16 +0100 Original-Received: from localhost ([::1]:49283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAC63-0003Ym-JT for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Feb 2013 23:24:55 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAC5x-0003YT-Ha for help-gnu-emacs@gnu.org; Mon, 25 Feb 2013 23:24:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAC5u-0007sb-OK for help-gnu-emacs@gnu.org; Mon, 25 Feb 2013 23:24:49 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:34083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAC5u-0007sQ-Hx for help-gnu-emacs@gnu.org; Mon, 25 Feb 2013 23:24:46 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UAC6C-0003rg-9M for help-gnu-emacs@gnu.org; Tue, 26 Feb 2013 05:25:04 +0100 Original-Received: from g231233014.adsl.alicedsl.de ([92.231.233.14]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Feb 2013 05:25:04 +0100 Original-Received: from tjolitz by g231233014.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Feb 2013 05:25:04 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 21 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231233014.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:EATXTWwPamEonG4oyF4EJMqUSeA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:89261 Archived-At: Stefan Monnier writes: >> How can I trigger an action everytime a certain buffer gets the focus >> (becomes current-buffer)? Is there no hook for 'switch-buffer' or >> something similar? > > No, indeed, there isn't. You can use window-configuration-change-hook > to detect changes within an Emacs frame, but in order to detect focus > changing from/to Emacs to/from other applications you'd additionally > need a focus-hook, but last I checked the corresponding C-level events > are not reliably propagated to Elisp. Patch welcome. window-configuration-change-hook is not exactly what I was looking for, but in the absence of a more straight-forward solution I'll give it a try. If the only thing that happens is a 'switch-window or 'switch-buffer command - is that considered a window-configuration-change and triggers the hook? -- cheers, Thorsten