1

I'm trying to use cl-lib early in my init.el. The function I'm using (cl-some) is autoloaded, so I expect that don't need an explicit require, yet I get a void-function error if I don't explicitly require. Sounds like other people have this problem as well: https://stackoverflow.com/a/30848971/245173

;; OK
(require 'cl-lib)
(cl-some #'identity '(nil))

;; void-function the first time, OK subsequently
(cl-some #'identity '(nil))

Why is require necessary if the function is marked for autoloading? Why does it generate an error and also load the library?

Update: if I (load-library "cl-loaddefs.el"), which is where the autoload for cl-some is, it works correctly the first time. So it seems like cl-loaddefs isn't being loaded. Why not?

2 Answers 2

3

It's an internal autoload of the cl-lib package, not a global autoload. cl- has no global autoloads. To use cl- functions, require cl-lib. To use cl- macros, eval-when-compile require cl-lib.

1
  • Fair enough. It still seems super weird. For example, cl-evenp is in cl-lib, is not marked for autoloading (at least with a ;;;###autoload comment), and depends only on builtins. It behaves the same way as cl-some: fails with void-function on the first invocation, gets autoloaded anyway, and works on subsequent invocations.
    – jpkotta
    May 4, 2017 at 20:34
1

As ocoh2 points out, cl-lib is not autoloaded, the only way to get it is to require it or have it indirectly autoloaded (some autoloaded package requires it).

It must be the Debugger that loads cl-lib. With emacs -Q --eval '(cl-evenp 2)', there is an error but no debugger and cl-lib is not loaded. cl-lib only gets loaded after the Debugger pops up once Emacs is running interactively. I still don't understand why cl-lib is not autoloaded (though I'm not very surprised given the avoidance of cl-lib in a lot of Emacs), but at least everything is consistent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.