Hi,

since commit bc21e33 (“add new custom option `org-contacts-capf-completing`”), 
activating org-contacts with straight.el fails with:

  Debugger entered--Lisp error: (void-variable org-contacts-capf-completing)
    (when org-contacts-capf-completing (add-hook 'org-mode-hook 
#'org-contacts-completion-setup))
    eval(...)
    straight--activate-package-autoloads(...)
    straight-use-package(org-contacts)

The cause is the ;;;###autoload cookie in front of the top-level form

  (when org-contacts-capf-completing
    (add-hook 'org-mode-hook #'org-contacts-completion-setup))

The cookie copies the whole form into org-contacts-autoloads.el.  Package 
managers (straight.el, package.el) evaluate that file on activation, i.e. 
before org-contacts.el and the defcustom of org-contacts-capf-completing are 
loaded.  With package.el, the error is demoted to a message in *Messages*, but 
loading of the autoloads file stops at this point, so autoloads defined after 
this form (e.g. org-contacts-anniversaries) are missing.  The bug is still 
present on current main (a9a29e6).

To reproduce with emacs -Q (GNU Emacs 32.0.50): generate the autoloads for 
org-contacts.el with loaddefs-generate and load the resulting file.  This 
signals the same void-variable error.

A possible fix is to remove the ;;;###autoload cookie from the (when ...) form, 
so that it is evaluated only when org-contacts.el itself is loaded.  In my 
test, the regenerated autoloads file then loaded without error, and setting 
org-contacts-capf-completing to t before loading org-contacts still added the 
completion function in Org buffers.

One further remark: the option only takes effect if it is set before 
org-contacts is loaded; changing it later (e.g. via Customize) has no effect 
until restart.  A :set function on the defcustom that adds or removes the hook 
would address this.

Best,

  Titus


Reply via email to