From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: raman@google.com (T.V Raman) Newsgroups: gmane.emacs.devel Subject: Re: HowTo: Run a hook when a buffer becomes "current" Date: Wed, 16 Dec 2015 15:20:35 -0800 Message-ID: <22129.61891.619502.29074@retriever.mtv.corp.google.com> References: <874mfi5afk.fsf@ulb.ac.be> <87bn9q3sh8.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1450308058 4046 80.91.229.3 (16 Dec 2015 23:20:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Dec 2015 23:20:58 +0000 (UTC) Cc: emacs-devel@gnu.org, nrichard@ulb.ac.be, raman@google.com To: dak@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 17 00:20:46 2015 Return-path: Envelope-to: ged-emacs-devel@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 1a9LNF-0008M0-T5 for ged-emacs-devel@m.gmane.org; Thu, 17 Dec 2015 00:20:46 +0100 Original-Received: from localhost ([::1]:49862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9LNF-0005kh-3h for ged-emacs-devel@m.gmane.org; Wed, 16 Dec 2015 18:20:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9LNA-0005kM-VA for emacs-devel@gnu.org; Wed, 16 Dec 2015 18:20:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9LNA-0005yY-3r for emacs-devel@gnu.org; Wed, 16 Dec 2015 18:20:40 -0500 Original-Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]:32827) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9LN9-0005yS-T5 for emacs-devel@gnu.org; Wed, 16 Dec 2015 18:20:40 -0500 Original-Received: by mail-pa0-x22b.google.com with SMTP id ur14so31071437pab.0 for ; Wed, 16 Dec 2015 15:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:mime-version:content-type:content-transfer-encoding:message-id :date:to:cc:subject:in-reply-to:references; bh=Hc4MUbNJNdRYl9fi6SW+mGPwXtqSXqRmX3oCscXiKaw=; b=gHtWtMDW7x7MKWdOW33/Y0KPNf9BOA+39gnLa4clIfberlpnFIHDJ9wFc5OXYRcKqW GjWLzonRZnPjdNN+6jWiKfWXZ6Jf2jMHgZJAWaJH4n5Yu4l3yhkePxUGruIoMKXX2VZF 1IT2Yxog0WgPuy+ysOV0V6ZxnX6fmNdg54HMoBzABMyuCIAP/E0gR6r2d/E67nTOBvtd 5GL9HRUjXg6oMp682wTXhfhxGFq0aC9+OnXbKpPP+eL2/sRwMjREZQ0YFJKZqNxieHqk Nzp1CgLjRc3ETethSUmkFsMZ5M3ioK0uZ2ewxOsEvWnl+yYOgV5SZi+757U1OulcBDXR PpIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=Hc4MUbNJNdRYl9fi6SW+mGPwXtqSXqRmX3oCscXiKaw=; b=TbBOkBkWDBQmhFyune73rrtl+o7wZp1UhCGVSI8SSnqEl7O4TsCIt5QyvDwvqM+2/T j/FZIpTe/0LC9/mvK3aaADWLue//xYHTOTGrOfigkyynWQhAUKzTvij75xvqCn08aNZj b5f3rnZtmbDbJZhQlQChJ2PAKB5qakppripbgOrn5dZF5R9Fh7o9XD7+nQEMJdz6aTid dHXs4lkBAJoT18bpHAu0S9b2fOET1Eiva6t3t+oTwIwWf0f0SL99QcfBT/0Wj334HrHh F6BTn6DWyvxxI+wqC0CZCpKUyQv5dHWzxqkIzwdwykTs70GgXVfWFgoVyiXmLUqvpFb3 W5Cg== X-Gm-Message-State: ALoCoQnsOCwehU9QtPVa3TiJDy63oSp5826rmNUwcRZH662zVLmvo3TdC9WnZM0TrDpO1CO55EmCff/WHeDd1fLC8iYwXoPRkA== X-Received: by 10.66.237.35 with SMTP id uz3mr67512465pac.96.1450308039295; Wed, 16 Dec 2015 15:20:39 -0800 (PST) Original-Received: from retriever.mtv.corp.google.com ([172.22.162.32]) by smtp.gmail.com with ESMTPSA id ry1sm11412879pab.30.2015.12.16.15.20.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2015 15:20:36 -0800 (PST) Original-Received: by retriever.mtv.corp.google.com (Postfix, from userid 13930) id BCC3A1A147E; Wed, 16 Dec 2015 15:20:35 -0800 (PST) In-Reply-To: <87bn9q3sh8.fsf@fencepost.gnu.org> X-Mailer: VM 8.1.1 under 25.0.50.1 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:196404 Archived-At: For now, the only solution I've found is to advice select-window. Interestingly, the documentation for select-window points you at buffer-list-update-hook -- but it's likely that that hook's usage has diverged since that documentation for select-window was written; for fun I tried this: (defvar record nil) (defun my-record-buffer () (push (buffer-name) record)) (add-hook 'buffer-list-update-hook #'my-record-buffer) A single buffer switch causes a lot of things to get pushed there David Kastrup writes: > Nicolas Richard writes: > > > raman writes: > > > >> I was looking for a way of running a function when a buffer becomes > >> "current". I cant find any hooks in Emacs -- the closest is > >> buffer-list-update-hook -- but that gets called way too often > >> including when a buffer is buried, is visited transiently from within > >> lisp code etc. > > > > I think you're after window-configuration-change-hook, see > > (info "(elisp) Window Hooks") > > That would be for "selected", not "current". > > -- > David Kastrup -- --