emacs-devel
[Top][All Lists]
Advanced

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

nesting eval-after-load?


From: Eric Abrahamsen
Subject: nesting eval-after-load?
Date: Tue, 05 Jun 2018 12:37:56 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

In Gnorb I've tried to make the various components (Org-focused,
Gnus-focused, BBDB-focused) loadable separately, by protecting some
setup with `eval-after-load'. In `gnorb-install-defaults' I tried to get
clever and use nested `eval-after-load's, so that some keys are bound
only if the user has elected to use, eg, *both* the Org and BBDB
functionality. `gnorb-install-defaults' has bits in it like this:

(eval-after-load "gnorb-bbdb"
    '(progn
       (define-key bbdb-mode-map (kbd "C-c S") #'gnorb-bbdb-mail-search)
       (define-key bbdb-mode-map (kbd "C-c l") #'gnorb-bbdb-open-link)
       (define-key bbdb-mode-map [remap bbdb-mail] #'gnorb-bbdb-mail)
       (eval-after-load "gnorb-org"
         (org-defkey org-mode-map (kbd "C-c C") #'gnorb-org-contact-link))))

This raises an error if the user loads "gnorb-org" and *then*
"gnorb-bbdb". What seems to happen is that first the "gnorb-org" form
is evaluated, and its return value (the function object
`gnorb-org-contact-link') is stored in the outer `eval-after-load'. When
"gnorb-bbdb" is loaded and the outer `eval-after-load' is evaluated,
`gnorb-org-contact-link' is actually run as a function (and complains
about wrong number of arguments).

I had assumed that the entire outer `eval-after-load' form would remain
"frozen" until "gnorb-bbdb" was loaded, at which point the inner
`eval-after-load' would be evaluated and either define the key or
"freeze" the inner form, depending.

Is there a better way to do this?

Thanks,
Eric




reply via email to

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