From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: does customizing a hook "add-to" the hook? Date: Tue, 16 Jul 2013 00:49:16 +0200 Message-ID: <87mwpn4exf.fsf@web.de> References: <87wqou6tkw.fsf@nyu.edu> <871u703bmd.fsf@web.de> <87d2qj8xok.fsf@nyu.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1373928591 28000 80.91.229.3 (15 Jul 2013 22:49:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Jul 2013 22:49:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 16 00:49:52 2013 Return-path: Envelope-to: geh-help-gnu-emacs@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 1UyraZ-0001hB-O7 for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Jul 2013 00:49:51 +0200 Original-Received: from localhost ([::1]:37681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyraZ-0008Jp-ET for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Jul 2013 18:49:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyraO-0008JY-10 for help-gnu-emacs@gnu.org; Mon, 15 Jul 2013 18:49:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UyraM-00028b-I7 for help-gnu-emacs@gnu.org; Mon, 15 Jul 2013 18:49:39 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:55354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UyraM-00028R-Bu for help-gnu-emacs@gnu.org; Mon, 15 Jul 2013 18:49:38 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UyraJ-0001bs-IB for help-gnu-emacs@gnu.org; Tue, 16 Jul 2013 00:49:35 +0200 Original-Received: from ip-90-186-142-203.web.vodafone.de ([90.186.142.203]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 16 Jul 2013 00:49:35 +0200 Original-Received: from michael_heerdegen by ip-90-186-142-203.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 16 Jul 2013 00:49:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-142-203.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:Bdhde946CX7TJzsu6lkO78iadLQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92144 Archived-At: gottlieb@nyu.edu writes: > > All relevant hooks I know are empty when declared in the sources. So if > > you load your `custom-file' early enough when starting up Emacs (i.e., > > before modifying hooks or loading packages), you don't need to worry > > about your or third party code adding stuff to the hook, that works > > normally. > > Thank you for the response. > That was exactly my concern. Namely that I (in this order) > > 1. set a hook via customize > 2. upgrade emacs > 3. run the new emacs (with my same startup files) > > and then some new default would be overridden since my customization > overwrites the hook instead of adding to it. > > Is it guaranteed or suggested that hook are by default empty? No, it's not a convention AFAICT. And there are examples in the sources where this is not the case, although they are a minority. There are probably also cases where a user indeed wants to replace an element of a hook variable with another one or "delete" elements, so it makes some sense that hooks are not always declared empty. You have to be a bit careful. There is no absolute guarantee that your customization will work in future Emacsen. If you want a more finegrained control, use Lisp. But also what you do in Lisp can be wrong in future Emacsen. I agree that there is a bit a disparity between the manual ((emacs) Hooks): | You can set a hook variable with ‘setq’ like any other Lisp | variable, but the recommended way to add a function to a hook (either | normal or abnormal) is to use ‘add-hook’, as shown by the following | examples. *Note (elisp)Hooks::, for details. and how Customize works (setting the hook variable instead of adding). Regards, Michael.