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

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

Re: "variable [in .emacs] is void"


From: Karl Pflästerer
Subject: Re: "variable [in .emacs] is void"
Date: Mon, 22 Dec 2003 17:01:55 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Hamster/2.0.4.0

An unnamed person wrote:

> Great.  That works.  Now, I have some other functions which also use
> mail-mode-map.  Can I wrap them in the same '(add-hook ...?  Or do I
> need to duplicate the lines for each? ... like this?

> (eval-after-load "sendmail"
>   '(add-hook 'mail-setup-hook
>            '(define-key mail-mode-map mail-foo...

> (eval-after-load "sendmail"
>   '(add-hook 'mail-setup-hook
>              '(define-key mail-mode-map mail-bar...

> (eval-after-load "sendmail"
>   '(add-hook 'mail-setup-hook
>              '(define-key mail-mode-map foo-be-do-be-do...

That depends on what you want to achive; to have multiple functions in a
hook you can wrap them in a lambda form or you can add them each
separately to the hook.

So either:

(eval-after-load "sendmail"
  '(add-hook 'mail-setup-hook
             '(define-key mail-mode-map mail-foo...))
  '(add-hook 'mail-setup-hook
             '(define-key mail-mode-map mail-bar...))
  '(add-hook 'mail-setup-hook
             '(define-key mail-mode-map foo-be-do-be-do...)))

or:
(eval-after-load "sendmail"
  '(add-hook 'mail-setup-hook
    (lambda ()
      (define-key mail-mode-map mail-foo...)
      (define-key mail-mode-map mail-bar...)
      (define-key mail-mode-map foo-be-do-be-do...))))


You needn't duplicate the `eval-after-load' macro.

> Even tidier and more readable, can I put all the sendmail-dependent
> defines in a separate (possibly byte-compiled) file and then have
> something like an "include"  in my emacs evaluate them all subject to an
> (eval-after-load "sendmail" ...)?

Yes.  That's the way a lot of people prefer.  Like that you don't lose
the oversight over your config files.

(eval-after-load "sendmail"
  (load "privhooks"))

;; privhooks.el
(add-hook 'mail-setup-hook
          (lambda ()
            (define-key mail-mode-map mail-foo...)
            (define-key mail-mode-map mail-bar...)
            (define-key mail-mode-map foo-be-do-be-do...))))


To byte-compile it you might need an

(eval-when-compile
 (require 'sendmail))

in the top of your privhooks.el.


   KP

-- 
"Lisp is worth learning for the profound enlightenment experience you
will have when you finally get it; that experience will make you a
better programmer for the rest of your days, even if you never
actually use Lisp itself a lot."                    -- Eric S. Raymond


reply via email to

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