custom-load-symbol
code: custom.el
(defun custom-load-symbol (symbol)
"Load all dependencies for SYMBOL."
(unless custom-load-recursion
(let ((custom-load-recursion t))
;; Load these files if not already done,
;; to make sure we know all the dependencies of SYMBOL.
(ignore-errors
(require 'cus-load))
(ignore-errors
(require 'cus-start))
(dolist (load (get symbol 'custom-loads))
(cond ((symbolp load) (ignore-errors (require load)))
;; This is subsumed by the test below, but it's much faster.
((assoc load load-history))
;; This was just (assoc (locate-library load) load-history)
;; but has been optimized not to load locate-library
;; if not necessary.
((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load)
"\\(\\'\\|\\.\\)"))
(found nil))
(dolist (loaded load-history)
(and (stringp (car loaded))
(string-match-p regexp (car loaded))
(setq found t)))
found))
;; Without this, we would load cus-edit recursively.
;; We are still loading it when we call this,
;; and it is not in load-history yet.
((equal load "cus-edit"))
(t (ignore-errors (load load))))))))