[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with c-mode-common-hook
From: |
Hadron |
Subject: |
Re: help with c-mode-common-hook |
Date: |
Sun, 06 May 2007 20:29:22 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.99 (gnu/linux) |
Kai Grossjohann <kai@emptydomain.de> writes:
> Hadron <hadronquark@gmail.com> writes:
>
>> Kai Grossjohann <kai@emptydomain.de> writes:
>>
>>> Hadron <hadronquark@gmail.com> 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!
- help with c-mode-common-hook, Hadron, 2007/05/02
- Re: help with c-mode-common-hook, Robert Thorpe, 2007/05/02
- Re: help with c-mode-common-hook, Hadron, 2007/05/02
- Re: help with c-mode-common-hook, Hadron, 2007/05/02
- Re: help with c-mode-common-hook, Kevin Rodgers, 2007/05/03
- Message not available
- Re: help with c-mode-common-hook, Hadron, 2007/05/03
- Re: help with c-mode-common-hook, Kai Grossjohann, 2007/05/03
- Message not available
- Re: help with c-mode-common-hook, Hadron, 2007/05/03
- Re: help with c-mode-common-hook, Kai Grossjohann, 2007/05/03
- Re: help with c-mode-common-hook, Robert Thorpe, 2007/05/03
- Message not available
- Re: help with c-mode-common-hook,
Hadron <=