Closed meliache closed 2 years ago
@meliache does defalias
need autoload
as well?
I merged the master branch again
@dmitrym0 At first I also wasn't sure if the defalias
needs to be autoloaded, as I'm not an experienced elisp package developer but I just tested it and yes, the autoload comment is needed. This is how I tested it:
(use-package org-hyperscheduler
:defer t
:straight
(:host github :repo "dmitrym0/org-hyperscheduler" :files ("*")))
(Or alternatively use (setq use-package-always-defer t)
at the begin of your init file, but that will affect all packages.)
;;;###autoload
magic comment from the source codeM-x straight-rebuild-package org-hyperscheduler
M-x org-hs-open
. I found that I can only do that when the magic comment is added Out of curiosity, I also checked the autoload defintions that emacs generated. For me with straight they were in
~/.emacs.d/straight/build/org-hyperscheduler/org-hyperscheduler-autoloads.el
That file contained the lines:
;;; Generated autoloads from org-hyperscheduler.el
(autoload 'org-hyperscheduler-open "org-hyperscheduler" "\
Open org-hyperscheduler in the browser." t nil)
(defalias 'org-hs-open #'org-hyperscheduler-open)
So to be precise, emacs doesn't actually call autoload
on the alias, but just forwards the alias definition to the autoload file that has the emacs code that is loaded before the actual package is loaded. That makes sense since an alias is just a lightweight shortform.
I didn't know how autoloads work! Thanks for doing this, I learned a bunch.
The advantage is just making it more obvious that it's just an alias and not doing anything else. E.g. when consulting
M-x describe-variable org-hs-open
, emacs will tell the user that it's an alias.