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