Mercurial > emacs
annotate lisp/cus-dep.el @ 22490:75a50246a099
Initial revision
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 14 Jun 1998 21:32:23 +0000 |
parents | 44c9237d9e52 |
children | 2649d061d370 |
rev | line source |
---|---|
17393 | 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 | |
17520 | 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 | |
17393 | 25 ;;; Code: |
26 | |
27 (require 'cl) | |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
28 (require 'widget) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
29 (require 'cus-face) |
17393 | 30 |
31 (defun custom-make-dependencies () | |
32 "Batch function to extract custom dependencies from .el files. | |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
33 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" |
17393 | 34 (let ((enable-local-eval nil) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
35 (all-subdirs command-line-args-left) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
36 (start-directory default-directory)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
37 (get-buffer-create " cus-dep temp") |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
38 (set-buffer " cus-dep temp") |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
39 (while all-subdirs |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
40 (message "Directory %s" (car all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
41 (let ((files (directory-files (car all-subdirs) nil "\\`[^=].*\\.el\\'")) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
42 (default-directory default-directory) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
43 file) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
44 (cd (car all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
45 (while files |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
46 (setq file (car files) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
47 files (cdr files)) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
48 (when (file-exists-p file) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
49 (erase-buffer) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
50 (insert-file-contents file) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
51 (goto-char (point-min)) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
52 (string-match "\\`\\(.*\\)\\.el\\'" file) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
53 (let ((name (file-name-nondirectory (match-string 1 file)))) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
54 (condition-case nil |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
55 (while (re-search-forward "^(defcustom\\|^(defface\\|^(defgroup" |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
56 nil t) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
57 (beginning-of-line) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
58 (let ((expr (read (current-buffer)))) |
21755
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
59 (condition-case nil |
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
60 (progn |
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
61 (eval expr) |
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
62 (put (nth 1 expr) 'custom-where name)) |
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
63 (error nil)))) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
64 (error nil))))) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
65 (setq all-subdirs (cdr all-subdirs))))) |
17393 | 66 (message "Generating cus-load.el...") |
67 (find-file "cus-load.el") | |
68 (erase-buffer) | |
69 (insert "\ | |
70 ;;; cus-load.el --- automatically extracted custom dependencies | |
71 ;; | |
72 ;;; Code: | |
17395 | 73 |
17393 | 74 ") |
75 (mapatoms (lambda (symbol) | |
76 (let ((members (get symbol 'custom-group)) | |
77 item where found) | |
78 (when members | |
79 (while members | |
80 (setq item (car (car members)) | |
81 members (cdr members) | |
82 where (get item 'custom-where)) | |
83 (unless (or (null where) | |
84 (member where found)) | |
85 (if found | |
86 (insert " ") | |
87 (insert "(put '" (symbol-name symbol) | |
88 " 'custom-loads '(")) | |
17473
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
89 (prin1 where (current-buffer)) |
17393 | 90 (push where found))) |
17473
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
91 (when found |
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
92 (insert "))\n")))))) |
17479 | 93 (insert "\ |
94 | |
95 \(provide 'cus-load) | |
96 | |
97 ;;; cus-load.el ends here\n") | |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
98 (let ((kept-new-versions 10000000)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
99 (save-buffer)) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
100 (message "Generating cus-load.el...done") |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
101 (kill-emacs)) |
17393 | 102 |
103 ;;; cus-dep.el ends here |