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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17393
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
1 ;;; cus-dep.el --- Find customization dependencies.
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
2 ;;
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
4 ;;
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
6 ;; Keywords: internal
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
7
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
8 ;; This file is part of GNU Emacs.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
9
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
13 ;; any later version.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
14
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
18 ;; GNU General Public License for more details.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
19
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
20 ;; You should have received a copy of the GNU General Public License
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
23 ;; Boston, MA 02111-1307, USA.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17479
diff changeset
24
17393
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
25 ;;; Code:
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
26
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
30
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
31 (defun custom-make-dependencies ()
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
66 (message "Generating cus-load.el...")
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
67 (find-file "cus-load.el")
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
68 (erase-buffer)
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
69 (insert "\
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
70 ;;; cus-load.el --- automatically extracted custom dependencies
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
71 ;;
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
72 ;;; Code:
17395
ad9d92edda0d Added newline.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17393
diff changeset
73
17393
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
74 ")
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
75 (mapatoms (lambda (symbol)
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
76 (let ((members (get symbol 'custom-group))
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
77 item where found)
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
78 (when members
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
79 (while members
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
80 (setq item (car (car members))
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
81 members (cdr members)
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
82 where (get item 'custom-where))
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
83 (unless (or (null where)
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
84 (member where found))
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
85 (if found
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
86 (insert " ")
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
87 (insert "(put '" (symbol-name symbol)
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
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
b613ee4fd988 provide `cus-load'.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17474
diff changeset
93 (insert "\
b613ee4fd988 provide `cus-load'.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17474
diff changeset
94
b613ee4fd988 provide `cus-load'.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17474
diff changeset
95 \(provide 'cus-load)
b613ee4fd988 provide `cus-load'.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17474
diff changeset
96
b613ee4fd988 provide `cus-load'.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17474
diff changeset
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
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
102
14c7f7b87c22 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
103 ;;; cus-dep.el ends here