Copying autoloads (was: Adding 'compat' from ELPA as an optional dependency to ERC)

Stefan Monnier <[email protected]>
Newsgroups gmane.emacs.erc.general,gmane.emacs.devel
Message-ID <[email protected]>
Philip Kaludercic [2022-07-25 18:56:39] wrote:
>         (defun get-compatibility-func (name)
>           "Return the function NAME of a compatibility alias."
>           (let* ((compat (intern-soft (format "compat-%s" name))))
>             (or (symbol-function (if (fboundp name) name compat))
>                 (error "No definition for %S could be found" name))))

Side note: if `name` is autoloaded this will not return a "valid" value,
in the sense that the (autoload ...) value stored in `symbol-function`
is only usable when placed inside `name` and not elsewhere (e.g. you
can't `funcall` it, and if you store it in another symbol, calling the
function under that other symbol will probably fail).

Autoloads are somewhat hackish in this sense.


        Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.