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