(read_minibuf): New arg disable_multibyte.
[bpt/emacs.git] / 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 (require 'widget)
29 (require 'cus-face)
30
31 (defun custom-make-dependencies ()
32 "Batch function to extract custom dependencies from .el files.
33 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
34 (let ((enable-local-eval nil)
35 (all-subdirs command-line-args-left)
36 (start-directory default-directory))
37 (get-buffer-create " cus-dep temp")
38 (set-buffer " cus-dep temp")
39 (while all-subdirs
40 (message "Directory %s" (car all-subdirs))
41 (let ((files (directory-files (car all-subdirs) nil "\\`[^=].*\\.el\\'"))
42 (default-directory default-directory)
43 file)
44 (cd (car all-subdirs))
45 (while files
46 (setq file (car files)
47 files (cdr files))
48 (when (file-exists-p file)
49 (message "Checking %s..." file)
50 (erase-buffer)
51 (insert-file-contents file)
52 (goto-char (point-min))
53 (string-match "\\`\\(.*\\)\\.el\\'" file)
54 (let ((name (file-name-nondirectory (match-string 1 file))))
55 (condition-case nil
56 (while (re-search-forward "^(defcustom\\|^(defface\\|^(defgroup"
57 nil t)
58 (beginning-of-line)
59 (let ((expr (read (current-buffer))))
60 (eval expr)
61 (put (nth 1 expr) 'custom-where name)))
62 (error nil)))))
63 (setq all-subdirs (cdr all-subdirs)))))
64 (message "Generating cus-load.el...")
65 (find-file "cus-load.el")
66 (erase-buffer)
67 (insert "\
68 ;;; cus-load.el --- automatically extracted custom dependencies
69 ;;
70 ;;; Code:
71
72 ")
73 (mapatoms (lambda (symbol)
74 (let ((members (get symbol 'custom-group))
75 item where found)
76 (when members
77 (while members
78 (setq item (car (car members))
79 members (cdr members)
80 where (get item 'custom-where))
81 (unless (or (null where)
82 (member where found))
83 (if found
84 (insert " ")
85 (insert "(put '" (symbol-name symbol)
86 " 'custom-loads '("))
87 (prin1 where (current-buffer))
88 (push where found)))
89 (when found
90 (insert "))\n"))))))
91 (insert "\
92
93 \(provide 'cus-load)
94
95 ;;; cus-load.el ends here\n")
96 (let ((kept-new-versions 10000000))
97 (save-buffer))
98 (message "Generating cus-load.el...done")
99 (kill-emacs))
100
101 ;;; cus-dep.el ends here