* doc/lispref/customize.texi (Custom Themes): Clarify .el preference.
[emacs.git] / lisp / emacs-lisp / autoload.el
blob92ad6155b5392fe4209f42e80dec69f6695d8a21
1 ;; autoload.el --- maintain autoloads in loaddefs.el -*- lexical-binding: t -*-
3 ;; Copyright (C) 1991-1997, 2001-2018 Free Software Foundation, Inc.
5 ;; Author: Roland McGrath <roland@gnu.org>
6 ;; Keywords: maint
7 ;; Package: emacs
9 ;; This file is part of GNU Emacs.
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 3 of the License, or
14 ;; (at your option) any later version.
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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; This code helps GNU Emacs maintainers keep the loaddefs.el file up to
27 ;; date. It interprets magic cookies of the form ";;;###autoload" in
28 ;; lisp source files in various useful ways. To learn more, read the
29 ;; source; if you're going to use this, you'd better be able to.
31 ;;; Code:
33 (require 'lisp-mode) ;for `doc-string-elt' properties.
34 (require 'lisp-mnt)
35 (eval-when-compile (require 'cl-lib))
37 (defvar generated-autoload-file nil
38 "File into which to write autoload definitions.
39 A Lisp file can set this in its local variables section to make
40 its autoloads go somewhere else.
42 If this is a relative file name, the directory is determined as
43 follows:
44 - If a Lisp file defined `generated-autoload-file' as a
45 file-local variable, use its containing directory.
46 - Otherwise use the \"lisp\" subdirectory of `source-directory'.
48 The autoload file is assumed to contain a trailer starting with a
49 FormFeed character.")
50 ;;;###autoload
51 (put 'generated-autoload-file 'safe-local-variable 'stringp)
53 (defvar generated-autoload-load-name nil
54 "Load name for `autoload' statements generated from autoload cookies.
55 If nil, this defaults to the file name, sans extension.
56 Typically, you need to set this when the directory containing the file
57 is not in `load-path'.
58 This also affects the generated cus-load.el file.")
59 ;;;###autoload
60 (put 'generated-autoload-load-name 'safe-local-variable 'stringp)
62 ;; This feels like it should be a defconst, but MH-E sets it to
63 ;; ";;;###mh-autoload" for the autoloads that are to go into mh-loaddefs.el.
64 (defvar generate-autoload-cookie ";;;###autoload"
65 "Magic comment indicating the following form should be autoloaded.
66 Used by \\[update-file-autoloads]. This string should be
67 meaningless to Lisp (e.g., a comment).
69 This string is used:
71 \;;;###autoload
72 \(defun function-to-be-autoloaded () ...)
74 If this string appears alone on a line, the following form will be
75 read and an autoload made for it. If there is further text on the line,
76 that text will be copied verbatim to `generated-autoload-file'.")
78 (defvar autoload-excludes nil
79 "If non-nil, list of absolute file names not to scan for autoloads.")
81 (defconst generate-autoload-section-header "\f\n;;;### "
82 "String that marks the form at the start of a new file's autoload section.")
84 (defconst generate-autoload-section-trailer "\n;;;***\n"
85 "String which indicates the end of the section of autoloads for a file.")
87 (defconst generate-autoload-section-continuation ";;;;;; "
88 "String to add on each continuation of the section header form.")
90 ;; In some ways it would be nicer to use a value that is recognizably
91 ;; not a time-value, eg t, but that can cause issues if an older Emacs
92 ;; that does not expect non-time-values loads the file.
93 (defconst autoload--non-timestamp '(0 0 0 0)
94 "Value to insert when `autoload-timestamps' is nil.")
96 (defvar autoload-timestamps nil ; experimental, see bug#22213
97 "Non-nil means insert a timestamp for each input file into the output.
98 We use these in incremental updates of the output file to decide
99 if we need to rescan an input file. If you set this to nil,
100 then we use the timestamp of the output file instead. As a result:
101 - for fixed inputs, the output will be the same every time
102 - incremental updates of the output file might not be correct if:
103 i) the timestamp of the output file cannot be trusted (at least
104 relative to that of the input files)
105 ii) any of the input files can be modified during the time it takes
106 to create the output
107 iii) only a subset of the input files are scanned
108 These issues are unlikely to happen in practice, and would arguably
109 represent bugs in the build system. Item iii) will happen if you
110 use a command like `update-file-autoloads', though, since it only
111 checks a single input file.")
113 (defvar autoload-modified-buffers) ;Dynamically scoped var.
115 (defun make-autoload (form file &optional expansion)
116 "Turn FORM into an autoload or defvar for source file FILE.
117 Returns nil if FORM is not a special autoload form (i.e. a function definition
118 or macro definition or a defcustom).
119 If EXPANSION is non-nil, we're processing the macro expansion of an
120 expression, in which case we want to handle forms differently."
121 (let ((car (car-safe form)) expand)
122 (cond
123 ((and expansion (eq car 'defalias))
124 (pcase-let*
125 ((`(,_ ,_ ,arg . ,rest) form)
126 ;; `type' is non-nil if it defines a macro.
127 ;; `fun' is the function part of `arg' (defaults to `arg').
128 ((or (and (or `(cons 'macro ,fun) `'(macro . ,fun)) (let type t))
129 (and (let fun arg) (let type nil)))
130 arg)
131 ;; `lam' is the lambda expression in `fun' (or nil if not
132 ;; recognized).
133 (lam (if (memq (car-safe fun) '(quote function)) (cadr fun)))
134 ;; `args' is the list of arguments (or t if not recognized).
135 ;; `body' is the body of `lam' (or t if not recognized).
136 ((or `(lambda ,args . ,body)
137 (and (let args t) (let body t)))
138 lam)
139 ;; Get the `doc' from `body' or `rest'.
140 (doc (cond ((stringp (car-safe body)) (car body))
141 ((stringp (car-safe rest)) (car rest))))
142 ;; Look for an interactive spec.
143 (interactive (pcase body
144 ((or `((interactive . ,_) . ,_)
145 `(,_ (interactive . ,_) . ,_))
146 t))))
147 ;; Add the usage form at the end where describe-function-1
148 ;; can recover it.
149 (when (listp args) (setq doc (help-add-fundoc-usage doc args)))
150 ;; (message "autoload of %S" (nth 1 form))
151 `(autoload ,(nth 1 form) ,file ,doc ,interactive ,type)))
153 ((and expansion (memq car '(progn prog1)))
154 (let ((end (memq :autoload-end form)))
155 (when end ;Cut-off anything after the :autoload-end marker.
156 (setq form (copy-sequence form))
157 (setcdr (memq :autoload-end form) nil))
158 (let ((exps (delq nil (mapcar (lambda (form)
159 (make-autoload form file expansion))
160 (cdr form)))))
161 (when exps (cons 'progn exps)))))
163 ;; For complex cases, try again on the macro-expansion.
164 ((and (memq car '(easy-mmode-define-global-mode define-global-minor-mode
165 define-globalized-minor-mode defun defmacro
166 easy-mmode-define-minor-mode define-minor-mode
167 define-inline cl-defun cl-defmacro cl-defgeneric
168 pcase-defmacro))
169 (macrop car)
170 (setq expand (let ((load-file-name file)) (macroexpand form)))
171 (memq (car expand) '(progn prog1 defalias)))
172 (make-autoload expand file 'expansion)) ;Recurse on the expansion.
174 ;; For special function-like operators, use the `autoload' function.
175 ((memq car '(define-skeleton define-derived-mode
176 define-compilation-mode define-generic-mode
177 easy-mmode-define-global-mode define-global-minor-mode
178 define-globalized-minor-mode
179 easy-mmode-define-minor-mode define-minor-mode
180 cl-defun defun* cl-defmacro defmacro*
181 define-overloadable-function))
182 (let* ((macrop (memq car '(defmacro cl-defmacro defmacro*)))
183 (name (nth 1 form))
184 (args (pcase car
185 ((or `defun `defmacro
186 `defun* `defmacro* `cl-defun `cl-defmacro
187 `define-overloadable-function)
188 (nth 2 form))
189 (`define-skeleton '(&optional str arg))
190 ((or `define-generic-mode `define-derived-mode
191 `define-compilation-mode)
192 nil)
193 (_ t)))
194 (body (nthcdr (or (function-get car 'doc-string-elt) 3) form))
195 (doc (if (stringp (car body)) (pop body))))
196 ;; Add the usage form at the end where describe-function-1
197 ;; can recover it.
198 (when (listp args) (setq doc (help-add-fundoc-usage doc args)))
199 ;; `define-generic-mode' quotes the name, so take care of that
200 `(autoload ,(if (listp name) name (list 'quote name))
201 ,file ,doc
202 ,(or (and (memq car '(define-skeleton define-derived-mode
203 define-generic-mode
204 easy-mmode-define-global-mode
205 define-global-minor-mode
206 define-globalized-minor-mode
207 easy-mmode-define-minor-mode
208 define-minor-mode))
210 (eq (car-safe (car body)) 'interactive))
211 ,(if macrop ''macro nil))))
213 ;; For defclass forms, use `eieio-defclass-autoload'.
214 ((eq car 'defclass)
215 (let ((name (nth 1 form))
216 (superclasses (nth 2 form))
217 (doc (nth 4 form)))
218 (list 'eieio-defclass-autoload (list 'quote name)
219 (list 'quote superclasses) file doc)))
221 ;; Convert defcustom to less space-consuming data.
222 ((eq car 'defcustom)
223 (let ((varname (car-safe (cdr-safe form)))
224 (init (car-safe (cdr-safe (cdr-safe form))))
225 (doc (car-safe (cdr-safe (cdr-safe (cdr-safe form)))))
226 ;; (rest (cdr-safe (cdr-safe (cdr-safe (cdr-safe form)))))
228 `(progn
229 (defvar ,varname ,init ,doc)
230 (custom-autoload ',varname ,file
231 ,(condition-case nil
232 (null (cadr (memq :set form)))
233 (error nil))))))
235 ((eq car 'defgroup)
236 ;; In Emacs this is normally handled separately by cus-dep.el, but for
237 ;; third party packages, it can be convenient to explicitly autoload
238 ;; a group.
239 (let ((groupname (nth 1 form)))
240 `(let ((loads (get ',groupname 'custom-loads)))
241 (if (member ',file loads) nil
242 (put ',groupname 'custom-loads (cons ',file loads))))))
244 ;; When processing a macro expansion, any expression
245 ;; before a :autoload-end should be included. These are typically (put
246 ;; 'fun 'prop val) and things like that.
247 ((and expansion (consp form)) form)
249 ;; nil here indicates that this is not a special autoload form.
250 (t nil))))
252 ;; Forms which have doc-strings which should be printed specially.
253 ;; A doc-string-elt property of ELT says that (nth ELT FORM) is
254 ;; the doc-string in FORM.
255 ;; Those properties are now set in lisp-mode.el.
257 (defun autoload-find-generated-file ()
258 "Visit the autoload file for the current buffer, and return its buffer."
259 (let ((enable-local-variables :safe)
260 (enable-local-eval nil)
261 (delay-mode-hooks t)
262 (file (autoload-generated-file)))
263 ;; We used to use `raw-text' to read this file, but this causes
264 ;; problems when the file contains non-ASCII characters.
265 (with-current-buffer (find-file-noselect
266 (autoload-ensure-file-writeable file))
267 (if (zerop (buffer-size)) (insert (autoload-rubric file nil t)))
268 (current-buffer))))
270 (defun autoload-generated-file ()
271 "Return `generated-autoload-file' as an absolute name.
272 If local to the current buffer, expand using the default directory;
273 otherwise, using `source-directory'/lisp."
274 (expand-file-name generated-autoload-file
275 ;; File-local settings of generated-autoload-file should
276 ;; be interpreted relative to the file's location,
277 ;; of course.
278 (if (not (local-variable-p 'generated-autoload-file))
279 (expand-file-name "lisp" source-directory))))
282 (defun autoload-read-section-header ()
283 "Read a section header form.
284 Since continuation lines have been marked as comments,
285 we must copy the text of the form and remove those comment
286 markers before we call `read'."
287 (save-match-data
288 (let ((beginning (point))
289 string)
290 (forward-line 1)
291 (while (looking-at generate-autoload-section-continuation)
292 (forward-line 1))
293 (setq string (buffer-substring beginning (point)))
294 (with-current-buffer (get-buffer-create " *autoload*")
295 (erase-buffer)
296 (insert string)
297 (goto-char (point-min))
298 (while (search-forward generate-autoload-section-continuation nil t)
299 (replace-match " "))
300 (goto-char (point-min))
301 (read (current-buffer))))))
303 (defvar autoload-print-form-outbuf nil
304 "Buffer which gets the output of `autoload-print-form'.")
306 (defun autoload-print-form (form)
307 "Print FORM such that `make-docfile' will find the docstrings.
308 The variable `autoload-print-form-outbuf' specifies the buffer to
309 put the output in."
310 (cond
311 ;; If the form is a sequence, recurse.
312 ((eq (car form) 'progn) (mapcar #'autoload-print-form (cdr form)))
313 ;; Symbols at the toplevel are meaningless.
314 ((symbolp form) nil)
316 (let ((doc-string-elt (function-get (car-safe form) 'doc-string-elt))
317 (outbuf autoload-print-form-outbuf))
318 (if (and doc-string-elt (stringp (nth doc-string-elt form)))
319 ;; We need to hack the printing because the
320 ;; doc-string must be printed specially for
321 ;; make-docfile (sigh).
322 (let* ((p (nthcdr (1- doc-string-elt) form))
323 (elt (cdr p)))
324 (setcdr p nil)
325 (princ "\n(" outbuf)
326 (let ((print-escape-newlines t)
327 (print-quoted t)
328 (print-escape-nonascii t))
329 (dolist (elt form)
330 (prin1 elt outbuf)
331 (princ " " outbuf)))
332 (princ "\"\\\n" outbuf)
333 (let ((begin (with-current-buffer outbuf (point))))
334 (princ (substring (prin1-to-string (car elt)) 1)
335 outbuf)
336 ;; Insert a backslash before each ( that
337 ;; appears at the beginning of a line in
338 ;; the doc string.
339 (with-current-buffer outbuf
340 (save-excursion
341 (while (re-search-backward "\n[[(]" begin t)
342 (forward-char 1)
343 (insert "\\"))))
344 (if (null (cdr elt))
345 (princ ")" outbuf)
346 (princ " " outbuf)
347 (princ (substring (prin1-to-string (cdr elt)) 1)
348 outbuf))
349 (terpri outbuf)))
350 (let ((print-escape-newlines t)
351 (print-quoted t)
352 (print-escape-nonascii t))
353 (print form outbuf)))))))
355 (defun autoload-rubric (file &optional type feature)
356 "Return a string giving the appropriate autoload rubric for FILE.
357 TYPE (default \"autoloads\") is a string stating the type of
358 information contained in FILE. TYPE \"package\" acts like the default,
359 but adds an extra line to the output to modify `load-path'.
361 If FEATURE is non-nil, FILE will provide a feature. FEATURE may
362 be a string naming the feature, otherwise it will be based on
363 FILE's name."
364 (let ((basename (file-name-nondirectory file))
365 (lp (if (equal type "package") (setq type "autoloads"))))
366 (concat ";;; " basename
367 " --- automatically extracted " (or type "autoloads") "\n"
368 ";;\n"
369 ";;; Code:\n\n"
370 (if lp
371 ;; `load-path' should contain only directory names.
372 "(add-to-list 'load-path (directory-file-name
373 (or (file-name-directory #$) (car load-path))))\n\n")
374 "\f\n"
375 ;; This is used outside of autoload.el, eg cus-dep, finder.
376 (if feature
377 (format "(provide '%s)\n"
378 (if (stringp feature) feature
379 (file-name-sans-extension basename))))
380 ";; Local Variables:\n"
381 ";; version-control: never\n"
382 ";; no-byte-compile: t\n"
383 ";; no-update-autoloads: t\n"
384 ";; coding: utf-8\n"
385 ";; End:\n"
386 ";;; " basename
387 " ends here\n")))
389 (defvar autoload-ensure-writable nil
390 "Non-nil means `autoload-find-generated-file' makes existing file writable.")
391 ;; Just in case someone tries to get you to overwrite a file that you
392 ;; don't want to.
393 ;;;###autoload
394 (put 'autoload-ensure-writable 'risky-local-variable t)
396 (defun autoload-ensure-file-writeable (file)
397 ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile,
398 ;; which was designed to handle CVSREAD=1 and equivalent.
399 (and autoload-ensure-writable
400 (file-exists-p file)
401 (let ((modes (file-modes file)))
402 (if (zerop (logand modes #o0200))
403 ;; Ignore any errors here, and let subsequent attempts
404 ;; to write the file raise any real error.
405 (ignore-errors (set-file-modes file (logior modes #o0200))))))
406 file)
408 (defun autoload-insert-section-header (outbuf autoloads load-name file time)
409 "Insert the section-header line,
410 which lists the file name and which functions are in it, etc."
411 ;; (cl-assert ;Make sure we don't insert it in the middle of another section.
412 ;; (save-excursion
413 ;; (or (not (re-search-backward
414 ;; (concat "\\("
415 ;; (regexp-quote generate-autoload-section-header)
416 ;; "\\)\\|\\("
417 ;; (regexp-quote generate-autoload-section-trailer)
418 ;; "\\)")
419 ;; nil t))
420 ;; (match-end 2))))
421 (insert generate-autoload-section-header)
422 (prin1 `(autoloads ,autoloads ,load-name ,file ,time)
423 outbuf)
424 (terpri outbuf)
425 ;; Break that line at spaces, to avoid very long lines.
426 ;; Make each sub-line into a comment.
427 (with-current-buffer outbuf
428 (save-excursion
429 (forward-line -1)
430 (while (not (eolp))
431 (move-to-column 64)
432 (skip-chars-forward "^ \n")
433 (or (eolp)
434 (insert "\n" generate-autoload-section-continuation))))))
436 (defun autoload-find-file (file)
437 "Fetch file and put it in a temp buffer. Return the buffer."
438 ;; It is faster to avoid visiting the file.
439 (setq file (expand-file-name file))
440 (with-current-buffer (get-buffer-create " *autoload-file*")
441 (kill-all-local-variables)
442 (erase-buffer)
443 (setq buffer-undo-list t
444 buffer-read-only nil)
445 (delay-mode-hooks (emacs-lisp-mode))
446 (setq default-directory (file-name-directory file))
447 (insert-file-contents file nil)
448 (let ((enable-local-variables :safe)
449 (enable-local-eval nil))
450 (hack-local-variables))
451 (current-buffer)))
453 (defvar no-update-autoloads nil
454 "File local variable to prevent scanning this file for autoload cookies.")
456 (defun autoload-file-load-name (file)
457 "Compute the name that will be used to load FILE."
458 ;; OUTFILE should be the name of the global loaddefs.el file, which
459 ;; is expected to be at the root directory of the files we're
460 ;; scanning for autoloads and will be in the `load-path'.
461 (let* ((outfile (default-value 'generated-autoload-file))
462 (name (file-relative-name file (file-name-directory outfile)))
463 (names '())
464 (dir (file-name-directory outfile)))
465 ;; If `name' has directory components, only keep the
466 ;; last few that are really needed.
467 (while name
468 (setq name (directory-file-name name))
469 (push (file-name-nondirectory name) names)
470 (setq name (file-name-directory name)))
471 (while (not name)
472 (cond
473 ((null (cdr names)) (setq name (car names)))
474 ((file-exists-p (expand-file-name "subdirs.el" dir))
475 ;; FIXME: here we only check the existence of subdirs.el,
476 ;; without checking its content. This makes it generate wrong load
477 ;; names for cases like lisp/term which is not added to load-path.
478 (setq dir (expand-file-name (pop names) dir)))
479 (t (setq name (mapconcat #'identity names "/")))))
480 (if (string-match "\\.elc?\\(\\.\\|\\'\\)" name)
481 (substring name 0 (match-beginning 0))
482 name)))
484 (defun generate-file-autoloads (file)
485 "Insert at point a loaddefs autoload section for FILE.
486 Autoloads are generated for defuns and defmacros in FILE
487 marked by `generate-autoload-cookie' (which see).
488 If FILE is being visited in a buffer, the contents of the buffer
489 are used.
490 Return non-nil in the case where no autoloads were added at point."
491 (interactive "fGenerate autoloads for file: ")
492 (let ((generated-autoload-file buffer-file-name))
493 (autoload-generate-file-autoloads file (current-buffer))))
495 (defvar autoload-compute-prefixes t
496 "If non-nil, autoload will add code to register the prefixes used in a file.
497 Standard prefixes won't be registered anyway. I.e. if a file \"foo.el\" defines
498 variables or functions that use \"foo-\" as prefix, that will not be registered.
499 But all other prefixes will be included.")
500 (put 'autoload-compute-prefixes 'safe #'booleanp)
502 (defconst autoload-def-prefixes-max-entries 5
503 "Target length of the list of definition prefixes per file.
504 If set too small, the prefixes will be too generic (i.e. they'll use little
505 memory, we'll end up looking in too many files when we need a particular
506 prefix), and if set too large, they will be too specific (i.e. they will
507 cost more memory use).")
509 (defconst autoload-def-prefixes-max-length 12
510 "Target size of definition prefixes.
511 Don't try to split prefixes that are already longer than that.")
513 (require 'radix-tree)
515 (defun autoload--make-defs-autoload (defs file)
517 ;; Remove the defs that obey the rule that file foo.el (or
518 ;; foo-mode.el) uses "foo-" as prefix.
519 ;; FIXME: help--symbol-completion-table still doesn't know how to use
520 ;; the rule that file foo.el (or foo-mode.el) uses "foo-" as prefix.
521 ;;(let ((prefix
522 ;; (concat (substring file 0 (string-match "-mode\\'" file)) "-")))
523 ;; (dolist (def (prog1 defs (setq defs nil)))
524 ;; (unless (string-prefix-p prefix def)
525 ;; (push def defs))))
527 ;; Then compute a small set of prefixes that cover all the
528 ;; remaining definitions.
529 (let* ((tree (let ((tree radix-tree-empty))
530 (dolist (def defs)
531 (setq tree (radix-tree-insert tree def t)))
532 tree))
533 (prefixes nil))
534 ;; Get the root prefixes, that we should include in any case.
535 (radix-tree-iter-subtrees
536 tree (lambda (prefix subtree)
537 (push (cons prefix subtree) prefixes)))
538 ;; In some cases, the root prefixes are too short, e.g. if you define
539 ;; "cc-helper" and "c-mode", you'll get "c" in the root prefixes.
540 (dolist (pair (prog1 prefixes (setq prefixes nil)))
541 (let ((s (car pair)))
542 (if (or (and (> (length s) 2) ; Long enough!
543 ;; But don't use "def" from deffoo-pkg-thing.
544 (not (string= "def" s)))
545 (string-match ".[[:punct:]]\\'" s) ;A real (tho short) prefix?
546 (radix-tree-lookup (cdr pair) "")) ;Nothing to expand!
547 (push pair prefixes) ;Keep it as is.
548 (radix-tree-iter-subtrees
549 (cdr pair) (lambda (prefix subtree)
550 (push (cons (concat s prefix) subtree) prefixes))))))
551 ;; FIXME: The expansions done below are mostly pointless, such as
552 ;; for `yenc', where we replace "yenc-" with an exhaustive list (5
553 ;; elements).
554 ;; (while
555 ;; (let ((newprefixes nil)
556 ;; (changes nil))
557 ;; (dolist (pair prefixes)
558 ;; (let ((prefix (car pair)))
559 ;; (if (or (> (length prefix) autoload-def-prefixes-max-length)
560 ;; (radix-tree-lookup (cdr pair) ""))
561 ;; ;; No point splitting it any further.
562 ;; (push pair newprefixes)
563 ;; (setq changes t)
564 ;; (radix-tree-iter-subtrees
565 ;; (cdr pair) (lambda (sprefix subtree)
566 ;; (push (cons (concat prefix sprefix) subtree)
567 ;; newprefixes))))))
568 ;; (and changes
569 ;; (<= (length newprefixes)
570 ;; autoload-def-prefixes-max-entries)
571 ;; (let ((new nil)
572 ;; (old nil))
573 ;; (dolist (pair prefixes)
574 ;; (unless (memq pair newprefixes) ;Not old
575 ;; (push pair old)))
576 ;; (dolist (pair newprefixes)
577 ;; (unless (memq pair prefixes) ;Not new
578 ;; (push pair new)))
579 ;; (cl-assert new)
580 ;; (message "Expanding %S to %S"
581 ;; (mapcar #'car old) (mapcar #'car new))
582 ;; t)
583 ;; (setq prefixes newprefixes)
584 ;; (< (length prefixes) autoload-def-prefixes-max-entries))))
586 ;; (message "Final prefixes %s : %S" file (mapcar #'car prefixes))
587 (when prefixes
588 (let ((strings
589 (mapcar
590 (lambda (x)
591 (let ((prefix (car x)))
592 (if (or (> (length prefix) 2) ;Long enough!
593 (and (eq (length prefix) 2)
594 (string-match "[[:punct:]]" prefix)))
595 prefix
596 ;; Some packages really don't follow the rules.
597 ;; Drop the most egregious cases such as the
598 ;; one-letter prefixes.
599 (let ((dropped ()))
600 (radix-tree-iter-mappings
601 (cdr x) (lambda (s _)
602 (push (concat prefix s) dropped)))
603 (message "Not registering prefix \"%s\" from %s. Affects: %S"
604 prefix file dropped)
605 nil))))
606 prefixes)))
607 `(if (fboundp 'register-definition-prefixes)
608 (register-definition-prefixes ,file ',(delq nil strings)))))))
610 (defun autoload--setup-output (otherbuf outbuf absfile load-name)
611 (let ((outbuf
612 (or (if otherbuf
613 ;; A file-local setting of
614 ;; autoload-generated-file says we
615 ;; should ignore OUTBUF.
617 outbuf)
618 (autoload-find-destination absfile load-name)
619 ;; The file has autoload cookies, but they're
620 ;; already up-to-date. If OUTFILE is nil, the
621 ;; entries are in the expected OUTBUF,
622 ;; otherwise they're elsewhere.
623 (throw 'done otherbuf))))
624 (with-current-buffer outbuf
625 (point-marker))))
627 (defun autoload--print-cookie-text (output-start load-name file)
628 (let ((standard-output (marker-buffer output-start)))
629 (search-forward generate-autoload-cookie)
630 (skip-chars-forward " \t")
631 (if (eolp)
632 (condition-case-unless-debug err
633 ;; Read the next form and make an autoload.
634 (let* ((form (prog1 (read (current-buffer))
635 (or (bolp) (forward-line 1))))
636 (autoload (make-autoload form load-name)))
637 (if autoload
639 (setq autoload form))
640 (let ((autoload-print-form-outbuf
641 standard-output))
642 (autoload-print-form autoload)))
643 (error
644 (message "Autoload cookie error in %s:%s %S"
645 file (count-lines (point-min) (point)) err)))
647 ;; Copy the rest of the line to the output.
648 (princ (buffer-substring
649 (progn
650 ;; Back up over whitespace, to preserve it.
651 (skip-chars-backward " \f\t")
652 (if (= (char-after (1+ (point))) ? )
653 ;; Eat one space.
654 (forward-char 1))
655 (point))
656 (progn (forward-line 1) (point)))))))
658 (defvar autoload-builtin-package-versions nil)
660 ;; When called from `generate-file-autoloads' we should ignore
661 ;; `generated-autoload-file' altogether. When called from
662 ;; `update-file-autoloads' we don't know `outbuf'. And when called from
663 ;; `update-directory-autoloads' it's in between: we know the default
664 ;; `outbuf' but we should obey any file-local setting of
665 ;; `generated-autoload-file'.
666 (defun autoload-generate-file-autoloads (file &optional outbuf outfile)
667 "Insert an autoload section for FILE in the appropriate buffer.
668 Autoloads are generated for defuns and defmacros in FILE
669 marked by `generate-autoload-cookie' (which see).
670 If FILE is being visited in a buffer, the contents of the buffer are used.
671 OUTBUF is the buffer in which the autoload statements should be inserted.
672 If OUTBUF is nil, it will be determined by `autoload-generated-file'.
674 If provided, OUTFILE is expected to be the file name of OUTBUF.
675 If OUTFILE is non-nil and FILE specifies a `generated-autoload-file'
676 different from OUTFILE, then OUTBUF is ignored.
678 Return non-nil if and only if FILE adds no autoloads to OUTFILE
679 \(or OUTBUF if OUTFILE is nil). The actual return value is
680 FILE's modification time."
681 ;; Include the file name in any error messages
682 (condition-case err
683 (let (load-name
684 (print-length nil)
685 (print-level nil)
686 (float-output-format nil)
687 (visited (get-file-buffer file))
688 (otherbuf nil)
689 (absfile (expand-file-name file))
690 (defs '())
691 ;; nil until we found a cookie.
692 output-start)
693 (when
694 (catch 'done
695 (with-current-buffer (or visited
696 ;; It is faster to avoid visiting the file.
697 (autoload-find-file file))
698 ;; Obey the no-update-autoloads file local variable.
699 (unless no-update-autoloads
700 (or noninteractive (message "Generating autoloads for %s..." file))
701 (setq load-name
702 (if (stringp generated-autoload-load-name)
703 generated-autoload-load-name
704 (autoload-file-load-name absfile)))
705 ;; FIXME? Comparing file-names for equality with just equal
706 ;; is fragile, eg if one has an automounter prefix and one
707 ;; does not, but both refer to the same physical file.
708 (when (and outfile
709 (not
710 (if (memq system-type '(ms-dos windows-nt))
711 (equal (downcase outfile)
712 (downcase (autoload-generated-file)))
713 (equal outfile (autoload-generated-file)))))
714 (setq otherbuf t))
715 (save-excursion
716 (save-restriction
717 (widen)
718 (when autoload-builtin-package-versions
719 (let ((version (lm-header "version"))
720 package)
721 (and version
722 (setq version (ignore-errors (version-to-list version)))
723 (setq package (or (lm-header "package")
724 (file-name-sans-extension
725 (file-name-nondirectory file))))
726 (setq output-start (autoload--setup-output
727 otherbuf outbuf absfile load-name))
728 (let ((standard-output (marker-buffer output-start))
729 (print-quoted t))
730 (princ `(push (purecopy
731 ',(cons (intern package) version))
732 package--builtin-versions))
733 (princ "\n")))))
735 ;; Do not insert autoload entries for excluded files.
736 (unless (member absfile autoload-excludes)
737 (goto-char (point-min))
738 (while (not (eobp))
739 (skip-chars-forward " \t\n\f")
740 (cond
741 ((looking-at (regexp-quote generate-autoload-cookie))
742 ;; If not done yet, figure out where to insert this text.
743 (unless output-start
744 (setq output-start (autoload--setup-output
745 otherbuf outbuf absfile load-name)))
746 (autoload--print-cookie-text output-start load-name file))
747 ((= (following-char) ?\;)
748 ;; Don't read the comment.
749 (forward-line 1))
751 ;; Avoid (defvar <foo>) by requiring a trailing space.
752 ;; Also, ignore this prefix business
753 ;; for ;;;###tramp-autoload and friends.
754 (when (and (equal generate-autoload-cookie ";;;###autoload")
755 (looking-at "(\\(def[^ ]+\\) ['(]*\\([^' ()\"\n]+\\)[\n \t]")
756 (not (member
757 (match-string 1)
758 '("define-obsolete-function-alias"
759 "define-obsolete-variable-alias"
760 "define-category" "define-key"
761 "defgroup" "defface" "defadvice"
762 "def-edebug-spec"
763 ;; Hmm... this is getting ugly:
764 "define-widget"
765 "define-erc-module"
766 "define-erc-response-handler"
767 "defun-rcirc-command"))))
768 (push (match-string 2) defs))
769 (forward-sexp 1)
770 (forward-line 1)))))))
772 (when (and autoload-compute-prefixes defs)
773 ;; This output needs to always go in the main loaddefs.el,
774 ;; regardless of generated-autoload-file.
775 ;; FIXME: the files that don't have autoload cookies but
776 ;; do have definitions end up listed twice in loaddefs.el:
777 ;; once for their register-definition-prefixes and once in
778 ;; the list of "files without any autoloads".
779 (let ((form (autoload--make-defs-autoload defs load-name)))
780 (cond
781 ((null form)) ;All defs obey the default rule, yay!
782 ((not otherbuf)
783 (unless output-start
784 (setq output-start (autoload--setup-output
785 nil outbuf absfile load-name)))
786 (let ((autoload-print-form-outbuf
787 (marker-buffer output-start)))
788 (autoload-print-form form)))
790 (let* ((other-output-start
791 ;; To force the output to go to the main loaddefs.el
792 ;; rather than to generated-autoload-file,
793 ;; there are two cases: if outbuf is non-nil,
794 ;; then passing otherbuf=nil is enough, but if
795 ;; outbuf is nil, that won't cut it, so we
796 ;; locally bind generated-autoload-file.
797 (let ((generated-autoload-file
798 (default-value 'generated-autoload-file)))
799 (autoload--setup-output nil outbuf absfile load-name)))
800 (autoload-print-form-outbuf
801 (marker-buffer other-output-start)))
802 (autoload-print-form form)
803 (with-current-buffer (marker-buffer other-output-start)
804 (save-excursion
805 ;; Insert the section-header line which lists
806 ;; the file name and which functions are in it, etc.
807 (goto-char other-output-start)
808 (let ((relfile (file-relative-name absfile)))
809 (autoload-insert-section-header
810 (marker-buffer other-output-start)
811 "actual autoloads are elsewhere" load-name relfile
812 (if autoload-timestamps
813 (nth 5 (file-attributes absfile))
814 autoload--non-timestamp))
815 (insert ";;; Generated autoloads from " relfile "\n")))
816 (insert generate-autoload-section-trailer)))))))
818 (when output-start
819 (let ((secondary-autoloads-file-buf
820 (if otherbuf (current-buffer))))
821 (with-current-buffer (marker-buffer output-start)
822 (cl-assert (> (point) output-start))
823 (save-excursion
824 ;; Insert the section-header line which lists the file name
825 ;; and which functions are in it, etc.
826 (goto-char output-start)
827 (let ((relfile (file-relative-name absfile)))
828 (autoload-insert-section-header
829 (marker-buffer output-start)
830 () load-name relfile
831 (if secondary-autoloads-file-buf
832 ;; MD5 checksums are much better because they do not
833 ;; change unless the file changes (so they'll be
834 ;; equal on two different systems and will change
835 ;; less often than time-stamps, thus leading to fewer
836 ;; unneeded changes causing spurious conflicts), but
837 ;; using time-stamps is a very useful optimization,
838 ;; so we use time-stamps for the main autoloads file
839 ;; (loaddefs.el) where we have special ways to
840 ;; circumvent the "random change problem", and MD5
841 ;; checksum in secondary autoload files where we do
842 ;; not need the time-stamp optimization because it is
843 ;; already provided by the primary autoloads file.
844 (md5 secondary-autoloads-file-buf
845 ;; We'd really want to just use
846 ;; `emacs-internal' instead.
847 nil nil 'emacs-mule-unix)
848 (if autoload-timestamps
849 (nth 5 (file-attributes relfile))
850 autoload--non-timestamp)))
851 (insert ";;; Generated autoloads from " relfile "\n")))
852 (insert generate-autoload-section-trailer))))
853 (or noninteractive
854 (message "Generating autoloads for %s...done" file)))
855 (or visited
856 ;; We created this buffer, so we should kill it.
857 (kill-buffer (current-buffer))))
858 (or (not output-start)
859 ;; If the entries were added to some other buffer, then the file
860 ;; doesn't add entries to OUTFILE.
861 otherbuf))
862 (nth 5 (file-attributes absfile))))
863 (error
864 ;; Probably unbalanced parens in forward-sexp. In that case, the
865 ;; condition is scan-error, and the signal data includes point
866 ;; where the error was found; we'd like to convert that to
867 ;; line:col, but line-number-at-pos gets the wrong line in batch
868 ;; mode for some reason.
870 ;; At least this gets the file name in the error message; the
871 ;; developer can use goto-char to get to the error position.
872 (error "%s:0:0: error: %s: %s" file (car err) (cdr err)))
875 ;; For parallel builds, to stop another process reading a half-written file.
876 (defun autoload--save-buffer ()
877 "Save current buffer to its file, atomically."
878 ;; Similar to byte-compile-file.
879 (let* ((version-control 'never)
880 (tempfile (make-temp-file buffer-file-name))
881 (default-modes (default-file-modes))
882 (temp-modes (logand default-modes #o600))
883 (desired-modes (logand default-modes
884 (or (file-modes buffer-file-name) #o666)))
885 (kill-emacs-hook
886 (cons (lambda () (ignore-errors (delete-file tempfile)))
887 kill-emacs-hook)))
888 (unless (= temp-modes desired-modes)
889 (set-file-modes tempfile desired-modes))
890 (write-region (point-min) (point-max) tempfile nil 1)
891 (backup-buffer)
892 (rename-file tempfile buffer-file-name t))
893 (set-buffer-modified-p nil)
894 (set-visited-file-modtime)
895 (or noninteractive (message "Wrote %s" buffer-file-name)))
897 (defun autoload-save-buffers ()
898 (while autoload-modified-buffers
899 (with-current-buffer (pop autoload-modified-buffers)
900 (autoload--save-buffer))))
902 ;; FIXME This command should be deprecated.
903 ;; See https://debbugs.gnu.org/22213#41
904 ;;;###autoload
905 (defun update-file-autoloads (file &optional save-after outfile)
906 "Update the autoloads for FILE.
907 If prefix arg SAVE-AFTER is non-nil, save the buffer too.
909 If FILE binds `generated-autoload-file' as a file-local variable,
910 autoloads are written into that file. Otherwise, the autoloads
911 file is determined by OUTFILE. If called interactively, prompt
912 for OUTFILE; if called from Lisp with OUTFILE nil, use the
913 existing value of `generated-autoload-file'.
915 Return FILE if there was no autoload cookie in it, else nil."
916 (interactive (list (read-file-name "Update autoloads for file: ")
917 current-prefix-arg
918 (read-file-name "Write autoload definitions to file: ")))
919 (let* ((generated-autoload-file (or outfile generated-autoload-file))
920 (autoload-modified-buffers nil)
921 ;; We need this only if the output file handles more than one input.
922 ;; See https://debbugs.gnu.org/22213#38 and subsequent.
923 (autoload-timestamps t)
924 (no-autoloads (autoload-generate-file-autoloads file)))
925 (if autoload-modified-buffers
926 (if save-after (autoload-save-buffers))
927 (if (called-interactively-p 'interactive)
928 (message "Autoload section for %s is up to date." file)))
929 (if no-autoloads file)))
931 (defun autoload-find-destination (file load-name)
932 "Find the destination point of the current buffer's autoloads.
933 FILE is the file name of the current buffer.
934 LOAD-NAME is the name as it appears in the output.
935 Returns a buffer whose point is placed at the requested location.
936 Returns nil if the file's autoloads are up-to-date, otherwise
937 removes any prior now out-of-date autoload entries."
938 (catch 'up-to-date
939 (let* ((buf (current-buffer))
940 (existing-buffer (if buffer-file-name buf))
941 (output-file (autoload-generated-file))
942 (output-time (if (file-exists-p output-file)
943 (nth 5 (file-attributes output-file))))
944 (found nil))
945 (with-current-buffer (autoload-find-generated-file)
946 ;; This is to make generated-autoload-file have Unix EOLs, so
947 ;; that it is portable to all platforms.
948 (or (eq 0 (coding-system-eol-type buffer-file-coding-system))
949 (set-buffer-file-coding-system 'unix))
950 (or (> (buffer-size) 0)
951 (error "Autoloads file %s lacks boilerplate" buffer-file-name))
952 (or (file-writable-p buffer-file-name)
953 (error "Autoloads file %s is not writable" buffer-file-name))
954 (widen)
955 (goto-char (point-min))
956 ;; Look for the section for LOAD-NAME.
957 (while (and (not found)
958 (search-forward generate-autoload-section-header nil t))
959 (let ((form (autoload-read-section-header)))
960 (cond ((string= (nth 2 form) load-name)
961 ;; We found the section for this file.
962 ;; Check if it is up to date.
963 (let ((begin (match-beginning 0))
964 (last-time (nth 4 form))
965 (file-time (nth 5 (file-attributes file))))
966 (if (and (or (null existing-buffer)
967 (not (buffer-modified-p existing-buffer)))
968 (cond
969 ;; FIXME? Arguably we should throw a
970 ;; user error, or some kind of warning,
971 ;; if we were called from update-file-autoloads,
972 ;; which can update only a single input file.
973 ;; It's not appropriate to use the output
974 ;; file modtime in such a case,
975 ;; if there are multiple input files
976 ;; contributing to the output.
977 ((and output-time
978 (member last-time
979 (list t autoload--non-timestamp)))
980 (not (time-less-p output-time file-time)))
981 ;; last-time is the time-stamp (specifying
982 ;; the last time we looked at the file) and
983 ;; the file hasn't been changed since.
984 ((listp last-time)
985 (not (time-less-p last-time file-time)))
986 ;; last-time is an MD5 checksum instead.
987 ((stringp last-time)
988 (equal last-time
989 (md5 buf nil nil 'emacs-mule)))))
990 (throw 'up-to-date nil)
991 (autoload-remove-section begin)
992 (setq found t))))
993 ((string< load-name (nth 2 form))
994 ;; We've come to a section alphabetically later than
995 ;; LOAD-NAME. We assume the file is in order and so
996 ;; there must be no section for LOAD-NAME. We will
997 ;; insert one before the section here.
998 (goto-char (match-beginning 0))
999 (setq found t)))))
1000 (or found
1001 (progn
1002 ;; No later sections in the file. Put before the last page.
1003 (goto-char (point-max))
1004 (search-backward "\f" nil t)))
1005 (unless (memq (current-buffer) autoload-modified-buffers)
1006 (push (current-buffer) autoload-modified-buffers))
1007 (current-buffer)))))
1009 (defun autoload-remove-section (begin)
1010 (goto-char begin)
1011 (search-forward generate-autoload-section-trailer)
1012 (delete-region begin (point)))
1014 ;;;###autoload
1015 (defun update-directory-autoloads (&rest dirs)
1016 "Update autoload definitions for Lisp files in the directories DIRS.
1017 In an interactive call, you must give one argument, the name of a
1018 single directory. In a call from Lisp, you can supply multiple
1019 directories as separate arguments, but this usage is discouraged.
1021 The function does NOT recursively descend into subdirectories of the
1022 directory or directories specified.
1024 In an interactive call, prompt for a default output file for the
1025 autoload definitions, and temporarily bind the variable
1026 `generated-autoload-file' to this value. When called from Lisp,
1027 use the existing value of `generated-autoload-file'. If any Lisp
1028 file binds `generated-autoload-file' as a file-local variable,
1029 write its autoloads into the specified file instead."
1030 (interactive "DUpdate autoloads from directory: ")
1031 (let* ((files-re (let ((tmp nil))
1032 (dolist (suf (get-load-suffixes))
1033 ;; We don't use module-file-suffix below because
1034 ;; we don't want to depend on whether Emacs was
1035 ;; built with or without modules support, nor
1036 ;; what is the suffix for the underlying OS.
1037 (unless (string-match "\\.\\(elc\\|\\so\\|dll\\)" suf)
1038 (push suf tmp)))
1039 (concat "^[^=.].*" (regexp-opt tmp t) "\\'")))
1040 (files (apply #'nconc
1041 (mapcar (lambda (dir)
1042 (directory-files (expand-file-name dir)
1043 t files-re))
1044 dirs)))
1045 (done ()) ;Files processed; to remove duplicates.
1046 (changed nil) ;Non-nil if some change occurred.
1047 (last-time)
1048 ;; Files with no autoload cookies or whose autoloads go to other
1049 ;; files because of file-local autoload-generated-file settings.
1050 (no-autoloads nil)
1051 (autoload-modified-buffers nil)
1052 (generated-autoload-file
1053 (if (called-interactively-p 'interactive)
1054 (read-file-name "Write autoload definitions to file: ")
1055 generated-autoload-file))
1056 (output-time
1057 (if (file-exists-p generated-autoload-file)
1058 (nth 5 (file-attributes generated-autoload-file)))))
1060 (with-current-buffer (autoload-find-generated-file)
1061 (save-excursion
1062 ;; Canonicalize file names and remove the autoload file itself.
1063 (setq files (delete (file-relative-name buffer-file-name)
1064 (mapcar #'file-relative-name files)))
1066 (goto-char (point-min))
1067 (while (search-forward generate-autoload-section-header nil t)
1068 (let* ((form (autoload-read-section-header))
1069 (file (nth 3 form)))
1070 (cond ((and (consp file) (stringp (car file)))
1071 ;; This is a list of files that have no autoload cookies.
1072 ;; There shouldn't be more than one such entry.
1073 ;; Remove the obsolete section.
1074 (autoload-remove-section (match-beginning 0))
1075 (setq last-time (nth 4 form))
1076 (if (member last-time (list t autoload--non-timestamp))
1077 (setq last-time output-time))
1078 (dolist (file file)
1079 (let ((file-time (nth 5 (file-attributes file))))
1080 (when (and file-time
1081 (not (time-less-p last-time file-time)))
1082 ;; file unchanged
1083 (push file no-autoloads)
1084 (setq files (delete file files))))))
1085 ((not (stringp file)))
1086 ((or (not (file-exists-p file))
1087 ;; Remove duplicates as well, just in case.
1088 (member file done))
1089 ;; Remove the obsolete section.
1090 (setq changed t)
1091 (autoload-remove-section (match-beginning 0)))
1092 ((not (time-less-p (let ((oldtime (nth 4 form)))
1093 (if (member oldtime
1094 (list
1095 t autoload--non-timestamp))
1096 output-time
1097 oldtime))
1098 (nth 5 (file-attributes file))))
1099 ;; File hasn't changed.
1100 nil)
1102 (setq changed t)
1103 (autoload-remove-section (match-beginning 0))
1104 (if (autoload-generate-file-autoloads
1105 ;; Passing `current-buffer' makes it insert at point.
1106 file (current-buffer) buffer-file-name)
1107 (push file no-autoloads))))
1108 (push file done)
1109 (setq files (delete file files)))))
1110 ;; Elements remaining in FILES have no existing autoload sections yet.
1111 (let ((no-autoloads-time (or last-time '(0 0 0 0))) file-time)
1112 (dolist (file files)
1113 (cond
1114 ;; Passing nil as second argument forces
1115 ;; autoload-generate-file-autoloads to look for the right
1116 ;; spot where to insert each autoloads section.
1117 ((setq file-time
1118 (autoload-generate-file-autoloads file nil buffer-file-name))
1119 (push file no-autoloads)
1120 (if (time-less-p no-autoloads-time file-time)
1121 (setq no-autoloads-time file-time)))
1122 (t (setq changed t))))
1124 (when no-autoloads
1125 ;; Sort them for better readability.
1126 (setq no-autoloads (sort no-autoloads 'string<))
1127 ;; Add the `no-autoloads' section.
1128 (goto-char (point-max))
1129 (search-backward "\f" nil t)
1130 (autoload-insert-section-header
1131 (current-buffer) nil nil no-autoloads (if autoload-timestamps
1132 no-autoloads-time
1133 autoload--non-timestamp))
1134 (insert generate-autoload-section-trailer)))
1136 ;; Don't modify the file if its content has not been changed, so `make'
1137 ;; dependencies don't trigger unnecessarily.
1138 (if (not changed)
1139 (set-buffer-modified-p nil)
1140 (autoload--save-buffer))
1142 ;; In case autoload entries were added to other files because of
1143 ;; file-local autoload-generated-file settings.
1144 (autoload-save-buffers))))
1146 (define-obsolete-function-alias 'update-autoloads-from-directories
1147 'update-directory-autoloads "22.1")
1149 ;;;###autoload
1150 (defun batch-update-autoloads ()
1151 "Update loaddefs.el autoloads in batch mode.
1152 Calls `update-directory-autoloads' on the command line arguments.
1153 Definitions are written to `generated-autoload-file' (which
1154 should be non-nil)."
1155 ;; For use during the Emacs build process only.
1156 ;; Exclude those files that are preloaded on ALL platforms.
1157 ;; These are the ones in loadup.el where "(load" is at the start
1158 ;; of the line (crude, but it works).
1159 (unless autoload-excludes
1160 (let ((default-directory (file-name-directory generated-autoload-file))
1161 file)
1162 (when (file-readable-p "loadup.el")
1163 (with-temp-buffer
1164 (insert-file-contents "loadup.el")
1165 (while (re-search-forward "^(load \"\\([^\"]+\\)\"" nil t)
1166 (setq file (match-string 1))
1167 (or (string-match "\\.el\\'" file)
1168 (setq file (format "%s.el" file)))
1169 (or (string-match "\\`site-" file)
1170 (push (expand-file-name file) autoload-excludes)))))))
1171 (let ((args command-line-args-left))
1172 (setq command-line-args-left nil)
1173 (apply #'update-directory-autoloads args)))
1175 (provide 'autoload)
1177 ;;; autoload.el ends here