unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* nesting eval-after-load?
@ 2018-06-05 19:37 Eric Abrahamsen
  2018-06-05 19:44 ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2018-06-05 19:37 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: nesting eval-after-load?
  2018-06-05 19:37 nesting eval-after-load? Eric Abrahamsen
@ 2018-06-05 19:44 ` Noam Postavsky
  2018-06-05 19:51   ` Eric Abrahamsen
  0 siblings, 1 reply; 3+ messages in thread
From: Noam Postavsky @ 2018-06-05 19:44 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: Emacs developers

On 5 June 2018 at 15:37, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

> (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))))

Missing quote for the inner eval-after-load?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: nesting eval-after-load?
  2018-06-05 19:44 ` Noam Postavsky
@ 2018-06-05 19:51   ` Eric Abrahamsen
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2018-06-05 19:51 UTC (permalink / raw)
  To: emacs-devel

Noam Postavsky <npostavs@gmail.com> writes:

> On 5 June 2018 at 15:37, Eric Abrahamsen <eric@ericabrahamsen.net> wrote:
>
>> (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))))
>
> Missing quote for the inner eval-after-load?

Bah, I was staring right at it, and even had it right in other places in
the same function. Thanks for that.

Eric




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-05 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 19:37 nesting eval-after-load? Eric Abrahamsen
2018-06-05 19:44 ` Noam Postavsky
2018-06-05 19:51   ` Eric Abrahamsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).