From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel Subject: Re: Confusion about first-change-hook Date: Tue, 18 Dec 2012 22:09:08 +0100 Message-ID: <87zk1bgj9n.fsf@engster.org> References: <878v8vi11x.fsf@engster.org> <874njjgjlq.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1355864957 22696 80.91.229.3 (18 Dec 2012 21:09:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Dec 2012 21:09:17 +0000 (UTC) Cc: emacs-devel@gnu.org To: Jambunathan K Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 18 22:09:32 2012 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 1Tl4Pr-000131-IO for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2012 22:09:31 +0100 Original-Received: from localhost ([::1]:41969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4Pd-0006Yy-Uw for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2012 16:09:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4Pa-0006Xh-5E for emacs-devel@gnu.org; Tue, 18 Dec 2012 16:09:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl4PY-0001mn-9D for emacs-devel@gnu.org; Tue, 18 Dec 2012 16:09:14 -0500 Original-Received: from randomsample.de ([83.169.19.17]:57060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4PX-0001mX-Sd for emacs-devel@gnu.org; Tue, 18 Dec 2012 16:09:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomsample.de; s=a; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From; bh=XRAeyMmQ5IjHgFBF9T0qqWpJzAnoEBdKkbtwnEedP8s=; b=tDC7j+1QgKejUBn5a1lgd/LFTqlDJQjAyWdFsWq6n3n43sjyhutiBK3F9tA1f6xKm4cnniLcM4yCClG1tw/Cchj6C86rEGXCbPrWLFt5Zyp22T1dMTSvd4Zt0wL16j4a; Original-Received: from dslc-082-083-045-171.pools.arcor-ip.net ([82.83.45.171] helo=spaten) by randomsample.de with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Tl4PV-0003Z9-0L; Tue, 18 Dec 2012 22:09:09 +0100 In-Reply-To: <874njjgjlq.fsf@gmail.com> (Jambunathan K.'s message of "Wed, 19 Dec 2012 02:31:53 +0530") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) Mail-Followup-To: Jambunathan K , emacs-devel@gnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 83.169.19.17 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:155664 Archived-At: Jambunathan K. writes: > David Engster writes: > >> I wanted to do something very simple: Activate whitespace-mode only when >> I start editing a buffer. So I looked into the manual and found >> `first-change-hook', which seemed exactly what I wanted. > > This seems to work: > > (add-hook 'c++-mode-hook > (lambda nil > (add-hook 'before-change-functions 'activate-whitespace-mode > nil 'local))) > > (defun activate-whitespace-mode (beg end) > (whitespace-mode 1) > (remove-hook 'before-change-functions > 'activate-whitespace-mode 'local)) Thank you. This works nicely. -David