-
Notifications
You must be signed in to change notification settings - Fork 30
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
Problem with generated autoloads #13
Comments
Hi, thank you very much for reporting this. I recently converted most of the commands to be defined with macros, and I don't have a firm grasp of how autoloading works, especially when macros are involved. Looking at the elisp info pages, I found this:
IIUC, that means that cookies like that should be before each of the I'm also not sure about the cookies on the macros themselves. The info page says:
That seems to imply that the cookies should be on the macro definitions, but again I'm not sure. I'll take a look at some bigger packages and see how they do it, see if I can figure out the proper way. Please let me know if you find out anything more also. By the way, for future reference, how did you discover this problem? I would like to be able to reproduce it on my end. :) Thanks! |
Googling for this was surprisingly difficult. I think the closest I've come to finding a plain answer is this: http://stackoverflow.com/questions/38779350/create-autoloaded-function-from-macro What's really confusing about that, though, is this answer from who appears to be Stefan Monnier:
That answer was posted on 6 Aug 2016. It just seems very strange to me that someone like him would be recognizing this as a bug in Emacs...in 2016! Isn't defining functions with macros a fairly common thing to do? This doesn't make sense to me, so I feel like I'm missing something obvious. I know I've seen other packages do it, but I can't seem to find a good example at the moment. (I feel like such a noob right now.) |
First of all, thanks for the quick and extensive reply.
That's pretty much how I understand it, too.
I think it just says that cookies are possible on macro definitions if you want to autoload the macro itself. It does not apply to functions defined by invocations of the macro.
I also find this confusing, as it seems to contradict what the manual says. I looked into the implementation to see if I could figure it out. The main function is
I'm not sure how |
And to you. :)
This is confusing to me, because what about byte-compiled packages? I guess this means that, for byte-compiled packages, it's not necessary to put the cookie on the macro definition, because it will be expanded when the package is byte-compiled. ... I guess it also means that, at least for a macro like this that isn't intended to be used outside this package, the macro doesn't need a cookie at all, regardless of byte-compiling.
Wow, thanks for digging into that. Maybe he was right when he said that a bug report should be filed. But what I can hardly fathom is that, after all these years, we would be nearly the first to notice and report this as a bug--so I still feel like I'm just misunderstanding something.
Yeah, Borg looks really interesting! I think I would give it a try if it weren't for its using git submodules. I just haven't wrapped my head around them, and I'm not quite comfortable with them. As it is I keep my Anyway, could this be a bug in Borg? It seems like it ought to do things basically the same way that Hmm...are you brave enough to bring this up on emacs-devel? ;) |
I think so, too, either it is expanded at compile time, or defined when loading the file from source. In any case, autoloads are not necessary for internal macros.
Hmm, it basically does things the same way as
Not sure, maybe we could as in /r/emacs first, there are a lot of knowledgeable people there, and the barrier is a bit lower for something that might just be a misunderstanding. |
Excellent idea, and I just saw that you posted it, so thanks for that. :) BTW, do you have any Emacs packages? You seem quite knowledgeable! |
Yeah, but not very successful as of yet :-/ No, I don't have any packages. I like poking around, but I'm generally to lazy for larger stuff :) |
Hmm, let me try something... @tarsius Sorry to bug you, but I wonder if you could teach us the way of the autoload... :) |
It hardly ever makes sense to autoload a macro, less so for a "definer" macro. You don't have to do so just to make those commands/funtions/variables autoloadable that were defined using it. Just autoload those definitions using something like If some other file The macro doesn't have to be autoloaded for this to work. If |
Thanks a lot for explaining that! I'll be fairly busy for the next few weeks, but I'll dig into this again soon. |
Additionally delete autoloads for the definitions of the macros. Fixes alphapapa#13
Also delete autoloads for the macro definitions. This prevents helm-org-rifle from causing org to load unnecessarily. Fixes #13. Closes #20. Thanks to Anders Johansson (@andersjohansson) and Chris Ruegge (@cruegge).
The
autoloads.el
generated for this package appears to be a bit problematic: it first defines an autoload for thehelm-org-rifle-define-command
macro and then directly uses that macro to define the various commands inline. Depending on the order in which the autoloads file is loaded and theload-path
is set up, that either directly pulls in the package and its dependencies, or fails to define the commands, both of which are missing the point of an autoload file.There does not seem to be a way of telling the the autoload cookie mechanism about new command-defining top-level forms -- it just special-cases some forms like
defun
and copies the rest verbatim. So the only way I see around this problem would be to add explicit autoloads, i.e. instead ofone should probably write
and remove the autoload on the macro altogether.
I can prepare a PR for this if you agree.
The text was updated successfully, but these errors were encountered: