Mercurial > emacs
annotate lisp/emacs-lisp/autoload.el @ 2026:3514a9bf50c5
(electric-buffer-list): Handle any kind of event.
(Electric-buffer-menu-exit): Handle any key sequence.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 06 Mar 1993 06:05:12 +0000 |
parents | 3334e2489824 |
children | 2c7997f249eb |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
1 ;;; autoload.el --- maintain autoloads in loaddefs.el. |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
2 |
1884
4a8bc12e7017
(generate-file-autoloads): If no buffer was visiting FILE when we started,
Roland McGrath <roland@gnu.org>
parents:
1552
diff
changeset
|
3 ;;; Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. |
473 | 4 ;;; |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
5 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu> |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
6 ;; Keyword: internal |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
7 |
473 | 8 ;;; This program is free software; you can redistribute it and/or modify |
9 ;;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
10 ;;; the Free Software Foundation; either version 2, or (at your option) |
473 | 11 ;;; any later version. |
12 ;;; | |
13 ;;; This program is distributed in the hope that it will be useful, | |
14 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;;; GNU General Public License for more details. | |
17 ;;; | |
18 ;;; A copy of the GNU General Public License can be obtained from this | |
19 ;;; program's author (send electronic mail to roland@ai.mit.edu) or from | |
20 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA | |
21 ;;; 02139, USA. | |
22 ;;; | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
24 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
25 |
473 | 26 (defun make-autoload (form file) |
27 "Turn FORM, a defun or defmacro, into an autoload for source file FILE. | |
28 Returns nil if FORM is not a defun or defmacro." | |
29 (let ((car (car-safe form))) | |
30 (if (or (eq car 'defun) (eq car 'defmacro)) | |
31 (let (name doc macrop) | |
32 (setq macrop (eq car 'defmacro)) | |
33 (setq form (cdr form)) | |
34 (setq name (car form)) | |
35 ;; Ignore the arguments. | |
36 (setq form (cdr (cdr form))) | |
37 (setq doc (car form)) | |
38 (if (stringp doc) | |
39 (setq form (cdr form)) | |
40 (setq doc nil)) | |
41 (list 'autoload (list 'quote name) file doc | |
1552
f2901040a07b
* autoload.el (make-autoload): When creating an autoload
Jim Blandy <jimb@redhat.com>
parents:
1108
diff
changeset
|
42 (eq (car-safe (car form)) 'interactive) |
f2901040a07b
* autoload.el (make-autoload): When creating an autoload
Jim Blandy <jimb@redhat.com>
parents:
1108
diff
changeset
|
43 (if macrop (list 'quote 'macro) nil))) |
473 | 44 nil))) |
45 | |
46 (defconst generate-autoload-cookie ";;;###autoload" | |
47 "Magic comment that tells \\[update-file-autoloads] | |
48 to make the following form into an autoload. This string should be | |
49 meaningless to Lisp (e.g., a comment). | |
50 | |
51 This string is used: | |
52 | |
53 ;;;###autoload | |
54 \(defun function-to-be-autoloaded () ...) | |
55 | |
56 If this string appears alone on a line, the following form will be | |
57 read and an autoload made for it. If there is further text on the line, | |
58 that text will be copied verbatim to `generated-autoload-file'.") | |
59 | |
60 (defconst generate-autoload-section-header "\f\n;;;### " | |
61 "String inserted before the form identifying | |
62 the section of autoloads for a file.") | |
63 | |
64 (defconst generate-autoload-section-trailer "\n;;;***\n" | |
65 "String which indicates the end of the section of autoloads for a file.") | |
66 | |
727 | 67 ;;; Forms which have doc-strings which should be printed specially. |
68 ;;; A doc-string-elt property of ELT says that (nth ELT FORM) is | |
69 ;;; the doc-string in FORM. | |
70 ;;; | |
71 ;;; There used to be the following note here: | |
72 ;;; ;;; Note: defconst and defvar should NOT be marked in this way. | |
73 ;;; ;;; We don't want to produce defconsts and defvars that | |
74 ;;; ;;; make-docfile can grok, because then it would grok them twice, | |
75 ;;; ;;; once in foo.el (where they are given with ;;;###autoload) and | |
76 ;;; ;;; once in loaddefs.el. | |
77 ;;; | |
78 ;;; Counter-note: Yes, they should be marked in this way. | |
79 ;;; make-docfile only processes those files that are loaded into the | |
80 ;;; dumped Emacs, and those files should never have anything | |
81 ;;; autoloaded here. The above-feared problem only occurs with files | |
82 ;;; which have autoloaded entries *and* are processed by make-docfile; | |
83 ;;; there should be no such files. | |
84 | |
473 | 85 (put 'autoload 'doc-string-elt 3) |
727 | 86 (put 'defun 'doc-string-elt 3) |
87 (put 'defvar 'doc-string-elt 3) | |
88 (put 'defconst 'doc-string-elt 3) | |
89 (put 'defmacro 'doc-string-elt 3) | |
473 | 90 |
91 (defun generate-file-autoloads (file) | |
92 "Insert at point a loaddefs autoload section for FILE. | |
93 autoloads are generated for defuns and defmacros in FILE | |
94 marked by `generate-autoload-regexp' (which see). | |
95 If FILE is being visited in a buffer, the contents of the buffer | |
96 are used." | |
97 (interactive "fGenerate autoloads for file: ") | |
98 (let ((outbuf (current-buffer)) | |
99 (autoloads-done '()) | |
100 (load-name (let ((name (file-name-nondirectory file))) | |
101 (if (string-match "\\.elc?$" name) | |
102 (substring name 0 (match-beginning 0)) | |
103 name))) | |
104 (print-length nil) | |
105 (floating-output-format "%20e") | |
106 (done-any nil) | |
1884
4a8bc12e7017
(generate-file-autoloads): If no buffer was visiting FILE when we started,
Roland McGrath <roland@gnu.org>
parents:
1552
diff
changeset
|
107 (visited (get-file-buffer file)) |
473 | 108 output-end) |
727 | 109 |
110 ;; If the autoload section we create here uses an absolute | |
111 ;; pathname for FILE in its header, and then Emacs is installed | |
112 ;; under a different path on another system, | |
113 ;; `update-autoloads-here' won't be able to find the files to be | |
114 ;; autoloaded. So, if FILE is in the same directory or a | |
732 | 115 ;; subdirectory of the current buffer's directory, we'll make it |
727 | 116 ;; relative to the current buffer's directory. |
117 (setq file (expand-file-name file)) | |
118 (if (and (< (length default-directory) (length file)) | |
119 (string= default-directory | |
120 (substring file 0 (length default-directory)))) | |
121 (progn | |
122 (setq file (substring file (length default-directory))))) | |
123 | |
473 | 124 (message "Generating autoloads for %s..." file) |
1975
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
125 (save-excursion |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
126 (unwind-protect |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
127 (progn |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
128 (set-buffer (find-file-noselect file)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
129 (save-excursion |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
130 (save-restriction |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
131 (widen) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
132 (goto-char (point-min)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
133 (while (not (eobp)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
134 (skip-chars-forward " \t\n\f") |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
135 (cond |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
136 ((looking-at (regexp-quote generate-autoload-cookie)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
137 (search-forward generate-autoload-cookie) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
138 (skip-chars-forward " \t") |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
139 (setq done-any t) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
140 (if (eolp) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
141 ;; Read the next form and make an autoload. |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
142 (let* ((form (prog1 (read (current-buffer)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
143 (forward-line 1))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
144 (autoload (make-autoload form load-name)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
145 (doc-string-elt (get (car-safe form) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
146 'doc-string-elt))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
147 (if autoload |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
148 (setq autoloads-done (cons (nth 1 form) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
149 autoloads-done)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
150 (setq autoload form)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
151 (if (and doc-string-elt |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
152 (stringp (nth doc-string-elt autoload))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
153 ;; We need to hack the printing because the |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
154 ;; doc-string must be printed specially for |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
155 ;; make-docfile (sigh). |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
156 (let* ((p (nthcdr (1- doc-string-elt) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
157 autoload)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
158 (elt (cdr p))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
159 (setcdr p nil) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
160 (princ "\n(" outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
161 (mapcar (function (lambda (elt) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
162 (prin1 elt outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
163 (princ " " outbuf))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
164 autoload) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
165 (princ "\"\\\n" outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
166 (princ (substring |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
167 (prin1-to-string (car elt)) 1) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
168 outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
169 (if (null (cdr elt)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
170 (princ ")" outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
171 (princ " " outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
172 (princ (substring |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
173 (prin1-to-string (cdr elt)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
174 1) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
175 outbuf)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
176 (terpri outbuf)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
177 (print autoload outbuf))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
178 ;; Copy the rest of the line to the output. |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
179 (let ((begin (point))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
180 (forward-line 1) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
181 (princ (buffer-substring begin (point)) outbuf)))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
182 ((looking-at ";") |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
183 ;; Don't read the comment. |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
184 (forward-line 1)) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
185 (t |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
186 (forward-sexp 1) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
187 (forward-line 1))))))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
188 (or visited |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
189 ;; We created this buffer, so we should kill it. |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
190 (kill-buffer (current-buffer))) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
191 (set-buffer outbuf) |
3334e2489824
* autoload.el (generate-file-autoloads): Add another
Jim Blandy <jimb@redhat.com>
parents:
1884
diff
changeset
|
192 (setq output-end (point-marker)))) |
473 | 193 (if done-any |
194 (progn | |
195 (insert generate-autoload-section-header) | |
196 (prin1 (list 'autoloads autoloads-done load-name file | |
197 (nth 5 (file-attributes file))) | |
198 outbuf) | |
199 (terpri outbuf) | |
200 (insert ";;; Generated autoloads from " file "\n") | |
201 (goto-char output-end) | |
202 (insert generate-autoload-section-trailer))) | |
203 (message "Generating autoloads for %s...done" file))) | |
204 | |
205 (defconst generated-autoload-file "loaddefs.el" | |
206 "*File \\[update-file-autoloads] puts autoloads into. | |
207 A .el file can set this in its local variables section to make its | |
208 autoloads go somewhere else.") | |
209 | |
210 ;;;###autoload | |
211 (defun update-file-autoloads (file) | |
212 "Update the autoloads for FILE in `generated-autoload-file' | |
213 \(which FILE might bind in its local variables)." | |
214 (interactive "fUpdate autoloads for file: ") | |
215 (let ((load-name (let ((name (file-name-nondirectory file))) | |
216 (if (string-match "\\.elc?$" name) | |
217 (substring name 0 (match-beginning 0)) | |
218 name))) | |
219 (done nil) | |
220 (existing-buffer (get-file-buffer file))) | |
221 (save-excursion | |
222 ;; We want to get a value for generated-autoload-file from | |
223 ;; the local variables section if it's there. | |
224 (set-buffer (find-file-noselect file)) | |
225 (set-buffer (find-file-noselect generated-autoload-file)) | |
226 (save-excursion | |
227 (save-restriction | |
228 (widen) | |
229 (goto-char (point-min)) | |
230 (while (search-forward generate-autoload-section-header nil t) | |
231 (let ((form (condition-case () | |
232 (read (current-buffer)) | |
233 (end-of-file nil)))) | |
234 (if (string= (nth 2 form) load-name) | |
235 (let ((begin (match-beginning 0)) | |
236 (last-time (nth 4 form)) | |
237 (file-time (nth 5 (file-attributes file)))) | |
238 (if (and (or (null existing-buffer) | |
239 (not (buffer-modified-p existing-buffer))) | |
240 (listp last-time) (= (length last-time) 2) | |
241 (or (> (car last-time) (car file-time)) | |
242 (and (= (car last-time) (car file-time)) | |
243 (>= (nth 1 last-time) | |
244 (nth 1 file-time))))) | |
245 (message "Autoload section for %s is up to date." | |
246 file) | |
247 (search-forward generate-autoload-section-trailer) | |
248 (delete-region begin (point)) | |
249 (generate-file-autoloads file)) | |
250 (setq done t)))))) | |
251 (if done | |
252 () | |
253 ;; Have the user tell us where to put the section. | |
254 (save-window-excursion | |
255 (switch-to-buffer (current-buffer)) | |
256 (with-output-to-temp-buffer "*Help*" | |
257 (princ (substitute-command-keys | |
258 (format "\ | |
259 Move point to where the autoload section | |
260 for %s should be inserted. | |
261 Then do \\[exit-recursive-edit]." | |
262 file)))) | |
1108 | 263 (recursive-edit) |
264 (beginning-of-line)) | |
473 | 265 (generate-file-autoloads file))) |
266 (if (and (null existing-buffer) | |
267 (setq existing-buffer (get-file-buffer file))) | |
268 (kill-buffer existing-buffer))))) | |
269 | |
270 ;;;###autoload | |
271 (defun update-autoloads-here () | |
272 "Update the sections of the current buffer generated by | |
273 \\[update-file-autoloads]." | |
274 (interactive) | |
275 (let ((generated-autoload-file (buffer-file-name))) | |
276 (save-excursion | |
277 (goto-char (point-min)) | |
278 (while (search-forward generate-autoload-section-header nil t) | |
279 (let* ((form (condition-case () | |
280 (read (current-buffer)) | |
281 (end-of-file nil))) | |
282 (file (nth 3 form))) | |
283 (if (and (stringp file) | |
284 (or (get-file-buffer file) | |
285 (file-exists-p file))) | |
286 () | |
287 (setq file (if (y-or-n-p (format "Library \"%s\" (load \ | |
288 file \"%s\") doesn't exist. Remove its autoload section? " | |
289 (nth 2 form) file)) | |
290 t | |
291 (condition-case () | |
292 (read-file-name (format "Find \"%s\" load file: " | |
293 (nth 2 form)) | |
294 nil nil t) | |
295 (quit nil))))) | |
296 (if file | |
297 (let ((begin (match-beginning 0))) | |
298 (search-forward generate-autoload-section-trailer) | |
299 (delete-region begin (point)))) | |
300 (if (stringp file) | |
301 (generate-file-autoloads file))))))) | |
302 | |
303 ;;;###autoload | |
304 (defun update-directory-autoloads (dir) | |
305 "Run \\[update-file-autoloads] on each .el file in DIR." | |
306 (interactive "DUpdate autoloads for directory: ") | |
307 (mapcar 'update-file-autoloads | |
308 (directory-files dir nil "\\.el$"))) | |
309 | |
310 ;;;###autoload | |
311 (defun batch-update-autoloads () | |
312 "Update the autoloads for the files or directories on the command line. | |
313 Runs \\[update-file-autoloads] on files and \\[update-directory-autoloads] | |
314 on directories. Must be used only with -batch, and kills Emacs on completion. | |
315 Each file will be processed even if an error occurred previously. | |
648 | 316 For example, invoke \"emacs -batch -f batch-update-autoloads *.el\"" |
473 | 317 (if (not noninteractive) |
318 (error "batch-update-file-autoloads is to be used only with -batch")) | |
319 (let ((lost nil) | |
320 (args command-line-args-left)) | |
321 (while args | |
322 (catch 'file | |
323 (condition-case lossage | |
324 (if (file-directory-p (expand-file-name (car args))) | |
325 (update-directory-autoloads (car args)) | |
326 (update-file-autoloads (car args))) | |
327 (error (progn (message ">>Error processing %s: %s" | |
328 (car args) lossage) | |
329 (setq lost t) | |
330 (throw 'file nil))))) | |
331 (setq args (cdr args))) | |
332 (save-some-buffers t) | |
333 (message "Done") | |
334 (kill-emacs (if lost 1 0)))) | |
335 | |
336 (provide 'autoload) | |
648 | 337 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
648
diff
changeset
|
338 ;;; autoload.el ends here |