]> code.delx.au - gnu-emacs/blob - lisp/cus-dep.el
(timezone-parse-date): Match forms 1 and 2 first.
[gnu-emacs] / lisp / cus-dep.el
1 ;;; cus-dep.el --- Find customization dependencies.
2 ;;
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: internal
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'cl)
28 (load-file "widget.el")
29 (load-file "custom.el")
30 (load-file "cus-face.el")
31
32 (defun custom-make-dependencies ()
33 "Batch function to extract custom dependencies from .el files.
34 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies"
35 (let ((enable-local-eval nil)
36 (files (directory-files "" nil "\\`[^=].*\\.el\\'" t))
37 file)
38 (while files
39 (setq file (car files)
40 files (cdr files))
41 (message "Checking %s..." file)
42 (set-buffer (find-file-noselect file))
43 (goto-char (point-min))
44 (string-match "\\`\\(.*\\)\\.el\\'" file)
45 (condition-case nil
46 (let ((name (file-name-nondirectory (match-string 1 file))))
47 (while t
48 (let ((expr (read (current-buffer))))
49 (when (and (listp expr)
50 (memq (car expr) '(defcustom defface defgroup)))
51 (eval expr)
52 (put (nth 1 expr) 'custom-where name)))))
53 (error nil))
54 (kill-buffer (current-buffer))))
55 (message "Generating cus-load.el...")
56 (find-file "cus-load.el")
57 (erase-buffer)
58 (insert "\
59 ;;; cus-load.el --- automatically extracted custom dependencies
60 ;;
61 ;;; Code:
62
63 ")
64 (mapatoms (lambda (symbol)
65 (let ((members (get symbol 'custom-group))
66 item where found)
67 (when members
68 (while members
69 (setq item (car (car members))
70 members (cdr members)
71 where (get item 'custom-where))
72 (unless (or (null where)
73 (member where found))
74 (if found
75 (insert " ")
76 (insert "(put '" (symbol-name symbol)
77 " 'custom-loads '("))
78 (prin1 where (current-buffer))
79 (push where found)))
80 (when found
81 (insert "))\n"))))))
82 (insert "\
83
84 \(provide 'cus-load)
85
86 ;;; cus-load.el ends here\n")
87 (save-buffer)
88 (message "Generating cus-load.el...done"))
89
90 ;;; cus-dep.el ends here