From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kai Grossjohann Newsgroups: gmane.emacs.help Subject: Re: help with c-mode-common-hook Date: Thu, 03 May 2007 17:42:48 +0200 Message-ID: <86hcqtykuf.fsf@ketchup.de.uu.net> 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 1178207002 300 80.91.229.12 (3 May 2007 15:43:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 3 May 2007 15:43:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 03 17:43:20 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 1HjdSi-0001i7-3N for geh-help-gnu-emacs@m.gmane.org; Thu, 03 May 2007 17:43:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjdZE-0006mS-Th for geh-help-gnu-emacs@m.gmane.org; Thu, 03 May 2007 11:50:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HjdZ3-0006mM-62 for help-gnu-emacs@gnu.org; Thu, 03 May 2007 11:49:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HjdZ2-0006mA-MB for help-gnu-emacs@gnu.org; Thu, 03 May 2007 11:49:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HjdZ2-0006m7-Ja for help-gnu-emacs@gnu.org; Thu, 03 May 2007 11:49:52 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HjdSU-0003M4-NT for help-gnu-emacs@gnu.org; Thu, 03 May 2007 11:43:07 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1HjdSI-00048c-3k for help-gnu-emacs@gnu.org; Thu, 03 May 2007 17:42:54 +0200 Original-Received: from de-lt-054776l.eu.frd.uu.net ([62.191.185.105]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 May 2007 17:42:54 +0200 Original-Received: from kai by de-lt-054776l.eu.frd.uu.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 May 2007 17:42:54 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 54 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: de-lt-054776l.eu.frd.uu.net User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux) Cancel-Lock: sha1:mViaWzUuy2RkFgRmGOQ+vQBOCqw= X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:43601 Archived-At: 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). Kai