mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
startup.el (command-line): For names of preloaded files, don't append
".elc" (now done in Fload), and call file-truename on the lisp directory. subr.el (eval-after-load): Fix the doc-string. Allow FILE to match ANY loaded file with the right name, not just those in load-path. Put a regexp matching the file name into after-load-alist, rather than the name itself. subr.el: New functions load-history-regexp, load-history-filename-element, do-after-load-evaluation. international/mule.el (load-with-code-conversion): Do the eval-after-load stuff by calling do-after-load-evaluation.
This commit is contained in:
parent
a386b0959d
commit
33d74677e7
3 changed files with 92 additions and 31 deletions
|
|
@ -98,9 +98,9 @@ Return t if file exists."
|
||||||
))
|
))
|
||||||
(let (kill-buffer-hook kill-buffer-query-functions)
|
(let (kill-buffer-hook kill-buffer-query-functions)
|
||||||
(kill-buffer buffer)))
|
(kill-buffer buffer)))
|
||||||
(let ((hook (assoc file after-load-alist)))
|
(unless purify-flag
|
||||||
(when hook
|
(do-after-load-evaluation fullname))
|
||||||
(mapcar (function eval) (cdr hook))))
|
|
||||||
(unless (or nomessage noninteractive)
|
(unless (or nomessage noninteractive)
|
||||||
(if source
|
(if source
|
||||||
(message "Loading %s (source)...done" file)
|
(message "Loading %s (source)...done" file)
|
||||||
|
|
|
||||||
|
|
@ -644,18 +644,17 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
|
||||||
|
|
||||||
;; Convert preloaded file names to absolute.
|
;; Convert preloaded file names to absolute.
|
||||||
(let ((lisp-dir
|
(let ((lisp-dir
|
||||||
(file-name-directory
|
(file-truename
|
||||||
(locate-file "simple" load-path
|
(file-name-directory
|
||||||
(get-load-suffixes)))))
|
(locate-file "simple" load-path
|
||||||
|
(get-load-suffixes))))))
|
||||||
|
|
||||||
(setq load-history
|
(setq load-history
|
||||||
(mapcar (lambda (elt)
|
(mapcar (lambda (elt)
|
||||||
(if (and (stringp (car elt))
|
(if (and (stringp (car elt))
|
||||||
(not (file-name-absolute-p (car elt))))
|
(not (file-name-absolute-p (car elt))))
|
||||||
(cons (concat lisp-dir
|
(cons (concat lisp-dir
|
||||||
(car elt)
|
(car elt))
|
||||||
(if (string-match "[.]el$" (car elt))
|
|
||||||
"" ".elc"))
|
|
||||||
(cdr elt))
|
(cdr elt))
|
||||||
elt))
|
elt))
|
||||||
load-history)))
|
load-history)))
|
||||||
|
|
|
||||||
106
lisp/subr.el
106
lisp/subr.el
|
|
@ -1393,32 +1393,94 @@ That function's doc string says which file created it."
|
||||||
t))
|
t))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
(defun load-history-regexp (file)
|
||||||
|
"Form a regexp to find FILE in load-history.
|
||||||
|
FILE, a string, is described in eval-after-load's doc-string."
|
||||||
|
(if (file-name-absolute-p file)
|
||||||
|
(setq file (file-truename file)))
|
||||||
|
(concat (if (file-name-absolute-p file) "\\`" "\\<")
|
||||||
|
(regexp-quote file)
|
||||||
|
(if (file-name-extension file)
|
||||||
|
""
|
||||||
|
;; Note: regexp-opt can't be used here, since we need to call
|
||||||
|
;; this before Emacs has been fully started. 2006-05-21
|
||||||
|
(concat "\\(" (mapconcat 'regexp-quote load-suffixes "\\|") "\\)?"))
|
||||||
|
"\\(" (mapconcat 'regexp-quote jka-compr-load-suffixes "\\|")
|
||||||
|
"\\)?\\'"))
|
||||||
|
|
||||||
|
(defun load-history-filename-element (file-regexp)
|
||||||
|
"Get the first elt of load-history whose car matches FILE-REGEXP.
|
||||||
|
Return nil if there isn't one."
|
||||||
|
(let* ((loads load-history)
|
||||||
|
(load-elt (and loads (car loads))))
|
||||||
|
(save-match-data
|
||||||
|
(while (and loads
|
||||||
|
(or (null (car load-elt))
|
||||||
|
(not (string-match file-regexp (car load-elt)))))
|
||||||
|
(setq loads (cdr loads)
|
||||||
|
load-elt (and loads (car loads)))))
|
||||||
|
load-elt))
|
||||||
|
|
||||||
(defun eval-after-load (file form)
|
(defun eval-after-load (file form)
|
||||||
"Arrange that, if FILE is ever loaded, FORM will be run at that time.
|
"Arrange that, if FILE is ever loaded, FORM will be run at that time.
|
||||||
This makes or adds to an entry on `after-load-alist'.
|
|
||||||
If FILE is already loaded, evaluate FORM right now.
|
If FILE is already loaded, evaluate FORM right now.
|
||||||
It does nothing if FORM is already on the list for FILE.
|
|
||||||
FILE must match exactly. Normally FILE is the name of a library,
|
If a matching file is loaded again, FORM will be evaluated again.
|
||||||
with no directory or extension specified, since that is how `load'
|
|
||||||
is normally called.
|
If FILE is a string, it may be either an absolute or a relative file
|
||||||
FILE can also be a feature (i.e. a symbol), in which case FORM is
|
name, and may have an extension \(e.g. \".el\") or may lack one, and
|
||||||
evaluated whenever that feature is `provide'd."
|
additionally may or may not have an extension denoting a compressed
|
||||||
(let ((elt (assoc file after-load-alist)))
|
format \(e.g. \".gz\").
|
||||||
;; Make sure there is an element for FILE.
|
|
||||||
(unless elt (setq elt (list file)) (push elt after-load-alist))
|
When FILE is absolute, it is first converted to a true name by chasing
|
||||||
;; Add FORM to the element if it isn't there.
|
out symbolic links. Only a file of this name \(see next paragraph for
|
||||||
|
extensions) will trigger the evaluation of FORM. When FILE is relative,
|
||||||
|
a file whose absolute true name ends in FILE will trigger evaluation.
|
||||||
|
|
||||||
|
When FILE lacks an extension, a file name with any extension will trigger
|
||||||
|
evaluation. Otherwise, its extension must match FILE's. A further
|
||||||
|
extension for a compressed format \(e.g. \".gz\") on FILE will not affect
|
||||||
|
this name matching.
|
||||||
|
|
||||||
|
Alternatively, FILE can be a feature (i.e. a symbol), in which case FORM
|
||||||
|
is evaluated whenever that feature is `provide'd.
|
||||||
|
|
||||||
|
Usually FILE is just a library name like \"font-lock\" or a feature name
|
||||||
|
like 'font-lock.
|
||||||
|
|
||||||
|
This function makes or adds to an entry on `after-load-alist'."
|
||||||
|
;; Add this FORM into after-load-alist (regardless of whether we'll be
|
||||||
|
;; evaluating it now).
|
||||||
|
(let* ((regexp-or-feature
|
||||||
|
(if (stringp file) (load-history-regexp file) file))
|
||||||
|
(elt (assoc regexp-or-feature after-load-alist)))
|
||||||
|
(unless elt
|
||||||
|
(setq elt (list regexp-or-feature))
|
||||||
|
(push elt after-load-alist))
|
||||||
|
;; Add FORM to the element unless it's already there.
|
||||||
(unless (member form (cdr elt))
|
(unless (member form (cdr elt))
|
||||||
(nconc elt (list form))
|
(nconc elt (list form)))
|
||||||
;; If the file has been loaded already, run FORM right away.
|
|
||||||
(if (if (symbolp file)
|
;; Is there an already loaded file whose name (or `provide' name)
|
||||||
(featurep file)
|
;; matches FILE?
|
||||||
;; Make sure `load-history' contains the files dumped with
|
(if (if (stringp file)
|
||||||
;; Emacs for the case that FILE is one of them.
|
(load-history-filename-element regexp-or-feature)
|
||||||
;; (load-symbol-file-load-history)
|
(featurep file))
|
||||||
(when (locate-library file)
|
(eval form))))
|
||||||
(assoc (locate-library file) load-history)))
|
|
||||||
(eval form))))
|
(defun do-after-load-evaluation (abs-file)
|
||||||
form)
|
"Evaluate all `eval-after-load' forms, if any, for ABS-FILE.
|
||||||
|
ABS-FILE, a string, should be the absolute true name of a file just loaded."
|
||||||
|
(let ((after-load-elts after-load-alist)
|
||||||
|
a-l-element file-elements file-element form)
|
||||||
|
(while after-load-elts
|
||||||
|
(setq a-l-element (car after-load-elts)
|
||||||
|
after-load-elts (cdr after-load-elts))
|
||||||
|
(when (and (stringp (car a-l-element))
|
||||||
|
(string-match (car a-l-element) abs-file))
|
||||||
|
(while (setq a-l-element (cdr a-l-element)) ; discard the file name
|
||||||
|
(setq form (car a-l-element))
|
||||||
|
(eval form))))))
|
||||||
|
|
||||||
(defun eval-next-after-load (file)
|
(defun eval-next-after-load (file)
|
||||||
"Read the following input sexp, and run it whenever FILE is loaded.
|
"Read the following input sexp, and run it whenever FILE is loaded.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue