From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Elena Newsgroups: gmane.emacs.help Subject: Re: Hook for "buffer switched" Date: Wed, 15 Dec 2010 01:02:40 -0800 (PST) Organization: http://groups.google.com Message-ID: <44c604d5-d4ca-4914-bc02-40f0fada6f3d@y31g2000vbt.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1292406143 1802 80.91.229.12 (15 Dec 2010 09:42:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Dec 2010 09:42:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 15 10:42:18 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PSnsH-0000Tu-Lq for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Dec 2010 10:42:17 +0100 Original-Received: from localhost ([127.0.0.1]:36100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSnsG-00045U-UM for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Dec 2010 04:42:16 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!y31g2000vbt.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 24 Original-NNTP-Posting-Host: 89.96.190.244 Original-X-Trace: posting.google.com 1292403760 931 127.0.0.1 (15 Dec 2010 09:02:40 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 15 Dec 2010 09:02:40 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y31g2000vbt.googlegroups.com; posting-host=89.96.190.244; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:183281 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:77517 Archived-At: On Dec 15, 5:07=A0am, Stefan Monnier wrote: > > Is there any hook that is run when a buffer is switched? > > I think generally the answer is "no", tho this question is ill-formed: > it's not clear what you mean by switching buffer: do you mean "change > the currently active buffer" (i.e. what is done by `set-buffer'), or > "change the buffer displayed in the current window", or "select > a different window showing a different buffer", or ... I would like to be able to handle the "change the currently active buffer" case. > > If not, why not? > > Maybe because to a large extent it's an ill-defined problem and once > they try to define it better, people seem to end up deciding they don't > really need to solve it any more? Or maybe because they are not able to solve it reliably. For instance, I'd like Viper state to be global instead of buffer-local. For this to work, I would have to know whenever the current active buffer changes and switch Viper state when needed. Or I could just prefer always switching to Normal state whenever I switch buffer.