(universal-coding-system-argument): Improve prompt strings.
[emacs.git] / lisp / cus-dep.el
blob286d4830fa873d95ca20aa07f643746043e76f91
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
8 ;; This file is part of GNU Emacs.
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.
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.
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.
25 ;;; Code:
27 (require 'cl)
28 (require 'widget)
29 (require 'cus-face)
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 (erase-buffer)
50 (insert-file-contents file)
51 (goto-char (point-min))
52 (string-match "\\`\\(.*\\)\\.el\\'" file)
53 (let ((name (file-name-nondirectory (match-string 1 file))))
54 (condition-case nil
55 (while (re-search-forward "^(defcustom\\|^(defface\\|^(defgroup"
56 nil t)
57 (beginning-of-line)
58 (let ((expr (read (current-buffer))))
59 (eval expr)
60 (put (nth 1 expr) 'custom-where name)))
61 (error nil)))))
62 (setq all-subdirs (cdr all-subdirs)))))
63 (message "Generating cus-load.el...")
64 (find-file "cus-load.el")
65 (erase-buffer)
66 (insert "\
67 ;;; cus-load.el --- automatically extracted custom dependencies
69 ;;; Code:
72 (mapatoms (lambda (symbol)
73 (let ((members (get symbol 'custom-group))
74 item where found)
75 (when members
76 (while members
77 (setq item (car (car members))
78 members (cdr members)
79 where (get item 'custom-where))
80 (unless (or (null where)
81 (member where found))
82 (if found
83 (insert " ")
84 (insert "(put '" (symbol-name symbol)
85 " 'custom-loads '("))
86 (prin1 where (current-buffer))
87 (push where found)))
88 (when found
89 (insert "))\n"))))))
90 (insert "\
92 \(provide 'cus-load)
94 ;;; cus-load.el ends here\n")
95 (let ((kept-new-versions 10000000))
96 (save-buffer))
97 (message "Generating cus-load.el...done")
98 (kill-emacs))
100 ;;; cus-dep.el ends here