From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Le Wang Newsgroups: gmane.emacs.help Subject: Re: doubt about mode hooks Date: Mon, 3 Jun 2013 23:21:16 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1370273709 2497 80.91.229.3 (3 Jun 2013 15:35:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Jun 2013 15:35:09 +0000 (UTC) Cc: help-gnu-emacs To: Luca Ferrari Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jun 03 17:35:10 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 1UjWmq-00062J-Oy for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Jun 2013 17:35:08 +0200 Original-Received: from localhost ([::1]:59268 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjWaH-00059N-LS for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Jun 2013 11:22:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjWZW-0004D6-Up for help-gnu-emacs@gnu.org; Mon, 03 Jun 2013 11:21:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjWZS-0000jd-1J for help-gnu-emacs@gnu.org; Mon, 03 Jun 2013 11:21:22 -0400 Original-Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:41144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjWZR-0000jP-PY for help-gnu-emacs@gnu.org; Mon, 03 Jun 2013 11:21:17 -0400 Original-Received: by mail-wi0-f175.google.com with SMTP id hn14so2809431wib.8 for ; Mon, 03 Jun 2013 08:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IdLpxHcKnA+A4B0aO7KmXDVWtAzdJ1Gp5V5H+7SXnmQ=; b=BpyfrpyLeLVXvWg6lpyJFOsdgrJXQ3bDBBk9wkh/Qw7iklp67WYA+HUwA6MnUlCjTs T5FSc7pNKsdIBEl7mjEpy/DKQnDSXR8VG6W5w4ysAgYtWmARyf0aNkLBLfc1JVUJS77r MuItQgTi6/EfF4kkAI2AE87RqSOTF7mZ5XYD4CtmaWAo/hAmQWnMpYjf9GbMYmY//Nm+ 1C+dOU1inbmG8uRIavoVT5ZTsrM3z0ua1a6L2UA6tx2Lw8xpDTRdj7mngXs4o5XNY45Z jeR3krZpgtVYH4WZ5A1p+x6SD3WcpK1sZvYOjuZweWAnaoIG/chDjhbnwqlzjNR24oqZ Deng== X-Received: by 10.180.160.167 with SMTP id xl7mr13234755wib.62.1370272876340; Mon, 03 Jun 2013 08:21:16 -0700 (PDT) Original-Received: by 10.217.88.4 with HTTP; Mon, 3 Jun 2013 08:21:16 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22f 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:91262 Archived-At: On Mon, Jun 3, 2013 at 10:51 PM, Luca Ferrari wrote: > Hi all, > so far I've added mode hooks with something like the following: > > (add-hook 'c-mode-hook (lambda() > (my-function-hook) ) > > but then I come across a snippet that does something different: > > (setq my-personal-hook 'my-function-hook) > (add-hook c-mode-hook (lambda () > (run-hooks 'my-personal-hook) ) t ) > > so I was wondering what are the differences and which advantages > should I get using the second. I cannot see any particular advantage > from the manual, so I'm guessing the second effectively does not add > the hook itself, rather a function that runs the hook. > Any explaination? Second way looks like fanciness for the sake of fanciness to me. The first way can also be simpler: (add-hook 'c-mode-hook 'my-c-setup-func) -- Le