1 ;;; cus-dep.el --- find customization dependencies
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
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)
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.
29 (eval-when-compile (require 'cl
))
33 (defun custom-make-dependencies ()
34 "Batch function to extract custom dependencies from .el files.
35 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS"
36 (let ((enable-local-eval nil
))
37 (set-buffer (get-buffer-create " cus-dep temp"))
38 (dolist (subdir command-line-args-left
)
39 (message "Directory %s" subdir
)
40 (let ((files (directory-files subdir nil
"\\`[^=].*\\.el\\'"))
41 (default-directory (expand-file-name subdir
))
42 (preloaded (concat "\\`"
45 (file-name-sans-extension
46 (file-name-nondirectory f
)))
47 preloaded-file-list
) t
)
50 (when (and (file-exists-p file
)
51 ;; Ignore files that are preloaded.
52 (not (string-match preloaded file
)))
54 (insert-file-contents file
)
55 (goto-char (point-min))
56 (string-match "\\`\\(.*\\)\\.el\\'" file
)
57 (let ((name (file-name-nondirectory (match-string 1 file
)))
58 (load-file-name file
))
61 (concat "(provide[ \t\n]+\\('\\|(quote[ \t\n]\\)[ \t\n]*"
62 (regexp-quote name
) "[ \t\n)]")
64 (setq name
(intern name
)))
66 (while (re-search-forward
67 "^(def\\(custom\\|face\\|group\\)" nil t
)
69 (let ((expr (read (current-buffer))))
71 (let ((custom-dont-initialize t
))
73 (put (nth 1 expr
) 'custom-where name
))
76 (message "Generating cus-load.el...")
77 (set-buffer (find-file-noselect "cus-load.el"))
80 ;;; cus-load.el --- automatically extracted custom dependencies
85 (mapatoms (lambda (symbol)
86 (let ((members (get symbol
'custom-group
))
89 ;; So x and no-x builds won't differ.
91 (sort (copy-sequence members
)
92 (lambda (x y
) (string< (car x
) (car y
)))))
94 (setq item
(car (car members
))
96 where
(get item
'custom-where
))
97 (unless (or (null where
)
101 (insert "(put '" (symbol-name symbol
)
102 " 'custom-loads '("))
103 (prin1 where
(current-buffer))
108 ;;; These are for handling :version. We need to have a minimum of
109 ;;; information so `customize-changed-options' could do its job.
110 ;;; For both groups and variables we have to set `custom-version'.
111 ;;; For variables we also set the `standard-value' and for groups
112 ;;; `group-documentation' (which is shown in the customize buffer), so
113 ;;; we don't have to load the file containing the group.
115 ;;; `custom-versions-load-alist' is an alist that has as car a version
116 ;;; number and as elts the files that have variables that contain that
117 ;;; version. These files should be loaded before showing the
118 ;;; customization buffer that `customize-changed-options' generates.
121 ;;; This macro is used so we don't modify the information about
122 ;;; variables and groups if it's already set. (We don't know when
123 ;;; cus-load.el is going to be loaded and at that time some of the
124 ;;; files might be loaded and some others might not).
125 \(defmacro custom-put-if-not (symbol propname value)
126 `(unless (get ,symbol ,propname)
127 (put ,symbol ,propname ,value)))
130 (let ((version-alist nil
))
131 (mapatoms (lambda (symbol)
132 (let ((version (get symbol
'custom-version
))
135 (setq where
(get symbol
'custom-where
))
137 (insert "(custom-put-if-not '" (symbol-name symbol
)
139 (prin1 version
(current-buffer))
141 (insert "(custom-put-if-not '" (symbol-name symbol
))
142 (if (get symbol
'standard-value
)
143 ;; This means it's a variable
145 (insert " 'standard-value t)\n")
146 (if (assoc version version-alist
)
149 (cdr (assoc version version-alist
)))
150 (push where
(cdr (assoc version version-alist
))))
151 (push (cons version
(list where
)) version-alist
)))
153 (insert " 'group-documentation ")
154 (prin1 (get symbol
'group-documentation
) (current-buffer))
157 (insert "\n(defvar custom-versions-load-alist "
158 (if version-alist
"'" ""))
159 (prin1 version-alist
(current-buffer))
160 (insert "\n \"For internal use by custom.\")\n"))
167 ;;; version-control: never
168 ;;; no-byte-compile: t
169 ;;; no-update-autoloads: t
171 ;;; cus-load.el ends here\n")
172 (let ((kept-new-versions 10000000))
174 (message "Generating cus-load.el...done")
178 ;;; cus-dep.el ends here