From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: hook syntax (was: Re: how to get around deprecated function) Date: Fri, 01 May 2015 05:55:10 +0200 Organization: Aioe.org NNTP Server Message-ID: <871tj1gdep.fsf_-_@debian.uxu> References: <87twvzx252.fsf@debian.uxu> <55426DFE.2050600@nihilo.net> <87y4l9p04r.fsf@debian.uxu> 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 1430452523 9154 80.91.229.3 (1 May 2015 03:55:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 May 2015 03:55:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 01 05:55:19 2015 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 1Yo22o-0002TQ-Ng for geh-help-gnu-emacs@m.gmane.org; Fri, 01 May 2015 05:55:18 +0200 Original-Received: from localhost ([::1]:46668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yo22n-0007If-NA for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Apr 2015 23:55:17 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 60 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:67VRumtbdYfukA8n7ZjlArwFpkA= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:211841 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:104124 Archived-At: Emanuel Berg writes: > By the way, and people probably have different views > on this, but I think all that add-hook stuff is > confusing. It is better to find out what the hook > is. Offen it is empty or consists of a single or but > a few items. Examine what is there and decide if you > want it. Then set up the hook explicitly, e.g. > > (setq perl-mode-hook 'enable-line-mode) ; Perl > > But there is nothing wrong with add-hook and I use > it sometimes dynamically. But in init files, I don't > see why not setting up the hooks explicitly offers > a higher degree of clarity and control. As I expected, in the docs it says you should use add-hook: (info "(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 ... is to use ‘add-hook’ (info "(elisp)Hooks") The recommended way to add a hook function to a hook is by calling ‘add-hook’ However, I have many (10-20) hooks set like this: (setq perl-mode-hook 'enable-line-mode) This gets perl-mode-hook ; => enable-line-mode If I do (setq perl-mode-hook nil) (add-hook 'perl-mode-hook 'enable-line-mode) I get perl-mode-hook ; => (enable-line-mode) The "incorrect" syntax always worked, until I just now found that for `message-mode-hook' I must do (setq message-mode-hook '(disable-super-global-keys)) So maybe I should retract my piece of advice. Or at least, if the setq method is to be used, make it a list (even for singular functions) at the first sight of trouble. Because that might be just it... -- underground experts united http://user.it.uu.se/~embe8573