Mercurial > emacs
annotate lisp/cus-dep.el @ 42188:40087ecf14d6
Add "language" to the load-path.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Wed, 19 Dec 2001 16:46:50 +0000 |
parents | b174db545cfd |
children | 227850832281 |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30884
diff
changeset
|
1 ;;; cus-dep.el --- find customization dependencies |
17393 | 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 | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30884
diff
changeset
|
25 ;;; Commentary: |
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
30884
diff
changeset
|
26 |
17393 | 27 ;;; Code: |
28 | |
28301
88b4e08f3ac1
Require CL at compile-time only.
Gerd Moellmann <gerd@gnu.org>
parents:
23099
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
30 (require 'widget) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
31 (require 'cus-face) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
32 (require 'autoload) |
17393 | 33 |
34 (defun custom-make-dependencies () | |
35 "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
|
36 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies DIRS" |
17393 | 37 (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
|
38 (all-subdirs command-line-args-left) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
39 (start-directory default-directory)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
40 (get-buffer-create " cus-dep temp") |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
41 (set-buffer " cus-dep temp") |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
42 (while all-subdirs |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
43 (message "Directory %s" (car all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
44 (let ((files (directory-files (car all-subdirs) nil "\\`[^=].*\\.el\\'")) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
45 (default-directory default-directory) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
46 file |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
47 is-autoloaded) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
48 (cd (car all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
49 (while files |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
50 (setq file (car files) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
51 files (cdr files)) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
52 (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
|
53 (erase-buffer) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
54 (insert-file-contents file) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
55 (goto-char (point-min)) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
56 (string-match "\\`\\(.*\\)\\.el\\'" file) |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
57 (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
|
58 (condition-case nil |
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
59 (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
|
60 nil t) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
61 (setq is-autoloaded nil) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
62 (beginning-of-line) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
63 (save-excursion |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
64 (forward-line -1) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
65 (if (looking-at generate-autoload-cookie) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
66 (setq is-autoloaded t))) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
67 (let ((expr (read (current-buffer)))) |
21755
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
68 (condition-case nil |
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
69 (progn |
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
70 (eval expr) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
71 (put (nth 1 expr) 'custom-autoloaded is-autoloaded) |
21755
44c9237d9e52
(custom-make-dependencies): Don't give up
Richard M. Stallman <rms@gnu.org>
parents:
19526
diff
changeset
|
72 (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
|
73 (error nil)))) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
74 (error nil))))) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
75 (setq all-subdirs (cdr all-subdirs))))) |
17393 | 76 (message "Generating cus-load.el...") |
77 (find-file "cus-load.el") | |
78 (erase-buffer) | |
79 (insert "\ | |
80 ;;; cus-load.el --- automatically extracted custom dependencies | |
81 ;; | |
82 ;;; Code: | |
17395 | 83 |
17393 | 84 ") |
85 (mapatoms (lambda (symbol) | |
86 (let ((members (get symbol 'custom-group)) | |
87 item where found) | |
88 (when members | |
89 (while members | |
90 (setq item (car (car members)) | |
91 members (cdr members) | |
92 where (get item 'custom-where)) | |
93 (unless (or (null where) | |
94 (member where found)) | |
95 (if found | |
96 (insert " ") | |
97 (insert "(put '" (symbol-name symbol) | |
98 " 'custom-loads '(")) | |
17473
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
99 (prin1 where (current-buffer)) |
17393 | 100 (push where found))) |
17473
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
101 (when found |
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
102 (insert "))\n")))))) |
17479 | 103 (insert "\ |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
104 ;;; These are for handling :version. We need to have a minimum of |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
105 ;;; information so `custom-changed-variables' could do its job. |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
106 ;;; For both groups and variables we have to set `custom-version'. |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
107 ;;; For variables we also set the `standard-value' and for groups |
23099 | 108 ;;; `group-documentation' (which is shown in the customize buffer), so |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
109 ;;; we don't have to load the file containing the group. |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
110 |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
111 ;;; `custom-versions-load-alist' is an alist that has as car a version |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
112 ;;; number and as elts the files that have variables that contain that |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
113 ;;; version. These files should be loaded before showing the |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
114 ;;; customization buffer that `customize-changed-options' generates. |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
115 |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
116 |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
117 ;;; This macro is used so we don't modify the information about |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
118 ;;; variables and groups if it's already set. (We don't know when |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
119 ;;; cus-load.el is going to be loaded and at that time some of the |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
120 ;;; files might be loaded and some others might not). |
30884
a6155f9c1e66
(custom-make-dependencies): Quote open-paren in string.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30883
diff
changeset
|
121 \(defmacro custom-put-if-not (symbol propname value) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
122 `(unless (get ,symbol ,propname) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
123 (put ,symbol ,propname ,value))) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
124 |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
125 ") |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
126 (let ((version-alist nil)) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
127 (mapatoms (lambda (symbol) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
128 (let ((version (get symbol 'custom-version)) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
129 where) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
130 (when version |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
131 (setq where (get symbol 'custom-where)) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
132 (when (and where |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
133 ;; Don't bother to do anything if it's |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
134 ;; autoloaded because we will have all |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
135 ;; this info when emacs is running |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
136 ;; anyway. |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
137 (not (get symbol 'custom-autoloaded))) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
138 (insert "(custom-put-if-not '" (symbol-name symbol) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
139 " 'custom-version ") |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
140 (prin1 version (current-buffer)) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
141 (insert ")\n") |
22633
3da8188c31a3
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
22538
diff
changeset
|
142 (insert "(custom-put-if-not '" (symbol-name symbol)) |
22538
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
143 (if (get symbol 'standard-value) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
144 ;; This means it's a variable |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
145 (progn |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
146 (insert " 'standard-value t)\n") |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
147 (if (assoc version version-alist) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
148 (unless |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
149 (member where |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
150 (cdr (assoc version version-alist))) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
151 (push where (cdr (assoc version version-alist)))) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
152 (push (cons version (list where)) version-alist))) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
153 ;; This is a group |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
154 (insert " 'group-documentation ") |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
155 (prin1 (get symbol 'group-documentation) (current-buffer)) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
156 (insert ")\n"))))))) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
157 |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
158 (insert "\n(defvar custom-versions-load-alist " |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
159 (if version-alist "'" "")) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
160 (prin1 version-alist (current-buffer)) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
161 (insert "\n \"For internal use by custom.\")\n")) |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
162 |
2649d061d370
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21755
diff
changeset
|
163 (insert "\ |
17479 | 164 |
165 \(provide 'cus-load) | |
166 | |
30883
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28301
diff
changeset
|
167 ;;; Local Variables: |
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28301
diff
changeset
|
168 ;;; version-control: never |
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28301
diff
changeset
|
169 ;;; no-byte-compile: t |
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28301
diff
changeset
|
170 ;;; no-update-autoloads: t |
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28301
diff
changeset
|
171 ;;; End: |
17479 | 172 ;;; cus-load.el ends here\n") |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
173 (let ((kept-new-versions 10000000)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
174 (save-buffer)) |
17744
2522a70cd009
(custom-make-dependencies): Don't find the subdirs here;
Richard M. Stallman <rms@gnu.org>
parents:
17685
diff
changeset
|
175 (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
|
176 (kill-emacs)) |
17393 | 177 |
30883
869204bacd5f
Add local-variable settings to the generated file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28301
diff
changeset
|
178 |
17393 | 179 ;;; cus-dep.el ends here |