annotate lisp/utils/autoload.el @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents e121b013d1f0
children b405438285a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; autoload.el --- maintain autoloads in loaddefs.el.
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
5 ;; Copyright (C) 1996 Ben Wing.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
10 ;; This file is part of XEmacs.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
11
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
13 ;; under the terms of the GNU General Public License as published by
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
15 ;; any later version.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
20 ;; General Public License for more details.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
21
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
22 ;; You should have received a copy of the GNU General Public License
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
25 ;; 02111-1307, USA.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
26
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
27 ;;; Synched up with: Not synched with FSF.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; This code helps GNU Emacs maintainers keep the loaddefs.el file up to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; date. It interprets magic cookies of the form ";;;###autoload" in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; lisp source files in various useful ways. To learn more, read the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; source; if you're going to use this, you'd better be able to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defun make-autoload (form file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "Turn FORM, a defun or defmacro, into an autoload for source file FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 Returns nil if FORM is not a defun, define-skeleton or defmacro."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (let ((car (car-safe form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (if (memq car '(defun define-skeleton defmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let ((macrop (eq car 'defmacro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 name doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (setq form (cdr form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 name (car form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; Ignore the arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 form (cdr (if (eq car 'define-skeleton)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (cdr form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 doc (car form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (if (stringp doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (setq form (cdr form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq doc nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (list 'autoload (list 'quote name) file doc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (or (eq car 'define-skeleton)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (eq (car-safe (car form)) 'interactive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (if macrop (list 'quote 'macro) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (put 'define-skeleton 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
63 (defvar generate-autoload-cookie ";;;###autoload"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Magic comment indicating the following form should be autoloaded.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
65 Used by `update-file-autoloads'. This string should be
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 meaningless to Lisp (e.g., a comment).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 This string is used:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 \(defun function-to-be-autoloaded () ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
73 If this string appears alone on a line, the following form will be
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
74 read and an autoload made for it. If it is followed by the string
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
75 \"immediate\", then the form on the following line will be copied
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
76 verbatim. If there is further text on the line, that text will be
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
77 copied verbatim to `generated-autoload-file'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
79 (defvar generate-autoload-section-header "\f\n;;;### "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "String inserted before the form identifying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 the section of autoloads for a file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
83 (defvar generate-autoload-section-trailer "\n;;;***\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "String which indicates the end of the section of autoloads for a file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; Forms which have doc-strings which should be printed specially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; the doc-string in FORM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; There used to be the following note here:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; ;;; Note: defconst and defvar should NOT be marked in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; ;;; We don't want to produce defconsts and defvars that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; ;;; make-docfile can grok, because then it would grok them twice,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; ;;; once in foo.el (where they are given with ;;;###autoload) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; ;;; once in loaddefs.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; Counter-note: Yes, they should be marked in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; make-docfile only processes those files that are loaded into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; dumped Emacs, and those files should never have anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; autoloaded here. The above-feared problem only occurs with files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; which have autoloaded entries *and* are processed by make-docfile;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; there should be no such files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (put 'autoload 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (put 'defun 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (put 'defvar 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (put 'defconst 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (put 'defmacro 'doc-string-elt 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun autoload-trim-file-name (file)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
111 "Returns a relative pathname of FILE including the last directory."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (setq file (expand-file-name file))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
113 (file-relative-name file (file-name-directory
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
114 (directory-file-name
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
115 (file-name-directory file)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defun generate-file-autoloads (file &optional funlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 "Insert at point a loaddefs autoload section for FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 autoloads are generated for defuns and defmacros in FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 marked by `generate-autoload-cookie' (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 If FILE is being visited in a buffer, the contents of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 are used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (interactive "fGenerate autoloads for file: ")
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
125 (generate-file-autoloads-1 file funlist))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
126
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
127 (defun* generate-file-autoloads-1 (file funlist)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
128 "Insert at point a loaddefs autoload section for FILE.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
129 autoloads are generated for defuns and defmacros in FILE
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
130 marked by `generate-autoload-cookie' (which see).
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
131 If FILE is being visited in a buffer, the contents of the buffer
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
132 are used."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let ((outbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (autoloads-done '())
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
135 (load-name (replace-in-string (file-name-nondirectory file)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
136 "\\.elc?$"
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
137 ""))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
138 (trim-name (autoload-trim-file-name file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (dofiles (not (null funlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (print-length nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (print-readably t) ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (float-output-format nil)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
143 ;; (done-any nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (visited (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 output-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; If the autoload section we create here uses an absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; pathname for FILE in its header, and then Emacs is installed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; under a different path on another system,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; `update-autoloads-here' won't be able to find the files to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; autoloaded. So, if FILE is in the same directory or a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; subdirectory of the current buffer's directory, we'll make it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; relative to the current buffer's directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (progn
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 112
diff changeset
159 (let ((find-file-hooks nil)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 112
diff changeset
160 (enable-local-variables nil))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 112
diff changeset
161 (set-buffer (or visited (find-file-noselect file)))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 112
diff changeset
162 (set-syntax-table lisp-mode-syntax-table))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (goto-char (point-min))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
167 (unless (search-forward generate-autoload-cookie nil t)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
168 (message "No autoloads found in %s" trim-name)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
169 (return-from generate-file-autoloads-1))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
170
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
171 (message "Generating autoloads for %s..." trim-name)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
172 (goto-char (point-min))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (while (if dofiles funlist (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if (not dofiles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (skip-chars-forward " \t\n\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (concat "(def\\(un\\|var\\|const\\|macro\\) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (regexp-quote (symbol-name (car funlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "\\s "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (goto-char (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ((or dofiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (looking-at (regexp-quote generate-autoload-cookie)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (if dofiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (search-forward generate-autoload-cookie)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (skip-chars-forward " \t"))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
189 ;; (setq done-any t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (or dofiles (eolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; Read the next form and make an autoload.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (let* ((form (prog1 (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (or (bolp) (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (autoload (make-autoload form load-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (doc-string-elt (get (car-safe form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 'doc-string-elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq autoloads-done (cons (nth 1 form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 autoloads-done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq autoload form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if (and doc-string-elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (stringp (nth doc-string-elt autoload)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; We need to hack the printing because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; doc-string must be printed specially for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; make-docfile (sigh).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let* ((p (nthcdr (1- doc-string-elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 autoload))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (elt (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setcdr p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (princ "\n(" outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; XEmacs change: don't let ^^L's get into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;; the file or sorting is hard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (let ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (p (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (mapcar (function (lambda (elt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (prin1 elt outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (princ " " outbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (setq p2 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (while (search-forward "\^L" p2 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (insert "\\^L")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (goto-char p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (princ "\"\\\n" outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (let ((begin (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (princ (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (prin1-to-string (car elt)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; Insert a backslash before each ( that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; appears at the beginning of a line in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; the doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (while (search-backward "\n(" begin t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (insert "\\"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (if (null (cdr elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (princ ")" outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (princ " " outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (princ (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (prin1-to-string (cdr elt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 outbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (terpri outbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; XEmacs change: another fucking ^L hack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (let ((p (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (print autoload outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq p2 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (goto-char p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (while (search-forward "\^L" p2 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (insert "\\^L")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (goto-char p2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; Copy the rest of the line to the output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (let ((begin (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (terpri outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (cond ((looking-at "immediate\\s *$") ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; This is here so that you can automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; have small hook functions copied to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; loaddefs.el so that it's not necessary to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; load a whole file just to get a two-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; do-nothing find-file-hook... --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (princ (buffer-substring begin (point)) outbuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ((looking-at ";")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; Don't read the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if dofiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq funlist (cdr funlist)))))))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
298 ;;(unless visited
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; We created this buffer, so we should kill it.
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
300 ;; Customize needs it later, we don't want to read the file
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
301 ;; in twice.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
302 ;;(kill-buffer (current-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (set-buffer outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq output-end (point-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (if t ;; done-any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; XEmacs -- always do this so that we cache the information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; that we've processed the file already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (insert generate-autoload-section-header)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
310 (prin1 (list 'autoloads autoloads-done load-name trim-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 outbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (terpri outbuf)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
313 ;;;; (insert ";;; Generated autoloads from "
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
314 ;;;; (autoload-trim-file-name file) "\n")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; Warn if we put a line in loaddefs.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; that is long enough to cause trouble.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
317 (when (< output-end (point))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
318 (setq output-end (point-marker)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (while (< (point) output-end)
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
320 ;; (let ((beg (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (end-of-line)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
322 ;; Emacs -- I still haven't figured this one out.
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
323 ;; (if (> (- (point) beg) 900)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
324 ;; (progn
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
325 ;; (message "A line is too long--over 900 characters")
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
326 ;; (sleep-for 2)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
327 ;; (goto-char output-end)))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
328 ;; )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (goto-char output-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (insert generate-autoload-section-trailer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (or noninteractive ; XEmacs: only need one line in -batch mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (message "Generating autoloads for %s...done" file))))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
334
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
336 (defconst autoload-file-name "auto-autoloads.el"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
337 "Generic filename to put autoloads into.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
338 Unless you are an XEmacs maintainer, it is probably unwise to change this.")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
339
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
340 (defvar autoload-target-directory "../lisp/prim/"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
341 "Directory to put autoload declaration file into.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
342 Unless you know what you're doing, don't mess with this.")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
343
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
344 (defvar generated-autoload-file
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
345 (expand-file-name (concat autoload-target-directory
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
346 autoload-file-name)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
347 data-directory)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
348 "*File `update-file-autoloads' puts autoloads into.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 A .el file can set this in its local variables section to make its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 autoloads go somewhere else.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
352 (defconst cusload-file-name "custom-load.el"
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
353 "Generic filename ot put custom loads into.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
354 Unless you are an XEmacs maintainr, it is probably unwise to change this.")
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
355
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
356 (defvar generated-custom-file
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
357 (expand-file-name (concat autoload-target-directory
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
358 cusload-file-name)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
359 data-directory)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
360 "*File `update-file-autoloads' puts customization into.")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
361
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
362 (defvar customized-symbols nil)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
363
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
364 ;; Written by Per Abrahamsen
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
365 (defun autoload-snarf-defcustom (file)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
366 "Snarf all customizations in the current buffer."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
367 (let ((visited (get-file-buffer file)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
368 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
369 (set-buffer (or visited (find-file-noselect file)))
112
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 110
diff changeset
370 (when (and file
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 110
diff changeset
371 (string-match "\\`\\(.*\\)\\.el\\'" file)
48d667d6f17f Import from CVS: tag r20-1b8
cvs
parents: 110
diff changeset
372 (not (buffer-modified-p)))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
373 (goto-char (point-min))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
374 (condition-case nil
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
375 (let ((name (file-name-nondirectory (match-string 1 file))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
376 (while t
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
377 (let ((expr (read (current-buffer))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
378 (when (and (listp expr)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
379 (memq (car expr) '(defcustom defface defgroup)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
380 (eval expr)
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
381 (put (nth 1 expr) 'custom-where name)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
382 (pushnew (nth 1 expr) customized-symbols)))))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
383 (error nil)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
384 (unless (buffer-modified-p)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
385 (kill-buffer (current-buffer))))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
386
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
387 (defvar autoload-do-custom-save nil)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
388
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun update-file-autoloads (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "Update the autoloads for FILE in `generated-autoload-file'
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
392 \(which FILE might bind in its local variables).
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
393 This functions refuses to update autolaods files and custom loads."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (interactive "fUpdate autoloads for file: ")
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
395 (setq file (expand-file-name file))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
396 (when (and (file-newer-than-file-p file generated-autoload-file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
397 (not (member (file-name-nondirectory file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
398 (list autoload-file-name cusload-file-name))))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
399
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
400 (setq autoload-do-custom-save t)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
401 (let ((load-name (replace-in-string (file-name-nondirectory file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
402 "\\.elc?$"
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
403 ""))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
404 (trim-name (autoload-trim-file-name file))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
405 section-begin form)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
406 (save-excursion
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
407 (let ((find-file-hooks nil))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
408 (set-buffer (or (get-file-buffer generated-autoload-file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
409 (find-file-noselect generated-autoload-file))))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
410 ;; First delete all sections for this file.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
411 (goto-char (point-min))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
412 (while (search-forward generate-autoload-section-header nil t)
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
413 (setq section-begin (match-beginning 0))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
414 (setq form (read (current-buffer)))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
415 (when (string= (nth 2 form) load-name)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
416 (search-forward generate-autoload-section-trailer)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
417 (delete-region section-begin (point))))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
418
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
419 ;; Now find insertion point for new section
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
420 (block find-insertion-point
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
421 (goto-char (point-min))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
422 (while (search-forward generate-autoload-section-header nil t)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
423 (setq form (read (current-buffer)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
424 (when (string< trim-name (nth 3 form))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
425 ;; Found alphabetically correct insertion point
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
426 (goto-char (match-beginning 0))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
427 (return-from find-insertion-point))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
428 (search-forward generate-autoload-section-trailer))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
429 (when (eq (point) (point-min)) ; No existing entries?
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
430 (goto-char (point-max)))) ; Append.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
431
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
432 ;; Add in new sections for file
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
433 (generate-file-autoloads file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
434 (autoload-snarf-defcustom file))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
435
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
436 (when (interactive-p) (save-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (defun update-autoloads-here ()
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
440 "Update sections of the current buffer generated by `update-file-autoloads'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (let ((generated-autoload-file (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (while (search-forward generate-autoload-section-header nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (let* ((form (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (read (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (end-of-file nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (file (nth 3 form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; XEmacs change: if we can't find the file as specified, look
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; around a bit more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (cond ((and (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (or (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (file-exists-p file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ((and (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (save-match-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (let ((loc (locate-file (file-name-nondirectory file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 load-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if (null loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (setq loc (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (autoload-trim-file-name loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ".."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (if (or (get-file-buffer loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (file-exists-p loc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (setq file loc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (t
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
469 (setq file
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
470 (if (y-or-n-p
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
471 (format
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
472 "Can't find library `%s'; remove its autoloads? "
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
473 (nth 2 form) file))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
474 t
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
475 (condition-case ()
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
476 (read-file-name
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
477 (format "Find `%s' load file: "
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
478 (nth 2 form))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
479 nil nil t)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
480 (quit nil))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (let ((begin (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (search-forward generate-autoload-section-trailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (delete-region begin (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (generate-file-autoloads file)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;;;###autoload
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
489 (defun update-autoloads-from-directory (dir)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
490 "Update `generated-autoload-file' with all the current autoloads from DIR.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
491 This runs `update-file-autoloads' on each .el file in DIR.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
492 Obsolete autoload entries for files that no longer exist are deleted."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (interactive "DUpdate autoloads for directory: ")
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
494 (setq autoload-do-custom-save nil)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
495 (setq dir (expand-file-name dir))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
496 (let ((simple-dir (file-name-as-directory
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
497 (file-name-nondirectory
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
498 (directory-file-name dir))))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
499 (enable-local-eval nil))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
500 (save-excursion
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 78
diff changeset
501 (let ((find-file-hooks nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 78
diff changeset
502 (set-buffer (find-file-noselect generated-autoload-file)))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
503 (goto-char (point-min))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
504 (while (search-forward generate-autoload-section-header nil t)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
505 (let* ((begin (match-beginning 0))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
506 (form (condition-case ()
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
507 (read (current-buffer))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
508 (end-of-file nil)))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
509 (file (nth 3 form)))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
510 (when (and (stringp file)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
511 (string= (file-name-directory file) simple-dir)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
512 (not (file-exists-p
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
513 (expand-file-name
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
514 (file-name-nondirectory file) dir))))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
515 ;; Remove the obsolete section.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
516 (search-forward generate-autoload-section-trailer)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
517 (delete-region begin (point)))))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
518 ;; Update or create autoload sections for existing files.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
519 (mapcar 'update-file-autoloads (directory-files dir t "^[^=].*\\.el$"))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
520 (unless noninteractive
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
521 (save-buffer)))))
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 24
diff changeset
522
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
523 ;; Based on code from Per Abrahamsen
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
524 (defun autoload-save-customization ()
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
525 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
526 (set-buffer (find-file-noselect generated-custom-file))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
527 (erase-buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
528 (insert
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
529 (with-output-to-string
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
530 (mapcar (lambda (symbol)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
531 (let ((members (condition-case nil
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
532 (get symbol 'custom-group)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
533 (t (progn
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
534 (message "Bad plist in %s"
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
535 (symbol-name symbol)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
536 nil)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
537 item where
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
538 (found (condition-case nil
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
539 (get symbol 'custom-loads)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
540 (t nil)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
541 )
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
542 (when (or members found)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
543 (princ "(custom-put '")
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
544 (princ symbol)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
545 (princ " 'custom-loads '(")
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
546 (when found
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
547 ;; (message "found = `%s'" found)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
548 (insert (mapconcat 'prin1-to-string found " ")))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
549 (while members
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
550 (setq item (car (car members))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
551 members (cdr members)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
552 where (get item 'custom-where))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
553 (unless (or (null where)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
554 (member where found))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
555 ;; (message "where = `%s', found = `%s'" where found)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
556 (when found
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
557 (princ " "))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
558 (prin1 where)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
559 (push where found)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
560 (princ "))\n"))))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
561 customized-symbols)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
562 (when (= (point-min) (point-max))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
563 (set-buffer-modified-p nil))))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 100
diff changeset
564
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun batch-update-autoloads ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 "Update the autoloads for the files or directories on the command line.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
568 Runs `update-file-autoloads' on files and `update-directory-autoloads'
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 on directories. Must be used only with -batch, and kills Emacs on completion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 Each file will be processed even if an error occurred previously.
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
571 For example, invoke `xemacs -batch -f batch-update-autoloads *.el'.
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
572 The directory to which the auto-autoloads.el and custom-load.el files must
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
573 be the first parameter on the command line."
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
574 (unless noninteractive
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
575 (error "batch-update-autoloads is to be used only with -batch"))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
576 (let ((defdir default-directory)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
577 (enable-local-eval nil)) ; Don't query in batch mode.
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
578 (when (file-exists-p generated-custom-file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
579 (flet ((custom-put (symbol property value)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
580 (progn
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
581 (put symbol property value)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
582 (pushnew symbol customized-symbols))))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
583 (load generated-custom-file nil t)))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
584 ;; (message "Updating autoloads in %s..." generated-autoload-file)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
585 (dolist (arg command-line-args-left)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
586 (setq arg (expand-file-name arg defdir))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
587 (cond
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
588 ((file-directory-p arg)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
589 (message "Updating autoloads for directory %s..." arg)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
590 (update-autoloads-from-directory arg))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
591 ((file-exists-p arg)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
592 (update-file-autoloads arg))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
593 (t (error "No such file or directory: %s" arg))))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
594 (when autoload-do-custom-save
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
595 (autoload-save-customization))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
596 (fixup-autoload-buffer (concat (file-name-nondirectory defdir)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
597 "-autoloads"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (save-some-buffers t)
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
599 ;; (message "Done")
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
600 (kill-emacs 0)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
602 (defun fixup-autoload-buffer (sym)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
603 (save-excursion
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
604 (set-buffer (find-file-noselect generated-autoload-file))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
605 (goto-char (point-min))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
606 (if (and (not (= (point-min) (point-max)))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
607 (not (looking-at ";;; DO NOT MODIFY THIS FILE")))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
608 (progn
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
609 (insert ";;; DO NOT MODIFY THIS FILE\n")
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
610 (insert "(if (featurep '" sym "-autoloads)")
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
611 (insert " (error \"Already loaded\"))")
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
612 (goto-char (point-max))
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 169
diff changeset
613 (insert "\n(provide '" sym ")\n")))))
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 169
diff changeset
614
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 169
diff changeset
615 (defvar autoload-package-name nil)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
616
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
617 ;;;###autoload
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
618 (defun batch-update-directory ()
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
619 "Update the autoloads for the directory on the command line.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
620 Runs `update-file-autoloads' on each file in the given directory, and must
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
621 be used only with -batch, and kills XEmacs on completion."
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
622 (unless noninteractive
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
623 (error "batch-update-directory is to be used only with -batch"))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
624 (let ((defdir default-directory)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
625 (enable-local-eval nil)) ; Don't query in batch mode.
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
626 (dolist (arg command-line-args-left)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
627 (setq arg (expand-file-name arg defdir))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
628 (let ((generated-autoload-file (concat arg "/" autoload-file-name))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
629 (generated-custom-file (concat arg "/" cusload-file-name)))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
630 (when (file-exists-p generated-custom-file)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
631 (flet ((custom-put (symbol property value)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
632 (progn
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
633 (put symbol property value)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
634 ;; (message "Loading %s = %s"
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
635 ;; (symbol-name symbol)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
636 ;; (prin1-to-string value))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
637 (pushnew symbol customized-symbols))))
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
638 (load generated-custom-file nil t)))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
639 (cond
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
640 ((file-directory-p arg)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
641 (message "Updating autoloads in directory %s..." arg)
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
642 (update-autoloads-from-directory arg))
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
643 (t (error "No such file or directory: %s" arg)))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
644 (when autoload-do-custom-save
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
645 (autoload-save-customization)
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
646 (setq customized-symbols nil))
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 169
diff changeset
647 (fixup-autoload-buffer (concat (if autoload-package-name
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 169
diff changeset
648 autoload-package-name
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 169
diff changeset
649 (file-name-nondirectory arg))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
650 "-autoloads"))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
651 (save-some-buffers t))
169
15872534500d Import from CVS: tag r20-3b11
cvs
parents: 167
diff changeset
652 ;; (message "Done")
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
653 ;; (kill-emacs 0)
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 165
diff changeset
654 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 165
diff changeset
655 (setq command-line-args-left nil)))
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 155
diff changeset
656
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (provide 'autoload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;;; autoload.el ends here