unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Hadron <hadronquark@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: help with c-mode-common-hook
Date: Sun, 06 May 2007 20:29:22 +0200	[thread overview]
Message-ID: <87irb5ajr1.fsf@gmail.com> (raw)
In-Reply-To: mailman.180.1178207394.32220.help-gnu-emacs@gnu.org

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!

      parent reply	other threads:[~2007-05-06 18:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-02 18:00 help with c-mode-common-hook Hadron
2007-05-02 18:22 ` Robert Thorpe
2007-05-02 18:37   ` Hadron
2007-05-03  0:24     ` Hadron
2007-05-03  6:26       ` Kevin Rodgers
     [not found]       ` <mailman.158.1178174006.32220.help-gnu-emacs@gnu.org>
2007-05-03 10:08         ` Hadron
2007-05-03 14:09           ` Kai Grossjohann
     [not found]           ` <mailman.175.1178201800.32220.help-gnu-emacs@gnu.org>
2007-05-03 14:48             ` Hadron
2007-05-03 15:42               ` Kai Grossjohann
2007-05-03 17:11               ` Robert Thorpe
     [not found]               ` <mailman.180.1178207394.32220.help-gnu-emacs@gnu.org>
2007-05-06 18:29                 ` Hadron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87irb5ajr1.fsf@gmail.com \
    --to=hadronquark@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).