From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Phillip Lord" Newsgroups: gmane.emacs.devel Subject: Re: A programming puzzle with buffer-local hooks Date: Thu, 18 May 2017 15:54:04 -0000 Message-ID: <6b7b6dff5fbf17b2f66bcd711b1d60f5.squirrel@cloud103.planethippo.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1495122860 28424 195.159.176.226 (18 May 2017 15:54:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 18 May 2017 15:54:20 +0000 (UTC) User-Agent: SquirrelMail/1.5.2 [SVN] Cc: Emacs developers , Phillip Lord To: =?utf-8?B?IkNsw6ltZW50IFBpdC1DbGF1ZGVsIg==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 18 17:54:17 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBNkm-0007Fp-A8 for ged-emacs-devel@m.gmane.org; Thu, 18 May 2017 17:54:16 +0200 Original-Received: from localhost ([::1]:54466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBNkr-00030g-SC for ged-emacs-devel@m.gmane.org; Thu, 18 May 2017 11:54:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBNkh-00030K-Jo for emacs-devel@gnu.org; Thu, 18 May 2017 11:54:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBNkc-0007S8-88 for emacs-devel@gnu.org; Thu, 18 May 2017 11:54:11 -0400 Original-Received: from cloud103.planethippo.com ([78.129.138.110]:57316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBNkb-0007Rf-Vb for emacs-devel@gnu.org; Thu, 18 May 2017 11:54:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Cc:To:From:Subject:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qCqWwCvRrh6+79jNeiOw5QN9YQmSUN4E0/TdQj7DwBk=; b=d+liSCQc+j2jICZq/pH6SDsiZu KLk3QcNS1tz/XJyca5UwOosTNQYOqEzckU+iWilBynUJYSPz6U6M7P1r0OEVRTX9OVcaKHThv09yG 70PbWJ8EWiBTATUMkN1hujkLqf9OTeZSkAuinZYm2/xl3Grd0i+7G1uhdVohwF530tgI69EMkKV3R uWmHOaJ533EG49QfmoVKWDnmhOXu/wQigOHpxp/oG0vy/k7/tTxVn7quoRKlsVlrVZTvwUMqDpQtd HEQKAAyDDusQlITuwcZHOtWIu/qg2Q/0u8H04Ei6gtLkUew3ilGGKnomHBCy49epArgp/ZhM6j71y H96E6hCA==; Original-Received: from [127.0.0.1] (port=36996 helo=cloud103.planethippo.com) by cloud103.planethippo.com with esmtpa (Exim 4.89) (envelope-from ) id 1dBNka-0007TJ-0T; Thu, 18 May 2017 15:54:04 +0000 Original-Received: from 128.240.225.77 ([128.240.225.77]) (SquirrelMail authenticated user phillip.lord@russet.org.uk) by cloud103.planethippo.com with HTTP; Thu, 18 May 2017 15:54:04 -0000 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 78.129.138.110 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:214944 Archived-At: On Thu, May 18, 2017 3:45 pm, Clément Pit-Claudel wrote: > On 2017-05-18 11:16, Phillip Lord wrote: > >> Add the hook globally, and then have your hook functions check whether >> the mode is on or off before they do anything. > > I think that's mostly what I meant by "never removing the hook". Am I > misunderstanding you? Well, combined with making it global, yes. I always found developing a minor mode where we add and remove hooks to be a bit of a pain, because you can easily end up with different buffers have different state during development. On the other hand, if you have a single global hook, it's either there or not, just whether it works or not is dependent only on whether the minor-mode is on or not. Seems a lot nicer to me.