-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing requires #194
Add missing requires #194
Conversation
Invoking org-gtd-capture with the following setup results in org-gtd--ensure-file-exists: Symbol’s value as variable is void: org-gtd-archive-location (use-package org-gtd :bind (("M-o M-g M-c" . org-gtd-capture)) :init (setq org-gtd-update-ack "3.0.0") :config (org-gtd-mode 1))
Change with-org-gtd-context to require org-gtd instead of individual modules like org-gtd-archive. This is because: - It's more future-proof, in case more stuff gets added to this macro. - It solves another problem, where use-package's :config section is never executed. For the latter point, consider what happens with (use-package org-gtd :bind (("M-o" . org-gtd-engage)) :init (setq org-gtd-update-ack "3.0.0") :config (org-gtd-mode 1)) With the old code, org-gtd-engage doesn't load org-gtd.el but org-gtd-archive.el et al., so the :config doesn't kick in.
Sorry, last-minute change: it's better to require org-gtd instead of individual modules like org-gtd-archive. See commit log for details. |
That's interesting, I hadn't considered doing it that way, and I was going mad trying to put the right requires in all the right places. Do you have any idea if/how we could write tests or otherwise ensure this works in a CI pipeline or during development, in an automated fashion? |
Yeah, it's a bit tricky, but I think this really is the right place for this
We could do something like the "Steps to Reproduce" I wrote above: start a fresh Emacs instance with minimal config and invoke one of the autoloaded functions, restart Emacs and repeat. Perhaps write a I've never worked with Eldev, buttercup, or GitHub CI before, but if you can give me some quick pointers (how/when tests are triggered in your Eldev workflow or the CI framework; how it finds test files; and where I could put files meant only for the subprocess-Emacs) maybe I can put something together. Be warned I'm a bit busy over the next week or so, though. |
Add tests to check if key autoloaded functions can be called without triggering errors in a fresh Emacs session.
So... it took a while to find the time to iron out the details, but this PR now includes automated testing for the autoload functionality. What do you think? I skipped tests for several commands that need some setup (and I'm not knowledgeable enough to set them up myself), I hope that's fine:
|
Oh wow, thank you! I was preparing to spend most of tomorrow reviewing this, but this new PR is fantastic. And it's fine that you're leaving out tests for these commands; only Thank you again for this, it's going to help a lot of people! |
This PR fixes the problem where you get
Symbol’s value as variable is void: org-gtd-archive-location
or similar such-and-such-is-undefined errors if you don't do an explicit(require 'org-gtd)
, making autoloads useless.Steps to reproduce
Short version: do
M-x org-gtd-engage
when org-gtd is installed and activated but not loaded.Long version: assuming Emacs 29.1, make a fresh directory containing an
init.el
file with the following contents and nothing else.emacs --init-directory=<that directory>
, wait for it to download and install org-gtd.M-x org-gtd-engage
.Result:
org-gtd-engage: Symbol’s value as variable is void: org-gtd-archive-location
Cause
package-activate-all
at startup, which loadsorg-gtd-autoloads.el
, which setsorg-gtd-engage
to be loaded fromorg-gtd-agenda.el
.org-gtd-engage
useswith-org-gtd-context
, butorg-gtd-agenda.el
doesn't load all the packages this macro requires, in particularorg-gtd-archive.el
.Similar problems abound for other autoloaded functions. The root of the problem is that
with-org-gtd-context
tightly couplesorg-gtd-agenda.el
,org-gtd-projects.el
,org-gtd-delegate
, andorg-gtd-core.el
, but these modules are not (cannot be) set up to require each other for fear of recursiverequire
.Fix
I fixed it by adding
require
fororg-gtd-agenda
et al. from the code generated bywith-org-gtd-context
.I also added a missing
(require 'f)
inorg-gtd-core.el
while I was at it. You can tickle this bug by removingorg-gtd-core.elc
before doingorg-gtd-engage
, which complains that-flatten
is undefined.