aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-06-05 02:35:36 +0000
committerGlenn Morris2008-06-05 02:35:36 +0000
commit9b3cd5b453aace3f80de3a70e3b659a442d3505a (patch)
tree658c4db3a7fcebbe7df753d3d2c97f5b6035b678
parent228b739631ef5180958cead15216236f239870b9 (diff)
downloademacs-9b3cd5b453aace3f80de3a70e3b659a442d3505a.tar.gz
emacs-9b3cd5b453aace3f80de3a70e3b659a442d3505a.zip
(generated-custom-dependencies-file): Doc fix.
(custom-dependencies-no-scan-regexp): New variable. (custom-make-dependencies): Use with-temp-buffer and autoload-rubric. Don't scan files matching custom-dependencies-no-scan-regexp. Disable undo in the output buffer. Remove kept-new-versions wackiness.
-rw-r--r--lisp/cus-dep.el113
1 files changed, 52 insertions, 61 deletions
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index 4066c50911f..bdae3895a6a 100644
--- a/lisp/cus-dep.el
+++ b/lisp/cus-dep.el
@@ -1,7 +1,7 @@
1;;; cus-dep.el --- find customization dependencies 1;;; cus-dep.el --- find customization dependencies
2;; 2;;
3;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 3;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4;; 2006, 2007, 2008 Free Software Foundation, Inc. 4;; 2008 Free Software Foundation, Inc.
5;; 5;;
6;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 6;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
7;; Keywords: internal 7;; Keywords: internal
@@ -30,59 +30,65 @@
30(require 'cus-face) 30(require 'cus-face)
31 31
32(defvar generated-custom-dependencies-file "cus-load.el" 32(defvar generated-custom-dependencies-file "cus-load.el"
33 "Output file for \\[custom-make-dependencies].") 33 "Output file for `custom-make-dependencies'.")
34
35;; See finder-no-scan-regexp in finder.el.
36(defvar custom-dependencies-no-scan-regexp "\\(^\\.#\\|\\(loaddefs\\|\
37cus-load\\|finder-inf\\|esh-groups\\|subdirs\\)\\.el$\\)"
38 "Regexp matching file names not to scan for `custom-make-dependencies'.")
39
40(autoload 'autoload-rubric "autoload")
34 41
35(defun custom-make-dependencies () 42(defun custom-make-dependencies ()
36 "Batch function to extract custom dependencies from .el files. 43 "Batch function to extract custom dependencies from .el files.
37Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" 44Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
38 (let ((enable-local-eval nil)) 45 (let ((enable-local-eval nil))
39 (set-buffer (get-buffer-create " cus-dep temp")) 46 (with-temp-buffer
40 (dolist (subdir command-line-args-left) 47 (dolist (subdir command-line-args-left)
41 (message "Directory %s" subdir) 48 (message "Directory %s" subdir)
42 (let ((files (directory-files subdir nil "\\`[^=].*\\.el\\'")) 49 (let ((files (directory-files subdir nil "\\`[^=].*\\.el\\'"))
43 (default-directory (expand-file-name subdir)) 50 (default-directory (expand-file-name subdir))
44 (preloaded (concat "\\`" 51 (preloaded (concat "\\`"
45 (regexp-opt (mapcar 52 (regexp-opt (mapcar
46 (lambda (f) 53 (lambda (f)
47 (file-name-sans-extension 54 (file-name-sans-extension
48 (file-name-nondirectory f))) 55 (file-name-nondirectory f)))
49 preloaded-file-list) t) 56 preloaded-file-list) t)
50 "\\.el\\'"))) 57 "\\.el\\'")))
51 (dolist (file files) 58 (dolist (file files)
52 (when (and (file-exists-p file) 59 (unless (or (string-match custom-dependencies-no-scan-regexp file)
53 ;; Ignore files that are preloaded. 60 (string-match preloaded file)
54 (not (string-match preloaded file))) 61 (not (file-exists-p file)))
55 (erase-buffer) 62 (erase-buffer)
56 (insert-file-contents file) 63 (insert-file-contents file)
57 (goto-char (point-min)) 64 (goto-char (point-min))
58 (string-match "\\`\\(.*\\)\\.el\\'" file) 65 (string-match "\\`\\(.*\\)\\.el\\'" file)
59 (let ((name (file-name-nondirectory (match-string 1 file))) 66 (let ((name (file-name-nondirectory (match-string 1 file)))
60 (load-file-name file)) 67 (load-file-name file))
61 (if (save-excursion 68 (if (save-excursion
62 (re-search-forward 69 (re-search-forward
63 (concat "(provide[ \t\n]+\\('\\|(quote[ \t\n]\\)[ \t\n]*" 70 (concat "(provide[ \t\n]+\\('\\|(quote[ \t\n]\\)[ \t\n]*"
64 (regexp-quote name) "[ \t\n)]") 71 (regexp-quote name) "[ \t\n)]")
65 nil t)) 72 nil t))
66 (setq name (intern name))) 73 (setq name (intern name)))
67 (condition-case nil 74 (condition-case nil
68 (while (re-search-forward 75 (while (re-search-forward
69 "^(def\\(custom\\|face\\|group\\)" nil t) 76 "^(def\\(custom\\|face\\|group\\)" nil t)
70 (beginning-of-line) 77 (beginning-of-line)
71 (let ((expr (read (current-buffer)))) 78 (let ((expr (read (current-buffer))))
72 (condition-case nil 79 (condition-case nil
73 (let ((custom-dont-initialize t)) 80 (let ((custom-dont-initialize t))
74 (eval expr) 81 (eval expr)
75 (put (nth 1 expr) 'custom-where name)) 82 (put (nth 1 expr) 'custom-where name))
76 (error nil)))) 83 (error nil))))
77 (error nil)))))))) 84 (error nil)))))))))
78 (message "Generating %s..." generated-custom-dependencies-file) 85 (message "Generating %s..." generated-custom-dependencies-file)
79 (set-buffer (find-file-noselect generated-custom-dependencies-file)) 86 (set-buffer (find-file-noselect generated-custom-dependencies-file))
87 (setq buffer-undo-list t)
80 (erase-buffer) 88 (erase-buffer)
81 (insert ";;; " (file-name-nondirectory generated-custom-dependencies-file) 89 (insert (autoload-rubric generated-custom-dependencies-file
82 " --- automatically extracted custom dependencies 90 "custom dependencies"))
83;;\n;;; Code: 91 (search-backward " ")
84
85")
86 (mapatoms (lambda (symbol) 92 (mapatoms (lambda (symbol)
87 (let ((members (get symbol 'custom-group)) 93 (let ((members (get symbol 'custom-group))
88 where found) 94 where found)
@@ -160,23 +166,8 @@ Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
160 (if version-alist "'" "")) 166 (if version-alist "'" ""))
161 (prin1 version-alist (current-buffer)) 167 (prin1 version-alist (current-buffer))
162 (insert "\n \"For internal use by custom.\")\n")) 168 (insert "\n \"For internal use by custom.\")\n"))
163 169 (save-buffer)
164 (insert "\ 170 (message "Generating %s...done" generated-custom-dependencies-file))
165
166\(provide '" (file-name-sans-extension
167 (file-name-nondirectory generated-custom-dependencies-file)) ")
168
169;; Local Variables:
170;; version-control: never
171;; no-byte-compile: t
172;; no-update-autoloads: t
173;; End:\n;;; "
174 (file-name-nondirectory generated-custom-dependencies-file)
175 " ends here\n")
176 (let ((kept-new-versions 10000000))
177 (save-buffer))
178 (message "Generating %s...done" generated-custom-dependencies-file)
179 (kill-emacs))
180 171
181 172
182 173