From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.devel Subject: Re: Confusion about first-change-hook Date: Wed, 19 Dec 2012 02:31:53 +0530 Message-ID: <874njjgjlq.fsf@gmail.com> References: <878v8vi11x.fsf@engster.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1355864320 17251 80.91.229.3 (18 Dec 2012 20:58:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Dec 2012 20:58:40 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 18 21:58:55 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 1Tl4FV-0003e5-Ia for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2012 21:58:49 +0100 Original-Received: from localhost ([::1]:60739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4FI-0000kX-5W for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2012 15:58:36 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4FG-0000k6-F7 for emacs-devel@gnu.org; Tue, 18 Dec 2012 15:58:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl4FC-0007Gp-R0 for emacs-devel@gnu.org; Tue, 18 Dec 2012 15:58:34 -0500 Original-Received: from mail-pa0-f53.google.com ([209.85.220.53]:64764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl4FC-0007Ga-Kh for emacs-devel@gnu.org; Tue, 18 Dec 2012 15:58:30 -0500 Original-Received: by mail-pa0-f53.google.com with SMTP id hz1so804307pad.40 for ; Tue, 18 Dec 2012 12:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=cqxFlVCcVOZFFgZ5JJdI9oX6EXSm8D2S/zS5hr6VmqE=; b=W9O2mv63uxjlbmhC27OHJPN50kafaWPslgQSUqAGfSWUZlBx/GPqkgEVL3ZaoqxcIU DfHLYA9bvRVDmsAzczpIz/7/E2YpQSvDn07dCCE8IIz81+aUhR+IWLoWqY4GUsUN3ozJ STm8TvhNeSqVR7U6EIwzrMssi8Sjd2hviZ12eeI2HhuaKyStG/2c87cywS/y6u/vux1L lmh8MpPZcadWIqCosL2fFG1ig8n5dzCHUpyC9cwzWtsqPVSRsCuxs3QXvsxIkhOhbqqN oZXYI+khUB6gfySU7iloJTCSb0n5YrG29gm0bN4E34PsZXl/LYS6jxosRXTioCn4NtAE Y/Qw== X-Received: by 10.68.233.196 with SMTP id ty4mr10913535pbc.23.1355864309643; Tue, 18 Dec 2012 12:58:29 -0800 (PST) Original-Received: from debian-6.05 ([115.184.74.123]) by mx.google.com with ESMTPS id o11sm1729699pby.8.2012.12.18.12.58.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 12:58:28 -0800 (PST) In-Reply-To: <878v8vi11x.fsf@engster.org> (David Engster's message of "Tue, 18 Dec 2012 20:59:38 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.53 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:155662 Archived-At: 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)) > > However, I soon saw that whitespace-mode got immediately activated in my > C++ buffers. The reason is that changing a text property apparently > already counts as "changing the buffer". Is this really the desired > behavior? If so, what else is there to achieve the above? Should I file > a wishlist-bug for something like 'buffer-modified-hook'? > > -David > > --