Function: prepare-user-lisp
prepare-user-lisp is an interactive and byte-compiled function defined
in startup.el.gz.
Signature
(prepare-user-lisp &optional JUST-ACTIVATE AUTOLOAD-FILE FORCE)
Documentation
Byte-compile, scrape autoloads and prepare files in user-lisp-directory.
Write the autoload file to AUTOLOAD-FILE. If JUST-ACTIVATE is non-nil, then the more expensive operations (byte-compilation and autoload scraping) are skipped, in effect only processing any previous autoloads. If AUTOLOAD-FILE is nil, store the autoload data in a file next to DIR. If FORCE is non-nil, or if invoked interactively with a prefix argument, re-create the entire autoload file and byte-compile everything unconditionally.
Probably introduced at or before Emacs version 31.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/startup.el.gz
(defun prepare-user-lisp (&optional just-activate autoload-file force)
"Byte-compile, scrape autoloads and prepare files in `user-lisp-directory'.
Write the autoload file to AUTOLOAD-FILE. If JUST-ACTIVATE is non-nil,
then the more expensive operations (byte-compilation and autoload
scraping) are skipped, in effect only processing any previous autoloads.
If AUTOLOAD-FILE is nil, store the autoload data in a file next to DIR.
If FORCE is non-nil, or if invoked interactively with a prefix argument,
re-create the entire autoload file and byte-compile everything
unconditionally."
(interactive (list nil nil current-prefix-arg))
(unless just-activate (require 'bytecomp))
(unless (file-directory-p user-lisp-directory)
(error "No such directory: %S" user-lisp-directory))
(unless autoload-file
(setq autoload-file (expand-file-name ".user-lisp-autoloads.el"
user-lisp-directory)))
(let* ((ignored
(concat "\\`" (regexp-opt user-lisp-ignored-directories) "\\'"))
(pred
(lambda (dir)
(not (string-match-p ignored (file-name-nondirectory dir)))))
(dir (expand-file-name user-lisp-directory))
(backup-inhibited t)
(dirs (list dir)) (files '()) (excluded '()))
(add-to-list 'load-path (directory-file-name dir))
(dolist (file (directory-files-recursively dir "" t pred t))
(let ((attr (file-attribute-type (file-attributes file))))
(cond
;; Dangling symlinks.
((and (stringp attr) (not (file-exists-p file)))
(push file excluded))
;; Directories.
((and (not (string-match-p ignored
(file-name-nondirectory file)))
(or (eq attr t)
(and (stringp attr) (file-directory-p file))))
(add-to-list 'load-path (directory-file-name file))
(push file dirs))
;; Everything else.
((and (or (null attr) (stringp attr))
(string-suffix-p ".el" file))
(push file files)))))
(unless just-activate
(loaddefs-generate dirs autoload-file excluded nil nil force)
(dolist (file files)
(with-demoted-errors "Error while compiling: %S"
(byte-recompile-file file force 0)
(when (native-comp-available-p)
(native-compile-async file)))))
(when (file-exists-p autoload-file)
(load autoload-file nil t))))