From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: question about "Making change-major-mode-hook buffer-local while locally let-bound!" Date: Tue, 22 Jun 2010 02:28:56 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1277166550 24072 80.91.229.12 (22 Jun 2010 00:29:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Jun 2010 00:29:10 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 22 02:29:09 2010 Return-path: Envelope-to: ged-emacs-devel@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 1OQrMS-0003Sf-43 for ged-emacs-devel@m.gmane.org; Tue, 22 Jun 2010 02:29:08 +0200 Original-Received: from localhost ([127.0.0.1]:42296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQrMR-0008Iu-Bh for ged-emacs-devel@m.gmane.org; Mon, 21 Jun 2010 20:29:07 -0400 Original-Received: from [140.186.70.92] (port=42464 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQrMJ-0008Hl-8H for emacs-devel@gnu.org; Mon, 21 Jun 2010 20:29:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQrMI-0004nz-26 for emacs-devel@gnu.org; Mon, 21 Jun 2010 20:28:59 -0400 Original-Received: from smtp-02.vtx.ch ([194.38.175.91]:52265) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQrMH-0004np-TS for emacs-devel@gnu.org; Mon, 21 Jun 2010 20:28:58 -0400 Original-Received: from ceviche.home (dyn.83-228-208-118.dsl.vtx.ch [83.228.208.118]) by smtp-02.vtx.ch (VTX Services SA) with ESMTP id 03E375FD2E; Tue, 22 Jun 2010 02:28:56 +0200 (CEST) Original-Received: by ceviche.home (Postfix, from userid 20848) id 2B6A766E08; Tue, 22 Jun 2010 02:28:56 +0200 (CEST) In-Reply-To: (Drew Adams's message of "Sun, 20 Jun 2010 09:51:33 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:126319 Archived-At: > (let ((emacs-lisp-mode-hook nil) > (change-major-mode-hook nil)) > (emacs-lisp-mode)) [...] > What is the right way to prevent these hooks from running here? E.g.: (make-local-variable 'emacs-lisp-mode-hook) (make-local-variable 'change-major-mode-hook) (let ((emacs-lisp-mode-hook nil) (change-major-mode-hook nil)) (emacs-lisp-mode)) > Do I need to use remove-hook followed by add-hook: saving, emptying and > repopulating the hook? What's the right approach? Those hooks are not permanent-local, so they'll be emptied and repopulated as needed by the call to emacs-lisp-mode. So you could probably just do: (set (make-local-variable 'emacs-lisp-mode-hook) nil) (set (make-local-variable 'change-major-mode-hook) nil) (emacs-lisp-mode) Or use `remove-hook' to eliminate only the particular values which are undesired rather than removing them all. > Why bother? What is gained by having such a runtime message? This messages is linked to a problematic circumstance where Emacs tries to do its best, but where the code should ideally be changed to avoid such a circumstance. So it's important to detect and warn about those cases, and sadly, I don't know how to do it at a better time. Stefan