(debugger-step-through): Make sure that stepping into the debugger's
[bpt/emacs.git] / lisp / emacs-lisp / autoload.el
CommitLineData
56eebc29 1;; autoload.el --- maintain autoloads in loaddefs.el
c0274f38 2
66dc9a0f 3;; Copyright (C) 1991,92,93,94,95,96,97, 2001,02,03,04
789b6186 4;; Free Software Foundation, Inc.
b578f267 5
5762abec 6;; Author: Roland McGrath <roland@gnu.org>
e9571d2a 7;; Keywords: maint
e5167999 8
b578f267
EN
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it 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.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to the
23;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; Boston, MA 02111-1307, USA.
0231f2dc 25
07b3798c 26;;; Commentary:
e41b2db1 27
00ee57f3 28;; This code helps GNU Emacs maintainers keep the loaddefs.el file up to
e41b2db1
ER
29;; date. It interprets magic cookies of the form ";;;###autoload" in
30;; lisp source files in various useful ways. To learn more, read the
31;; source; if you're going to use this, you'd better be able to.
32
e5167999
ER
33;;; Code:
34
b0daab9a 35(require 'lisp-mode) ;for `doc-string-elt' properties.
890df022 36(require 'help-fns) ;for help-add-fundoc-usage.
6826a134 37(eval-when-compile (require 'cl))
b0daab9a 38
0ceb5fe0
RS
39(defvar generated-autoload-file "loaddefs.el"
40 "*File \\[update-file-autoloads] puts autoloads into.
41A `.el' file can set this in its local variables section to make its
c8aca7d1
KH
42autoloads go somewhere else. The autoload file is assumed to contain a
43trailer starting with a FormFeed character.")
0ceb5fe0
RS
44
45(defconst generate-autoload-cookie ";;;###autoload"
46 "Magic comment indicating the following form should be autoloaded.
47Used by \\[update-file-autoloads]. This string should be
48meaningless to Lisp (e.g., a comment).
49
50This string is used:
51
52;;;###autoload
53\(defun function-to-be-autoloaded () ...)
54
55If this string appears alone on a line, the following form will be
56read and an autoload made for it. If there is further text on the line,
57that text will be copied verbatim to `generated-autoload-file'.")
58
59(defconst generate-autoload-section-header "\f\n;;;### "
2336b6a9 60 "String that marks the form at the start of a new file's autoload section.")
0ceb5fe0
RS
61
62(defconst generate-autoload-section-trailer "\n;;;***\n"
63 "String which indicates the end of the section of autoloads for a file.")
64
2336b6a9
KH
65(defconst generate-autoload-section-continuation ";;;;;; "
66 "String to add on each continuation of the section header form.")
67
0231f2dc 68(defun make-autoload (form file)
ceaa3695 69 "Turn FORM into an autoload or defvar for source file FILE.
e8139c11
SM
70Returns nil if FORM is not a special autoload form (i.e. a function definition
71or macro definition or a defcustom)."
72 (let ((car (car-safe form)) expand)
73 (cond
74 ;; For complex cases, try again on the macro-expansion.
75 ((and (memq car '(easy-mmode-define-global-mode
76 easy-mmode-define-minor-mode define-minor-mode))
77 (setq expand (let ((load-file-name file)) (macroexpand form)))
78 (eq (car expand) 'progn)
79 (memq :autoload-end expand))
80 (let ((end (memq :autoload-end expand)))
81 ;; Cut-off anything after the :autoload-end marker.
82 (setcdr end nil)
83 (cons 'progn
84 (mapcar (lambda (form) (make-autoload form file))
85 (cdr expand)))))
86
87 ;; For special function-like operators, use the `autoload' function.
88 ((memq car '(defun define-skeleton defmacro define-derived-mode
bec34fb0 89 define-compilation-mode
e8139c11
SM
90 define-generic-mode easy-mmode-define-minor-mode
91 easy-mmode-define-global-mode
74312ddc
CW
92 define-minor-mode defun* defmacro*))
93 (let* ((macrop (memq car '(defmacro defmacro*)))
e8139c11 94 (name (nth 1 form))
6826a134
SM
95 (args (case car
96 ((defun defmacro defun* defmacro*) (nth 2 form))
97 ((define-skeleton) '(&optional str arg))
bec34fb0
TTN
98 ((define-generic-mode define-derived-mode
99 define-compilation-mode) nil)
6826a134 100 (t)))
e8139c11
SM
101 (body (nthcdr (get car 'doc-string-elt) form))
102 (doc (if (stringp (car body)) (pop body))))
890df022
SM
103 (when (listp args)
104 ;; Add the usage form at the end where describe-function-1
105 ;; can recover it.
106 (setq doc (help-add-fundoc-usage doc args)))
e8139c11
SM
107 ;; `define-generic-mode' quotes the name, so take care of that
108 (list 'autoload (if (listp name) name (list 'quote name)) file doc
109 (or (and (memq car '(define-skeleton define-derived-mode
110 define-generic-mode
111 easy-mmode-define-global-mode
112 easy-mmode-define-minor-mode
113 define-minor-mode)) t)
114 (eq (car-safe (car body)) 'interactive))
115 (if macrop (list 'quote 'macro) nil))))
116
d49298d9 117 ;; Convert defcustom to less space-consuming data.
e8139c11
SM
118 ((eq car 'defcustom)
119 (let ((varname (car-safe (cdr-safe form)))
120 (init (car-safe (cdr-safe (cdr-safe form))))
121 (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))
d49298d9
MR
122 ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form)))))
123 )
124 `(progn
125 (defvar ,varname ,init ,doc)
126 (custom-autoload ',varname ,file))))
e8139c11
SM
127
128 ;; nil here indicates that this is not a special autoload form.
129 (t nil))))
0231f2dc 130
890df022
SM
131;; Forms which have doc-strings which should be printed specially.
132;; A doc-string-elt property of ELT says that (nth ELT FORM) is
133;; the doc-string in FORM.
134;; Those properties are now set in lisp-mode.el.
fc89daee 135
0231f2dc 136
72c19d97 137(defun autoload-trim-file-name (file)
8d3e5475 138 ;; Returns a relative file path for FILE
1eb0a345
RS
139 ;; starting from the directory that loaddefs.el is in.
140 ;; That is normally a directory in load-path,
141 ;; which means Emacs will be able to find FILE when it looks.
142 ;; Any extra directory names here would prevent finding the file.
72c19d97
RM
143 (setq file (expand-file-name file))
144 (file-relative-name file
1eb0a345 145 (file-name-directory generated-autoload-file)))
72c19d97 146
2336b6a9
KH
147(defun autoload-read-section-header ()
148 "Read a section header form.
149Since continuation lines have been marked as comments,
150we must copy the text of the form and remove those comment
151markers before we call `read'."
152 (save-match-data
153 (let ((beginning (point))
154 string)
155 (forward-line 1)
156 (while (looking-at generate-autoload-section-continuation)
157 (forward-line 1))
158 (setq string (buffer-substring beginning (point)))
159 (with-current-buffer (get-buffer-create " *autoload*")
160 (erase-buffer)
161 (insert string)
162 (goto-char (point-min))
163 (while (search-forward generate-autoload-section-continuation nil t)
164 (replace-match " "))
165 (goto-char (point-min))
166 (read (current-buffer))))))
167
4a3c5b3a
RS
168(defvar autoload-print-form-outbuf)
169
a8add29d 170(defun autoload-print-form (form)
4a3c5b3a
RS
171 "Print FORM such that `make-docfile' will find the docstrings.
172The variable `autoload-print-form-outbuf' specifies the buffer to
173put the output in."
a8add29d
SM
174 (cond
175 ;; If the form is a sequence, recurse.
176 ((eq (car form) 'progn) (mapcar 'autoload-print-form (cdr form)))
177 ;; Symbols at the toplevel are meaningless.
178 ((symbolp form) nil)
179 (t
4a3c5b3a
RS
180 (let ((doc-string-elt (get (car-safe form) 'doc-string-elt))
181 (outbuf autoload-print-form-outbuf))
a8add29d
SM
182 (if (and doc-string-elt (stringp (nth doc-string-elt form)))
183 ;; We need to hack the printing because the
184 ;; doc-string must be printed specially for
185 ;; make-docfile (sigh).
186 (let* ((p (nthcdr (1- doc-string-elt) form))
187 (elt (cdr p)))
188 (setcdr p nil)
189 (princ "\n(" outbuf)
190 (let ((print-escape-newlines t)
191 (print-escape-nonascii t))
7dab57b6
RS
192 (dolist (elt form)
193 (prin1 elt outbuf)
194 (princ " " outbuf)))
a8add29d
SM
195 (princ "\"\\\n" outbuf)
196 (let ((begin (with-current-buffer outbuf (point))))
197 (princ (substring (prin1-to-string (car elt)) 1)
198 outbuf)
199 ;; Insert a backslash before each ( that
200 ;; appears at the beginning of a line in
201 ;; the doc string.
202 (with-current-buffer outbuf
203 (save-excursion
890df022 204 (while (re-search-backward "\n[[(]" begin t)
a8add29d
SM
205 (forward-char 1)
206 (insert "\\"))))
207 (if (null (cdr elt))
208 (princ ")" outbuf)
209 (princ " " outbuf)
210 (princ (substring (prin1-to-string (cdr elt)) 1)
211 outbuf))
212 (terpri outbuf)))
213 (let ((print-escape-newlines t)
214 (print-escape-nonascii t))
215 (print form outbuf)))))))
216
a273d3e0
GM
217(defun autoload-ensure-default-file (file)
218 "Make sure that the autoload file FILE exists and if not create it."
219 (unless (file-exists-p file)
220 (write-region
221 (concat ";;; " (file-name-nondirectory file)
222 " --- automatically extracted autoloads\n"
223 ";;\n"
224 ";;; Code:\n\n"
225 "\f\n;; Local Variables:\n"
226 ";; version-control: never\n"
227 ";; no-byte-compile: t\n"
228 ";; no-update-autoloads: t\n"
229 ";; End:\n"
230 ";;; " (file-name-nondirectory file)
4994a50d 231 " ends here\n")
a273d3e0
GM
232 nil file))
233 file)
234
235(defun autoload-insert-section-header (outbuf autoloads load-name file time)
236 "Insert the section-header line,
237which lists the file name and which functions are in it, etc."
238 (insert generate-autoload-section-header)
239 (prin1 (list 'autoloads autoloads load-name
240 (if (stringp file) (autoload-trim-file-name file) file)
241 time)
242 outbuf)
243 (terpri outbuf)
244 ;; Break that line at spaces, to avoid very long lines.
245 ;; Make each sub-line into a comment.
246 (with-current-buffer outbuf
247 (save-excursion
248 (forward-line -1)
249 (while (not (eolp))
250 (move-to-column 64)
251 (skip-chars-forward "^ \n")
252 (or (eolp)
253 (insert "\n" generate-autoload-section-continuation))))))
254
0231f2dc
JB
255(defun generate-file-autoloads (file)
256 "Insert at point a loaddefs autoload section for FILE.
257autoloads are generated for defuns and defmacros in FILE
da8826b4 258marked by `generate-autoload-cookie' (which see).
0231f2dc
JB
259If FILE is being visited in a buffer, the contents of the buffer
260are used."
261 (interactive "fGenerate autoloads for file: ")
262 (let ((outbuf (current-buffer))
0231f2dc
JB
263 (autoloads-done '())
264 (load-name (let ((name (file-name-nondirectory file)))
a85e4d58 265 (if (string-match "\\.elc?\\(\\.\\|$\\)" name)
0231f2dc
JB
266 (substring name 0 (match-beginning 0))
267 name)))
268 (print-length nil)
72c19d97 269 (print-readably t) ; This does something in Lucid Emacs.
aa7ea8bd 270 (float-output-format nil)
0231f2dc 271 (done-any nil)
7e4263eb 272 (visited (get-file-buffer file))
0231f2dc 273 output-end)
daa37602
JB
274
275 ;; If the autoload section we create here uses an absolute
8d3e5475 276 ;; file name for FILE in its header, and then Emacs is installed
daa37602
JB
277 ;; under a different path on another system,
278 ;; `update-autoloads-here' won't be able to find the files to be
279 ;; autoloaded. So, if FILE is in the same directory or a
e5d77022 280 ;; subdirectory of the current buffer's directory, we'll make it
daa37602
JB
281 ;; relative to the current buffer's directory.
282 (setq file (expand-file-name file))
1265394f
RM
283 (let* ((source-truename (file-truename file))
284 (dir-truename (file-name-as-directory
285 (file-truename default-directory)))
286 (len (length dir-truename)))
287 (if (and (< len (length source-truename))
288 (string= dir-truename (substring source-truename 0 len)))
289 (setq file (substring source-truename len))))
daa37602 290
0231f2dc 291 (message "Generating autoloads for %s..." file)
6798a385
JB
292 (save-excursion
293 (unwind-protect
294 (progn
66fc2bf5
RM
295 (if visited
296 (set-buffer visited)
297 ;; It is faster to avoid visiting the file.
298 (set-buffer (get-buffer-create " *generate-autoload-file*"))
299 (kill-all-local-variables)
300 (erase-buffer)
b59c7256
RM
301 (setq buffer-undo-list t
302 buffer-read-only nil)
303 (emacs-lisp-mode)
66fc2bf5 304 (insert-file-contents file nil))
6798a385
JB
305 (save-excursion
306 (save-restriction
307 (widen)
308 (goto-char (point-min))
309 (while (not (eobp))
310 (skip-chars-forward " \t\n\f")
311 (cond
312 ((looking-at (regexp-quote generate-autoload-cookie))
313 (search-forward generate-autoload-cookie)
314 (skip-chars-forward " \t")
315 (setq done-any t)
9ed4d64f
RM
316 (if (eolp)
317 ;; Read the next form and make an autoload.
318 (let* ((form (prog1 (read (current-buffer))
a8add29d
SM
319 (or (bolp) (forward-line 1))))
320 (autoload (make-autoload form load-name)))
9ed4d64f
RM
321 (if autoload
322 (setq autoloads-done (cons (nth 1 form)
323 autoloads-done))
324 (setq autoload form))
4a3c5b3a
RS
325 (let ((autoload-print-form-outbuf outbuf))
326 (autoload-print-form autoload)))
a1506d29 327
a8add29d 328 ;; Copy the rest of the line to the output.
6e21af56
RM
329 (princ (buffer-substring
330 (progn
331 ;; Back up over whitespace, to preserve it.
332 (skip-chars-backward " \f\t")
333 (if (= (char-after (1+ (point))) ? )
334 ;; Eat one space.
335 (forward-char 1))
336 (point))
337 (progn (forward-line 1) (point)))
338 outbuf)))
72c19d97
RM
339 ((looking-at ";")
340 ;; Don't read the comment.
341 (forward-line 1))
342 (t
343 (forward-sexp 1)
344 (forward-line 1)))))))
6798a385
JB
345 (or visited
346 ;; We created this buffer, so we should kill it.
347 (kill-buffer (current-buffer)))
348 (set-buffer outbuf)
349 (setq output-end (point-marker))))
0231f2dc
JB
350 (if done-any
351 (progn
2336b6a9
KH
352 ;; Insert the section-header line
353 ;; which lists the file name and which functions are in it, etc.
a273d3e0
GM
354 (autoload-insert-section-header outbuf autoloads-done load-name file
355 (nth 5 (file-attributes file)))
72c19d97
RM
356 (insert ";;; Generated autoloads from "
357 (autoload-trim-file-name file) "\n")
0231f2dc
JB
358 (goto-char output-end)
359 (insert generate-autoload-section-trailer)))
360 (message "Generating autoloads for %s...done" file)))
e2b6138f 361\f
0231f2dc 362;;;###autoload
f7ed02ac 363(defun update-file-autoloads (file &optional save-after)
0231f2dc 364 "Update the autoloads for FILE in `generated-autoload-file'
a273d3e0 365\(which FILE might bind in its local variables).
f7ed02ac
RS
366If SAVE-AFTER is non-nil (which is always, when called interactively),
367save the buffer too.
368
369Return FILE if there was no autoload cookie in it, else nil."
370 (interactive "fUpdate autoloads for file: \np")
0231f2dc 371 (let ((load-name (let ((name (file-name-nondirectory file)))
a85e4d58 372 (if (string-match "\\.elc?\\(\\.\\|$\\)" name)
0231f2dc
JB
373 (substring name 0 (match-beginning 0))
374 name)))
d55e3ff0 375 (found nil)
a273d3e0
GM
376 (existing-buffer (get-file-buffer file))
377 (no-autoloads nil))
0231f2dc
JB
378 (save-excursion
379 ;; We want to get a value for generated-autoload-file from
380 ;; the local variables section if it's there.
b59c7256
RM
381 (if existing-buffer
382 (set-buffer existing-buffer))
9e3366e4
EZ
383 ;; We must read/write the file without any code conversion,
384 ;; but still decode EOLs.
385 (let ((coding-system-for-read 'raw-text))
68521d61 386 (set-buffer (find-file-noselect
a273d3e0
GM
387 (autoload-ensure-default-file
388 (expand-file-name generated-autoload-file
389 (expand-file-name "lisp"
390 source-directory)))))
9e3366e4
EZ
391 ;; This is to make generated-autoload-file have Unix EOLs, so
392 ;; that it is portable to all platforms.
393 (setq buffer-file-coding-system 'raw-text-unix))
0b33ec46
RS
394 (or (> (buffer-size) 0)
395 (error "Autoloads file %s does not exist" buffer-file-name))
396 (or (file-writable-p buffer-file-name)
397 (error "Autoloads file %s is not writable" buffer-file-name))
0231f2dc
JB
398 (save-excursion
399 (save-restriction
400 (widen)
401 (goto-char (point-min))
d55e3ff0
RM
402 ;; Look for the section for LOAD-NAME.
403 (while (and (not found)
404 (search-forward generate-autoload-section-header nil t))
2336b6a9 405 (let ((form (autoload-read-section-header)))
d55e3ff0
RM
406 (cond ((string= (nth 2 form) load-name)
407 ;; We found the section for this file.
408 ;; Check if it is up to date.
409 (let ((begin (match-beginning 0))
410 (last-time (nth 4 form))
411 (file-time (nth 5 (file-attributes file))))
412 (if (and (or (null existing-buffer)
413 (not (buffer-modified-p existing-buffer)))
414 (listp last-time) (= (length last-time) 2)
66dc9a0f 415 (not (time-less-p last-time file-time)))
d55e3ff0 416 (progn
d5aa62ec
RM
417 (if (interactive-p)
418 (message "\
419Autoload section for %s is up to date."
420 file))
d55e3ff0
RM
421 (setq found 'up-to-date))
422 (search-forward generate-autoload-section-trailer)
423 (delete-region begin (point))
424 (setq found t))))
425 ((string< load-name (nth 2 form))
426 ;; We've come to a section alphabetically later than
427 ;; LOAD-NAME. We assume the file is in order and so
428 ;; there must be no section for LOAD-NAME. We will
429 ;; insert one before the section here.
430 (goto-char (match-beginning 0))
72c19d97 431 (setq found 'new)))))
0f09bac6
RM
432 (or found
433 (progn
434 (setq found 'new)
435 ;; No later sections in the file. Put before the last page.
436 (goto-char (point-max))
5a161ab5 437 (search-backward "\f" nil t)))
72c19d97 438 (or (eq found 'up-to-date)
0f09bac6 439 (and (eq found 'new)
72c19d97
RM
440 ;; Check that FILE has any cookies before generating a
441 ;; new section for it.
442 (save-excursion
b59c7256
RM
443 (if existing-buffer
444 (set-buffer existing-buffer)
445 ;; It is faster to avoid visiting the file.
446 (set-buffer (get-buffer-create " *autoload-file*"))
447 (kill-all-local-variables)
448 (erase-buffer)
449 (setq buffer-undo-list t
450 buffer-read-only nil)
451 (emacs-lisp-mode)
452 (insert-file-contents file nil))
72c19d97 453 (save-excursion
b59c7256
RM
454 (save-restriction
455 (widen)
456 (goto-char (point-min))
457 (prog1
f0646ca0
RM
458 (if (re-search-forward
459 (concat "^" (regexp-quote
460 generate-autoload-cookie))
b59c7256
RM
461 nil t)
462 nil
463 (if (interactive-p)
75632953 464 (message "%s has no autoloads" file))
a273d3e0 465 (setq no-autoloads t)
b59c7256
RM
466 t)
467 (or existing-buffer
468 (kill-buffer (current-buffer))))))))
57cf354d 469 (generate-file-autoloads file))))
f7ed02ac 470 (and save-after
2336b6a9 471 (buffer-modified-p)
a273d3e0
GM
472 (save-buffer))
473
474 (if no-autoloads file))))
475
a273d3e0
GM
476(defun autoload-remove-section (begin)
477 (goto-char begin)
478 (search-forward generate-autoload-section-trailer)
479 (delete-region begin (point)))
0231f2dc
JB
480
481;;;###autoload
56eebc29 482(defun update-directory-autoloads (&rest dirs)
d08589bf 483 "\
3fbca58a 484Update loaddefs.el with all the current autoloads from DIRS, and no old ones.
56eebc29
RS
485This uses `update-file-autoloads' (which see) do its work.
486In an interactive call, you must give one argument, the name
487of a single directory. In a call from Lisp, you can supply multiple
488directories as separate arguments, but this usage is discouraged.
489
490The function does NOT recursively descend into subdirectories of the
491directory or directories specified."
b59c7256 492 (interactive "DUpdate autoloads from directory: ")
a85e4d58
SM
493 (let* ((files-re (let ((tmp nil))
494 (dolist (suf load-suffixes
495 (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))
496 (unless (string-match "\\.elc" suf) (push suf tmp)))))
497 (files (apply 'nconc
a273d3e0
GM
498 (mapcar (lambda (dir)
499 (directory-files (expand-file-name dir)
a85e4d58 500 t files-re))
a273d3e0
GM
501 dirs)))
502 (this-time (current-time))
503 (no-autoloads nil) ;files with no autoload cookies.
504 (autoloads-file
0e193890 505 (expand-file-name generated-autoload-file
a273d3e0
GM
506 (expand-file-name "lisp" source-directory)))
507 (top-dir (file-name-directory autoloads-file)))
508
509 (with-current-buffer
510 (find-file-noselect (autoload-ensure-default-file autoloads-file))
e2b6138f 511 (save-excursion
a273d3e0
GM
512
513 ;; Canonicalize file names and remove the autoload file itself.
514 (setq files (delete (autoload-trim-file-name buffer-file-name)
515 (mapcar 'autoload-trim-file-name files)))
516
b59c7256
RM
517 (goto-char (point-min))
518 (while (search-forward generate-autoload-section-header nil t)
2336b6a9 519 (let* ((form (autoload-read-section-header))
b59c7256 520 (file (nth 3 form)))
a273d3e0
GM
521 (cond ((and (consp file) (stringp (car file)))
522 ;; This is a list of files that have no autoload cookies.
523 ;; There shouldn't be more than one such entry.
524 ;; Remove the obsolete section.
525 (autoload-remove-section (match-beginning 0))
526 (let ((last-time (nth 4 form)))
527 (dolist (file file)
528 (let ((file-time (nth 5 (file-attributes file))))
529 (when (and file-time
66dc9a0f 530 (not (time-less-p last-time file-time)))
a273d3e0
GM
531 ;; file unchanged
532 (push file no-autoloads)
533 (setq files (delete file files)))))))
534 ((not (stringp file)))
3fbca58a 535 ((not (file-exists-p (expand-file-name file top-dir)))
b59c7256 536 ;; Remove the obsolete section.
a273d3e0
GM
537 (autoload-remove-section (match-beginning 0)))
538 ((equal (nth 4 form) (nth 5 (file-attributes file)))
539 ;; File hasn't changed.
540 nil)
b59c7256
RM
541 (t
542 (update-file-autoloads file)))
543 (setq files (delete file files)))))
a273d3e0
GM
544 ;; Elements remaining in FILES have no existing autoload sections yet.
545 (setq no-autoloads
546 (append no-autoloads
547 (delq nil (mapcar 'update-file-autoloads files))))
548 (when no-autoloads
000d9923
MR
549 ;; Sort them for better readability.
550 (setq no-autoloads (sort no-autoloads 'string<))
a273d3e0
GM
551 ;; Add the `no-autoloads' section.
552 (goto-char (point-max))
553 (search-backward "\f" nil t)
554 (autoload-insert-section-header
555 (current-buffer) nil nil no-autoloads this-time)
556 (insert generate-autoload-section-trailer))
557
b59c7256 558 (save-buffer))))
0231f2dc
JB
559
560;;;###autoload
561(defun batch-update-autoloads ()
b59c7256 562 "Update loaddefs.el autoloads in batch mode.
375d5635
JPW
563Calls `update-directory-autoloads' on the command line arguments."
564 (apply 'update-directory-autoloads command-line-args-left)
b59c7256 565 (setq command-line-args-left nil))
0231f2dc
JB
566
567(provide 'autoload)
ffd56f97 568
ab5796a9 569;;; arch-tag: 00244766-98f4-4767-bf42-8a22103441c6
c0274f38 570;;; autoload.el ends here