[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question: loading code when two packages are load?
From: |
Stefan Monnier |
Subject: |
Re: Question: loading code when two packages are load? |
Date: |
Wed, 08 Sep 2021 16:25:15 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> I’ve been working on the integration of crdt.el with a few other packages
> (xscheme.el, comint.el).
> Those code only make sense when both crdt.el and the “client” package are
> loaded.
> Is there a way to lazy load those code?
Some ways to address these kinds of problem:
- Move the relevant code to `crdt-<foo>.el` and then arrange for
`crdt-<foo>.el` to be loaded when need for example using an autoloaded
`crdt-<foo>-setup` function and in `crdt.el` you do
`(add-hook '<foo>-mode-hook 'crdt-<foo>-setup).
- Put the code inside an `with-eval-after-load`.
- Just add enough `defvar`s and `declare-function` to silence the
warnings.
The first solution above is arguably the cleanest, but can be a too
heavy if the code of `crdt-<foo>.el` is trivial.
Stefan