Skip to content
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

Autoloading transient-define-prefix form fails #280

Open
alphapapa opened this issue Mar 25, 2024 · 3 comments
Open

Autoloading transient-define-prefix form fails #280

alphapapa opened this issue Mar 25, 2024 · 3 comments
Labels
support User needs some help

Comments

@alphapapa
Copy link

Hi Jonas,

This seems to be the issue described in #254.

Please see this code in my listen package:

https://github.com/alphapapa/listen.el/blob/5abe25ff1678ffa694f7b062ca748ac143af47a1/listen.el#L331-L344

I explicitly (require 'transient), and I do:

;;;###autoload
(transient-define-prefix listen-menu () ...

But when I start Emacs, I get this error:

Error loading autoloads: (void-function transient-prefix)

Frustratingly, that error doesn't point to the source of the error. But I've narrowed it down to the autoloads for listen, as (featurep 'listen-autoloads) returns nil, and the functions autoloaded in listen-autoloads.el after this line are not defined:

(put 'listen-menu 'transient--prefix (transient-prefix :command 'listen-menu :info-manual "(listen)" :refresh-suffixes t))

If I manually M-x load-library RET listen-autoloads RET, then the rest of the file gets loaded and the functions are defined.

I don't understand how I could be the first (or even second) to encounter this problem, and I don't know how to fix it. By preventing my package's autoloads from loading completely, it's breaking some important functionality in the package.

I'd appreciate any help. Thanks.

@tarsius
Copy link
Member

tarsius commented Mar 26, 2024

;;;###autoload
(transient-define-prefix listen-menu () ...

Unfortunately that doesn't just work for arbitrary "defun" macros. Emacs has to be taught about each one individually, and that has to be done by editing Emacs. ☹️

For these macros I did it a month ago in emacsmirror/emacs@167d9b9. In other words, until your package stops supporting Emacs versions that are currently released, you have to use this instead:

;;;###autoload (autoload 'listen-menu "listen" nil t)
(transient-define-prefix listen-menu () ...

Unfortunately that isn't just more verbose, it also means that the autoload will lack the docstring.

Also see https://lists.gnu.org/archive/html/emacs-devel/2024-03/msg00015.html.

alphapapa added a commit to alphapapa/listen.el that referenced this issue Mar 28, 2024
See <magit/transient#280>.

Suggested-by: Jonas Bernoulli <jonas@bernoul.li>
@alphapapa
Copy link
Author

Thanks. I released that fix in v0.9 of Listen.

For my sake, this issue can be closed, but would it be worth mentioning in some "known issues" list?

@tarsius tarsius added the support User needs some help label Mar 28, 2024
@tarsius
Copy link
Member

tarsius commented Mar 28, 2024

I'll leave it open until I get around to documenting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User needs some help
Development

No branches or pull requests

2 participants