diff options
| author | Richard M. Stallman | 1997-05-06 21:14:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-05-06 21:14:20 +0000 |
| commit | c9aadf03220ebb6b24e74d37e16bd33ab9b98b7c (patch) | |
| tree | 35e1da7a602d1a8b087392430b3ac6324317dee3 | |
| parent | 94636ed5e85d0a884c75afdc14ba6bb3431a28b0 (diff) | |
| download | emacs-c9aadf03220ebb6b24e74d37e16bd33ab9b98b7c.tar.gz emacs-c9aadf03220ebb6b24e74d37e16bd33ab9b98b7c.zip | |
(custom-make-dependencies):
Don't use NOSORT in directory-files.
Don't actually visit the files.
Use re-search to search contents fast.
Search the subdirs of `lisp'.
Bind kept-new-versions when saving.
| -rw-r--r-- | lisp/cus-dep.el | 81 |
1 files changed, 59 insertions, 22 deletions
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el index 67d19055b78..a733da89d79 100644 --- a/lisp/cus-dep.el +++ b/lisp/cus-dep.el | |||
| @@ -25,33 +25,69 @@ | |||
| 25 | ;;; Code: | 25 | ;;; Code: |
| 26 | 26 | ||
| 27 | (require 'cl) | 27 | (require 'cl) |
| 28 | (load-file "widget.el") | 28 | (require 'widget) |
| 29 | (load-file "custom.el") | 29 | (require 'cus-face) |
| 30 | (load-file "cus-face.el") | ||
| 31 | 30 | ||
| 32 | (defun custom-make-dependencies () | 31 | (defun custom-make-dependencies () |
| 33 | "Batch function to extract custom dependencies from .el files. | 32 | "Batch function to extract custom dependencies from .el files. |
| 34 | Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies" | 33 | Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies" |
| 35 | (let ((enable-local-eval nil) | 34 | (let ((enable-local-eval nil) |
| 36 | (files (directory-files "" nil "\\`[^=].*\\.el\\'" t)) | 35 | all-subdirs pending |
| 37 | file) | 36 | (start-directory default-directory)) |
| 38 | (while files | 37 | (get-buffer-create " cus-dep temp") |
| 39 | (setq file (car files) | 38 | (set-buffer " cus-dep temp") |
| 40 | files (cdr files)) | 39 | (setq pending '(".")) |
| 41 | (message "Checking %s..." file) | 40 | (while pending |
| 42 | (set-buffer (find-file-noselect file)) | 41 | (let ((this (car pending)) |
| 43 | (goto-char (point-min)) | 42 | this-subdirs |
| 44 | (string-match "\\`\\(.*\\)\\.el\\'" file) | 43 | default-directory) |
| 45 | (condition-case nil | 44 | (setq all-subdirs (cons this all-subdirs)) |
| 45 | (setq pending (cdr pending)) | ||
| 46 | (setq default-directory | ||
| 47 | (expand-file-name this start-directory)) | ||
| 48 | (message "Finding subdirs of %s" this) | ||
| 49 | (erase-buffer) | ||
| 50 | (condition-case nil | ||
| 51 | (progn | ||
| 52 | (insert-file-contents "subdirs.el") | ||
| 53 | (goto-char (point-min)) | ||
| 54 | (search-forward "'(") | ||
| 55 | (forward-char -1) | ||
| 56 | (setq this-subdirs (read (current-buffer))) | ||
| 57 | (setq pending (nconc pending | ||
| 58 | (mapcar | ||
| 59 | (function (lambda (dir) | ||
| 60 | (file-relative-name | ||
| 61 | (file-name-as-directory | ||
| 62 | (expand-file-name dir this)) | ||
| 63 | start-directory))) | ||
| 64 | this-subdirs)))) | ||
| 65 | (error nil)))) | ||
| 66 | |||
| 67 | (while all-subdirs | ||
| 68 | (message "Directory %s" (car all-subdirs)) | ||
| 69 | (let ((files (directory-files (car all-subdirs) nil "\\`[^=].*\\.el\\'")) | ||
| 70 | (default-directory default-directory) | ||
| 71 | file) | ||
| 72 | (cd (car all-subdirs)) | ||
| 73 | (while files | ||
| 74 | (setq file (car files) | ||
| 75 | files (cdr files)) | ||
| 76 | (message "Checking %s..." file) | ||
| 77 | (erase-buffer) | ||
| 78 | (insert-file-contents file) | ||
| 79 | (goto-char (point-min)) | ||
| 80 | (string-match "\\`\\(.*\\)\\.el\\'" file) | ||
| 46 | (let ((name (file-name-nondirectory (match-string 1 file)))) | 81 | (let ((name (file-name-nondirectory (match-string 1 file)))) |
| 47 | (while t | 82 | (condition-case nil |
| 48 | (let ((expr (read (current-buffer)))) | 83 | (while (re-search-forward "^(defcustom\\|^(defface\\|^(defgroup" |
| 49 | (when (and (listp expr) | 84 | nil t) |
| 50 | (memq (car expr) '(defcustom defface defgroup))) | 85 | (beginning-of-line) |
| 51 | (eval expr) | 86 | (let ((expr (read (current-buffer)))) |
| 52 | (put (nth 1 expr) 'custom-where name))))) | 87 | (eval expr) |
| 53 | (error nil)) | 88 | (put (nth 1 expr) 'custom-where name))) |
| 54 | (kill-buffer (current-buffer)))) | 89 | (error nil)))) |
| 90 | (setq all-subdirs (cdr all-subdirs))))) | ||
| 55 | (message "Generating cus-load.el...") | 91 | (message "Generating cus-load.el...") |
| 56 | (find-file "cus-load.el") | 92 | (find-file "cus-load.el") |
| 57 | (erase-buffer) | 93 | (erase-buffer) |
| @@ -84,7 +120,8 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies" | |||
| 84 | \(provide 'cus-load) | 120 | \(provide 'cus-load) |
| 85 | 121 | ||
| 86 | ;;; cus-load.el ends here\n") | 122 | ;;; cus-load.el ends here\n") |
| 87 | (save-buffer) | 123 | (let ((kept-new-versions 10000000)) |
| 124 | (save-buffer)) | ||
| 88 | (message "Generating cus-load.el...done")) | 125 | (message "Generating cus-load.el...done")) |
| 89 | 126 | ||
| 90 | ;;; cus-dep.el ends here | 127 | ;;; cus-dep.el ends here |