comparison lisp/cus-dep.el @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children 78c3f60ba757
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
29 29
30 30
31 ;;; Commentary: 31 ;;; Commentary:
32 32
33 ;; This file generates the custom-load files, loaded by cus-load.el. 33 ;; This file generates the custom-load files, loaded by cus-load.el.
34 ;; The only entry point is `Custom-make-dependencies'. 34 ;; Entry points are `Custom-make-dependencies' and
35 ;; `Custom-make-one-dependency'.
35 36
36 ;; It works by scanning all the `.el' files in a directory, and 37 ;; It works by scanning all the `.el' files in a directory, and
37 ;; evaluates any `defcustom', `defgroup', or `defface' expression that 38 ;; evaluates any `defcustom', `defgroup', or `defface' expression that
38 ;; it finds. The symbol changed by this expression is stored to a 39 ;; it finds. The symbol changed by this expression is stored to a
39 ;; hash table as the hash key, file name being the value. 40 ;; hash table as the hash key, file name being the value.
89 90
90 ;; Be very careful when changing this function. It looks easy to 91 ;; Be very careful when changing this function. It looks easy to
91 ;; understand, but is in fact very easy to break. Be sure to read and 92 ;; understand, but is in fact very easy to break. Be sure to read and
92 ;; understand the commentary above! 93 ;; understand the commentary above!
93 94
94 ;;;###autoload 95 (defun Custom-make-dependencies-1 (subdirs)
95 (defun Custom-make-dependencies (&optional subdirs)
96 "Extract custom dependencies from .el files in SUBDIRS.
97 SUBDIRS is a list of directories. If it is nil, the command-line
98 arguments are used. If it is a string, only that directory is
99 processed. This function is especially useful in batch mode.
100
101 Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS"
102 (interactive "DDirectory: ")
103 (and (stringp subdirs)
104 (setq subdirs (list subdirs)))
105 (or subdirs
106 ;; Usurp the command-line-args
107 (setq subdirs command-line-args-left
108 command-line-args-left nil))
109 (setq subdirs (mapcar #'expand-file-name subdirs)) 96 (setq subdirs (mapcar #'expand-file-name subdirs))
110 (with-temp-buffer 97 (with-temp-buffer
111 (let ((enable-local-eval nil) 98 (let ((enable-local-eval nil)
112 (hash (make-hash-table :test 'eq))) 99 (hash (make-hash-table :test 'eq)))
113 (dolist (dir subdirs) 100 (dolist (dir subdirs)
156 (t 143 (t
157 (princ (format "Generating %s...\n" cusload-base-file)) 144 (princ (format "Generating %s...\n" cusload-base-file))
158 (with-temp-file cusload-file 145 (with-temp-file cusload-file
159 (insert ";;; " cusload-base-file 146 (insert ";;; " cusload-base-file
160 " --- automatically extracted custom dependencies\n" 147 " --- automatically extracted custom dependencies\n"
161 "\n;;; Code:\n\n") 148 "\n;;; Code:\n\n"
149 "(autoload 'custom-add-loads \"cus-load\")\n\n")
162 (mapatoms 150 (mapatoms
163 (lambda (sym) 151 (lambda (sym)
164 (let ((members (get sym 'custom-group)) 152 (let ((members (get sym 'custom-group))
165 item where found) 153 item where found)
166 (when members 154 (when members
179 (when found 167 (when found
180 (insert "))\n")))))) 168 (insert "))\n"))))))
181 (insert "\n;;; custom-load.el ends here\n")) 169 (insert "\n;;; custom-load.el ends here\n"))
182 (clrhash hash))))))))) 170 (clrhash hash)))))))))
183 171
172 (defun Custom-make-one-dependency ()
173 "Extract custom dependencies from .el files in one dir, on the command line.
174 Like `Custom-make-dependencies' but snarfs only one command-line argument,
175 making it useful in a chain of batch commands in a single XEmacs invocation."
176 (let ((subdir (car command-line-args-left)))
177 (setq command-line-args-left (cdr command-line-args-left))
178 (Custom-make-dependencies-1 (list subdir))))
179
180 ;;;###autoload
181 (defun Custom-make-dependencies (&optional subdirs)
182 "Extract custom dependencies from .el files in SUBDIRS.
183 SUBDIRS is a list of directories. If it is nil, the command-line
184 arguments are used. If it is a string, only that directory is
185 processed. This function is especially useful in batch mode.
186
187 Batch usage: xemacs -batch -l cus-dep.el -f Custom-make-dependencies DIRS"
188 (interactive "DDirectory: ")
189 (and (stringp subdirs)
190 (setq subdirs (list subdirs)))
191 (or subdirs
192 ;; Usurp the command-line-args
193 (setq subdirs command-line-args-left
194 command-line-args-left nil))
195 (Custom-make-dependencies-1 subdirs))
196
184 (provide 'cus-dep) 197 (provide 'cus-dep)
185 198
186 ;;; cus-dep.el ends here 199 ;;; cus-dep.el ends here