mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
(loaddefs-generate--emacs-batch): Chdir to lisp-directory
Chdir once and for all at the beginning to simplify the code. Eliminate some redundant `expand-file-name`s and fix a broken use of `expand-file-name` where we passed a list as second arg. * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Rename DIR to DIRS, to clarify that it can be a list. Use `ensure-list`. Don't pass DIR(S) directly to `expand-file-name`. Remove redundant `expand-file-name`. (loaddefs-generate--excluded-files): Add sanity checks. Return relative file names since `loaddefs-generate` will make them absolute anyway. Simplify. (loaddefs-generate--emacs-batch): Chdir to `lisp-directory` and simplify the rest accordingly.
This commit is contained in:
parent
02253b35af
commit
34ab8abdd2
1 changed files with 34 additions and 23 deletions
|
|
@ -593,7 +593,7 @@ If COMPILE, don't include a \"don't compile\" cookie."
|
|||
(buffer-string))))
|
||||
|
||||
;;;###autoload
|
||||
(defun loaddefs-generate (dir output-file &optional excluded-files
|
||||
(defun loaddefs-generate (dirs output-file &optional excluded-files
|
||||
extra-data include-package-version
|
||||
generate-full)
|
||||
"Generate loaddefs files for Lisp files in one or more directories given by DIR.
|
||||
|
|
@ -632,13 +632,18 @@ instead of just updating them with the new/changed autoloads."
|
|||
(mapcar (lambda (d)
|
||||
(directory-files (expand-file-name d)
|
||||
t files-re))
|
||||
(if (consp dir) dir (list dir)))))
|
||||
(ensure-list dirs))))
|
||||
(updating (and (file-exists-p output-file) (not generate-full)))
|
||||
(defs nil))
|
||||
;; Allow the excluded files to be relative.
|
||||
(setq excluded-files
|
||||
(mapcar (lambda (file) (expand-file-name file dir))
|
||||
excluded-files))
|
||||
;; We used to do (expand-file-name file dir), which strangely enough
|
||||
;; doesn't signal an error when DIR is a list but does something weird
|
||||
;; instead, so let's preserve the old behavior when DIR is a string,
|
||||
;; even tho it's different from what we do when it's a list.
|
||||
(let ((basedir (if (stringp dirs) dirs)))
|
||||
(setq excluded-files
|
||||
(mapcar (lambda (file) (expand-file-name file basedir))
|
||||
excluded-files)))
|
||||
|
||||
;; Collect all the autoload data.
|
||||
(let ((progress (make-progress-reporter
|
||||
|
|
@ -657,7 +662,7 @@ instead of just updating them with the new/changed autoloads."
|
|||
(file-attributes file))))
|
||||
;; If we're scanning for package versions, we want to look
|
||||
;; at the file even if it's excluded.
|
||||
(let* ((excluded (member (expand-file-name file dir) excluded-files))
|
||||
(let* ((excluded (member file excluded-files))
|
||||
(package-data
|
||||
(and include-package-version (if excluded 'only t))))
|
||||
(when (or package-data (not excluded))
|
||||
|
|
@ -724,7 +729,7 @@ instead of just updating them with the new/changed autoloads."
|
|||
(unless (equal (buffer-hash) hash)
|
||||
(write-region (point-min) (point-max) loaddefs-file nil 'silent)
|
||||
(byte-compile-info
|
||||
(file-relative-name loaddefs-file (car (ensure-list dir)))
|
||||
(file-relative-name loaddefs-file (car (ensure-list dirs)))
|
||||
t "GEN")))))
|
||||
|
||||
;; If processing files without any autoloads, the above loop will
|
||||
|
|
@ -776,19 +781,21 @@ instead of just updating them with the new/changed autoloads."
|
|||
;; Exclude those files that are preloaded on ALL platforms.
|
||||
;; These are the ones in loadup.el where "(load" is at the start
|
||||
;; of the line (crude, but it works).
|
||||
(let ((default-directory (file-name-directory lisp-directory))
|
||||
(excludes nil)
|
||||
file)
|
||||
(unless (equal default-directory (file-name-as-directory lisp-directory))
|
||||
(error "PWD is not set as expected: %S" default-directory))
|
||||
(let ((excludes nil))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents "loadup.el")
|
||||
(when (= (point-min) (point-max)) (error "Can't find loadup.el"))
|
||||
(while (re-search-forward "^(load \"\\([^\"]+\\)\"" nil t)
|
||||
(setq file (match-string 1))
|
||||
(or (string-match "\\.el\\'" file)
|
||||
(setq file (format "%s.el" file)))
|
||||
(or (string-match "\\`site-" file)
|
||||
(push (expand-file-name file) excludes))))
|
||||
(let ((file (match-string 1)))
|
||||
(unless (string-match "\\`site-" file)
|
||||
(push (if (string-match "\\.el\\'" file)
|
||||
file
|
||||
(format "%s.el" file))
|
||||
excludes)))))
|
||||
;; Don't scan ldefs-boot.el, either.
|
||||
(cons (expand-file-name "ldefs-boot.el") excludes)))
|
||||
(cons "ldefs-boot.el" excludes)))
|
||||
|
||||
;;;###autoload
|
||||
(defun loaddefs-generate-batch ()
|
||||
|
|
@ -806,8 +813,12 @@ use."
|
|||
"Generate the loaddefs for the Emacs build.
|
||||
This is like `loaddefs-generate-batch', but has some specific
|
||||
rules for built-in packages and excluded files."
|
||||
(let ((args command-line-args-left)
|
||||
(output-file (expand-file-name "loaddefs.el" lisp-directory)))
|
||||
(let* ((args command-line-args-left)
|
||||
;; We're run from $BUILDDIR/lisp but all the .el(c) files reside
|
||||
;; (and are generated) in `lisp-directory' which is in $SRCDIR,
|
||||
;; so go there and don't look back.
|
||||
(default-directory lisp-directory)
|
||||
(output-file (expand-file-name "loaddefs.el")))
|
||||
(setq command-line-args-left nil)
|
||||
(loaddefs-generate
|
||||
args output-file
|
||||
|
|
@ -817,12 +828,12 @@ rules for built-in packages and excluded files."
|
|||
;; updated.
|
||||
(file-newer-than-file-p
|
||||
(expand-file-name "emacs-lisp/loaddefs-gen.el" lisp-directory)
|
||||
output-file)))
|
||||
(let ((lisp-mode-autoload-regexp
|
||||
"^;;;###\\(\\(noexist\\)-\\)?\\(theme-autoload\\)"))
|
||||
output-file))
|
||||
(let ((lisp-mode-autoload-regexp
|
||||
"^;;;###\\(\\(noexist\\)-\\)?\\(theme-autoload\\)"))
|
||||
(loaddefs-generate
|
||||
(expand-file-name "../etc/themes/" lisp-directory)
|
||||
(expand-file-name "theme-loaddefs.el" lisp-directory))))
|
||||
(expand-file-name "../etc/themes/")
|
||||
(expand-file-name "theme-loaddefs.el")))))
|
||||
|
||||
;;;###autoload (load "theme-loaddefs.el" t)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue