Function: custom-initialize-after-file-load

custom-initialize-after-file-load is a byte-compiled function defined in custom.el.gz.

Signature

(custom-initialize-after-file-load SYMBOL VALUE)

Documentation

Delay initialization to after the current file is loaded.

This is handy when the initialization needs functions defined after the variable, such as for global minor modes.

Probably introduced at or before Emacs version 31.1.

Source Code

;; Defined in /usr/src/emacs/lisp/custom.el.gz
(defun custom-initialize-after-file-load (symbol value)
  "Delay initialization to after the current file is loaded.
This is handy when the initialization needs functions defined after the
variable, such as for global minor modes."
  ;; Defvar it so as to mark it special, etc (bug#25770).
  (internal--define-uninitialized-variable symbol)

  ;; Until the var is actually initialized, it is kept unbound.
  ;; This seemed to be at least as good as setting it to an arbitrary
  ;; value like nil (evaluating `value' is not an option because it
  ;; may have undesirable side-effects).
  (if (not load-file-name)
      ;; There's no "after file" to speak of.
      (custom-initialize-set symbol value)
    (let ((thisfile load-file-name))
      (letrec ((f (lambda (file)
                    (when (equal file thisfile)
                      (remove-hook 'after-load-functions f)
                      (custom-initialize-set symbol value)))))
        (add-hook 'after-load-functions f)))))