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.

View in manual

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)))
    (add-to-list 'load-path (directory-file-name dir))
    (dolist (file (directory-files-recursively dir "" t pred))
      (cond
       ((and (file-regular-p file) (string-suffix-p ".el" file))
        (unless just-activate
          (with-demoted-errors "Error while compiling: %S"
            (byte-recompile-file file force 0)
            (when (native-comp-available-p)
              (native-compile-async file)))))
       ((and (file-directory-p file)
             (not (string-match-p ignored (file-name-nondirectory file))))
        (add-to-list 'load-path (directory-file-name file))
        (push file dirs))))
    (unless just-activate
      (loaddefs-generate dirs autoload-file nil nil nil force))
    (when (file-exists-p autoload-file)
      (load autoload-file nil t))))