Mercurial > emacs
annotate lisp/cus-dep.el @ 17692:426dde653028 gnumach-release-1-1 gnumach-release-1-1-1 libc-970508 libc-970509 libc-970510 libc-970511 libc-970512 libc-970513 libc-970514 libc-970515 libc-970516 libc-970517 libc-970518 libc-970519 libc-970520 libc-970521 libc-970522 libc-970523 libc-970524 libc-970525 libc-970526 libc-970527 libc-970528 libc-970529 libc-970530 libc-970531 libc-970601 libc-970602 libc-970603 libc-970604 libc-970605
Recognize either / or - as a machine/suptype separator from uname -m
to cope with older systems that have the older uname.
author | Thomas Bushnell, BSG <thomas@gnu.org> |
---|---|
date | Wed, 07 May 1997 19:19:04 +0000 |
parents | 3a1471ba9387 |
children | 2522a70cd009 |
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. | |
33 Usage: emacs -batch -l ./cus-dep.el -f custom-make-dependencies" | |
34 (let ((enable-local-eval nil) | |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
35 all-subdirs pending |
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 (setq pending '(".")) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
40 (while pending |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
41 (let ((this (car pending)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
42 this-subdirs |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
43 default-directory) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
44 (setq all-subdirs (cons this all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
45 (setq pending (cdr pending)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
46 (setq default-directory |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
47 (expand-file-name this start-directory)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
48 (message "Finding subdirs of %s" this) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
49 (erase-buffer) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
50 (condition-case nil |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
51 (progn |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
52 (insert-file-contents "subdirs.el") |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
53 (goto-char (point-min)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
54 (search-forward "'(") |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
55 (forward-char -1) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
56 (setq this-subdirs (read (current-buffer))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
57 (setq pending (nconc pending |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
58 (mapcar |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
59 (function (lambda (dir) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
60 (file-relative-name |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
61 (file-name-as-directory |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
62 (expand-file-name dir this)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
63 start-directory))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
64 this-subdirs)))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
65 (error nil)))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
66 |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
67 (while all-subdirs |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
68 (message "Directory %s" (car all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
69 (let ((files (directory-files (car all-subdirs) nil "\\`[^=].*\\.el\\'")) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
70 (default-directory default-directory) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
71 file) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
72 (cd (car all-subdirs)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
73 (while files |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
74 (setq file (car files) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
75 files (cdr files)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
76 (message "Checking %s..." file) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
77 (erase-buffer) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
78 (insert-file-contents file) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
79 (goto-char (point-min)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
80 (string-match "\\`\\(.*\\)\\.el\\'" file) |
17393 | 81 (let ((name (file-name-nondirectory (match-string 1 file)))) |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
82 (condition-case nil |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
83 (while (re-search-forward "^(defcustom\\|^(defface\\|^(defgroup" |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
84 nil t) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
85 (beginning-of-line) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
86 (let ((expr (read (current-buffer)))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
87 (eval expr) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
88 (put (nth 1 expr) 'custom-where name))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
89 (error nil)))) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
90 (setq all-subdirs (cdr all-subdirs))))) |
17393 | 91 (message "Generating cus-load.el...") |
92 (find-file "cus-load.el") | |
93 (erase-buffer) | |
94 (insert "\ | |
95 ;;; cus-load.el --- automatically extracted custom dependencies | |
96 ;; | |
97 ;;; Code: | |
17395 | 98 |
17393 | 99 ") |
100 (mapatoms (lambda (symbol) | |
101 (let ((members (get symbol 'custom-group)) | |
102 item where found) | |
103 (when members | |
104 (while members | |
105 (setq item (car (car members)) | |
106 members (cdr members) | |
107 where (get item 'custom-where)) | |
108 (unless (or (null where) | |
109 (member where found)) | |
110 (if found | |
111 (insert " ") | |
112 (insert "(put '" (symbol-name symbol) | |
113 " 'custom-loads '(")) | |
17473
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
114 (prin1 where (current-buffer)) |
17393 | 115 (push where found))) |
17473
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
116 (when found |
83503d0dc576
Fixed generation of empty dependencies lists.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17395
diff
changeset
|
117 (insert "))\n")))))) |
17479 | 118 (insert "\ |
119 | |
120 \(provide 'cus-load) | |
121 | |
122 ;;; cus-load.el ends here\n") | |
17685
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
123 (let ((kept-new-versions 10000000)) |
3a1471ba9387
(custom-make-dependencies):
Richard M. Stallman <rms@gnu.org>
parents:
17520
diff
changeset
|
124 (save-buffer)) |
17474 | 125 (message "Generating cus-load.el...done")) |
17393 | 126 |
127 ;;; cus-dep.el ends here |