help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what does 'eval-after-load' what 'add-hook' doesn't do?


From: Kevin Rodgers
Subject: Re: what does 'eval-after-load' what 'add-hook' doesn't do?
Date: Wed, 02 Jul 2003 09:40:56 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Leo wrote:

hi there

in for xemacs i want to bind a key in the dired-mode-map:

i tried:

(add-hook 'dired-load-hook
   (lambda ()
     '(define-key dired-mode-map "j" 'w32-shellex-dired-on-objects)
   ))

that doesn't work.


Because by quoting the (define-key ...) form, you prevent it from being
evaluated when the anonymous hook function is called.


now i found:

(eval-after-load
    "dired"
  '(define-key dired-mode-map "j" 'w32-shellex-dired-on-objects))

what works fine.

but why???

Because eval-after-load is a function, it's FORM argument has to be
quoted to prevent it from being evaluated when eval-after-load is
called.  (You want the form evaluated later, after the "dired" library
has been loaded.)  (lambda ..) effectively quotes the (define-key ...)
FORM for add-hook.


--
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;";>Kevin Rodgers</a>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]