From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: add-hook Date: Fri, 25 Jan 2013 11:18:57 -0800 Message-ID: References: <902E1C3E-E017-4109-9904-803220E5EE58@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1359141553 24014 80.91.229.3 (25 Jan 2013 19:19:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Jan 2013 19:19:13 +0000 (UTC) To: "'Perry Smith'" , "'Emacs help'" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 25 20:19:33 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 1TyooE-0001XW-Gs for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Jan 2013 20:19:30 +0100 Original-Received: from localhost ([::1]:57816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyonw-0007h7-Su for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Jan 2013 14:19:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyonq-0007gN-1g for help-gnu-emacs@gnu.org; Fri, 25 Jan 2013 14:19:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tyono-0000uZ-PD for help-gnu-emacs@gnu.org; Fri, 25 Jan 2013 14:19:05 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:32306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyono-0000uO-Ir for help-gnu-emacs@gnu.org; Fri, 25 Jan 2013 14:19:04 -0500 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0PJJ2tS011311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 Jan 2013 19:19:03 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0PJJ1cd023187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jan 2013 19:19:02 GMT Original-Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r0PJJ1ke023462; Fri, 25 Jan 2013 13:19:01 -0600 Original-Received: from dradamslap1 (/10.159.189.45) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 25 Jan 2013 11:19:01 -0800 X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Thread-Index: Ac37L5EZ3vQVXESTRWCF9WAXr8LShQAADSgA In-Reply-To: <902E1C3E-E017-4109-9904-803220E5EE58@gmail.com> X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 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:88815 Archived-At: > In one of my setup files I have this: > > (eval-after-load 'ruby-mode > '(add-hook > 'ruby-mode-hook > (function > (lambda () > (ruby-electric-mode t))))) > > Other places, I just do the add-hook. You don't need the `eval-after-load' (or the `function'). > The reason I'm asking is because I need to do: > (eval-after-load 'grep '(add-to-list 'grep-files-aliases ...)) > because if I don't, I get an error that says grep-files-aliases > is not defined. > > It appears as if add-hook has smarts that add-to-list does not Good question. Let's ask Emacs... Yes - see the last paragraph of `C-h f add-hook': ,---- | add-hook is a compiled Lisp function in `subr.el'. | (add-hook HOOK FUNCTION &optional APPEND LOCAL) | | Add to the value of HOOK the function FUNCTION. | FUNCTION is not added if already present. | FUNCTION is added (if necessary) at the beginning of the hook list | unless the optional argument APPEND is non-nil, in which case | FUNCTION is added at the end. | | The optional fourth argument, LOCAL, if non-nil, says to modify | the hook's buffer-local value rather than its global value. | This makes the hook buffer-local, and it makes t a member of the | buffer-local value. That acts as a flag to run the hook | functions of the global value as well as in the local value. | | HOOK should be a symbol, and FUNCTION may be any valid function. If | HOOK is void, it is first set to nil. If HOOK's value is a single | function, it is changed to a list of functions. `---- If HOOK is void then it is initialized to nil. (add-hook 'ruby-mode-hook (lambda () (ruby-electric-mode t)))