[email protected] writes:

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

I added ;;;###autoload cookie in front of `org-contacts-capf-completing`. The 
problem should be fixed now.

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

The `org-contacts-anniversaries` function also has ;;;###autoload
cookie. I don't understand why it's missing. Can your show the backtrace?


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

Hook on org-mode-hook is necessary to auto setup contacts completing.

;;;###autoload
(when (bound-and-true-p org-contacts-capf-completing)
  (add-hook 'org-mode-hook #'org-contacts-completion-setup))

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

I don't know `:set` for `defcustom`. If you want to patch it. That's welcome.

-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Attachment: signature.asc
Description: PGP signature

Reply via email to