From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hadron Newsgroups: gmane.emacs.help Subject: Re: help with c-mode-common-hook Date: Sun, 06 May 2007 20:29:22 +0200 Message-ID: <87irb5ajr1.fsf@gmail.com> References: <87vefb3y2e.fsf@gmail.com> <1178130129.512841.259390@y5g2000hsa.googlegroups.com> <87647b3wdu.fsf@gmail.com> <87y7k6rbyp.fsf@gmail.com> <87r6pyw75z.fsf@gmail.com> <87abwmdkul.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1178476410 31700 80.91.229.12 (6 May 2007 18:33:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 6 May 2007 18:33:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 06 20:33:29 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HklY1-0001D3-6l for geh-help-gnu-emacs@m.gmane.org; Sun, 06 May 2007 20:33:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hklet-0000P5-Py for geh-help-gnu-emacs@m.gmane.org; Sun, 06 May 2007 14:40:35 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 56 Original-X-Trace: individual.net CMuYxcsTuDQCDhlU+PKOqg496bm/5G3bR7qYb9AT7zs3HW1Xmm X-Orig-Path: news.individual.net!news X-Face: 2h#||Cd#d%F*NCm59[_6/{1a@jy%; |j>{D~4^gKg(^i%7j0IK?+,/GmW&:CD5fEKb_! User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.99 (gnu/linux) Cancel-Lock: sha1:tcbUU4WaRfL8c4ZR/zgnXn/Qd0M= Original-Xref: shelby.stanford.edu gnu.emacs.help:148172 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:43774 Archived-At: Kai Grossjohann writes: > Hadron writes: > >> Kai Grossjohann writes: >> >>> Hadron writes: >>> >>>> I'm not sure what ellided means. But how come it works in my direct >>>> add-hook then? The "old" way was working before (famous last words :-;). >>> >>> The "direct" method works because you have different code in that >>> case. >>> >>> To make the "direct" method fail, you need to do this: >>> >>> (add-hook 'c-mode-common-hook >>> (lambda () >>> (lambda () >>> ...same code as before))) >>> >>> As you can see, there is one lambda too many. >>> >> >> But there wasnt 2 lambdas in my other way: >> >> | (defun my-compile () >> | (message "in my-compile") >> | (lambda () [...] >> | ) >> >> Am I missing something glaringly obvious here? > > defun has an implicit lambda -- sorry if that wasn't clear. Perhaps I > explain it with Scheme (Pidgin Scheme, I haven't used actual Scheme > for at least 15 years) first: > > (define (foo) ...) is the same as (setq foo (lambda () ...)). Thus, > (define (foo) (lambda () ...)) is the same as (setq foo (lambda () > (lambda () ...))). > > In Emacs Lisp, it looks less symmetric: > > (defun foo () ...) is the same as (fset foo (lambda() ...)). Thus, > (defun foo () (lambda () ...)) is the same as (fset foo (lambda () > (lambda () ...))). > > To be concrete: my-compile is a function that, when called, does the > following: first, it prints something. Then it returns a function. > The function it returns would, if it were ever called, do useful > things. However, it is never called -- the return value of my-compile > is discarded (when my-compile is added to a hook and then the hook is > run). Thanks - I finally got it!