| 312 | | (message "Generating autoloads for %s..." file) |
|---|
| 313 | | (save-excursion |
|---|
| 314 | | (unwind-protect |
|---|
| 315 | | (progn |
|---|
| 316 | | (if visited |
|---|
| 317 | | (set-buffer visited) |
|---|
| 318 | | ;; It is faster to avoid visiting the file. |
|---|
| 319 | | (set-buffer (get-buffer-create " *generate-autoload-file*")) |
|---|
| 320 | | (kill-all-local-variables) |
|---|
| 321 | | (erase-buffer) |
|---|
| 322 | | (setq buffer-undo-list t |
|---|
| 323 | | buffer-read-only nil) |
|---|
| 324 | | (emacs-lisp-mode) |
|---|
| 325 | | (insert-file-contents file nil)) |
|---|
| 326 | | (save-excursion |
|---|
| 327 | | (save-restriction |
|---|
| 328 | | (widen) |
|---|
| 329 | | (goto-char (point-min)) |
|---|
| 330 | | (while (not (eobp)) |
|---|
| 331 | | (skip-chars-forward " \t\n\f") |
|---|
| 332 | | (cond |
|---|
| 333 | | ((looking-at (regexp-quote generate-autoload-cookie)) |
|---|
| 334 | | (search-forward generate-autoload-cookie) |
|---|
| 335 | | (skip-chars-forward " \t") |
|---|
| 336 | | (setq done-any t) |
|---|
| 337 | | (if (eolp) |
|---|
| 338 | | ;; Read the next form and make an autoload. |
|---|
| 339 | | (let* ((form (prog1 (read (current-buffer)) |
|---|
| 340 | | (or (bolp) (forward-line 1)))) |
|---|
| 341 | | (autoload (make-autoload form load-name))) |
|---|
| 342 | | (if autoload |
|---|
| 343 | | (setq autoloads-done (cons (nth 1 form) |
|---|
| 344 | | autoloads-done)) |
|---|
| 345 | | (setq autoload form)) |
|---|
| 346 | | (let ((autoload-print-form-outbuf outbuf)) |
|---|
| 347 | | (autoload-print-form autoload))) |
|---|
| 348 | | |
|---|
| 349 | | ;; Copy the rest of the line to the output. |
|---|
| 350 | | (princ (buffer-substring |
|---|
| 351 | | (progn |
|---|
| 352 | | ;; Back up over whitespace, to preserve it. |
|---|
| 353 | | (skip-chars-backward " \f\t") |
|---|
| 354 | | (if (= (char-after (1+ (point))) ? ) |
|---|
| 355 | | ;; Eat one space. |
|---|
| 356 | | (forward-char 1)) |
|---|
| 357 | | (point)) |
|---|
| 358 | | (progn (forward-line 1) (point))) |
|---|
| 359 | | outbuf))) |
|---|
| 360 | | ((looking-at ";") |
|---|
| 361 | | ;; Don't read the comment. |
|---|
| 362 | | (forward-line 1)) |
|---|
| 363 | | (t |
|---|
| 364 | | (forward-sexp 1) |
|---|
| 365 | | (forward-line 1))))))) |
|---|
| 366 | | (or visited |
|---|
| 367 | | ;; We created this buffer, so we should kill it. |
|---|
| 368 | | (kill-buffer (current-buffer))) |
|---|
| 369 | | (set-buffer outbuf) |
|---|
| 370 | | (setq output-end (point-marker)))) |
|---|
| 371 | | (if done-any |
|---|
| 372 | | (progn |
|---|
| 373 | | ;; Insert the section-header line |
|---|
| 374 | | ;; which lists the file name and which functions are in it, etc. |
|---|
| 375 | | (autoload-insert-section-header outbuf autoloads-done load-name file |
|---|
| 376 | | (nth 5 (file-attributes file))) |
|---|
| 377 | | (insert ";;; Generated autoloads from " |
|---|
| 378 | | (autoload-trim-file-name file) "\n") |
|---|
| 379 | | (goto-char output-end) |
|---|
| 380 | | (insert generate-autoload-section-trailer))) |
|---|
| 381 | | (message "Generating autoloads for %s...done" file))) |
|---|
| | 330 | (with-current-buffer (or visited |
|---|
| | 331 | ;; It is faster to avoid visiting the file. |
|---|
| | 332 | (autoload-find-file file)) |
|---|
| | 333 | ;; Obey the no-update-autoloads file local variable. |
|---|
| | 334 | (unless no-update-autoloads |
|---|
| | 335 | (message "Generating autoloads for %s..." file) |
|---|
| | 336 | (setq output-start (with-current-buffer outbuf (point))) |
|---|
| | 337 | (save-excursion |
|---|
| | 338 | (save-restriction |
|---|
| | 339 | (widen) |
|---|
| | 340 | (goto-char (point-min)) |
|---|
| | 341 | (while (not (eobp)) |
|---|
| | 342 | (skip-chars-forward " \t\n\f") |
|---|
| | 343 | (cond |
|---|
| | 344 | ((looking-at (regexp-quote generate-autoload-cookie)) |
|---|
| | 345 | (search-forward generate-autoload-cookie) |
|---|
| | 346 | (skip-chars-forward " \t") |
|---|
| | 347 | (setq done-any t) |
|---|
| | 348 | (if (eolp) |
|---|
| | 349 | ;; Read the next form and make an autoload. |
|---|
| | 350 | (let* ((form (prog1 (read (current-buffer)) |
|---|
| | 351 | (or (bolp) (forward-line 1)))) |
|---|
| | 352 | (autoload (make-autoload form load-name))) |
|---|
| | 353 | (if autoload |
|---|
| | 354 | (push (nth 1 form) autoloads-done) |
|---|
| | 355 | (setq autoload form)) |
|---|
| | 356 | (let ((autoload-print-form-outbuf outbuf)) |
|---|
| | 357 | (autoload-print-form autoload))) |
|---|
| | 358 | |
|---|
| | 359 | ;; Copy the rest of the line to the output. |
|---|
| | 360 | (princ (buffer-substring |
|---|
| | 361 | (progn |
|---|
| | 362 | ;; Back up over whitespace, to preserve it. |
|---|
| | 363 | (skip-chars-backward " \f\t") |
|---|
| | 364 | (if (= (char-after (1+ (point))) ? ) |
|---|
| | 365 | ;; Eat one space. |
|---|
| | 366 | (forward-char 1)) |
|---|
| | 367 | (point)) |
|---|
| | 368 | (progn (forward-line 1) (point))) |
|---|
| | 369 | outbuf))) |
|---|
| | 370 | ((looking-at ";") |
|---|
| | 371 | ;; Don't read the comment. |
|---|
| | 372 | (forward-line 1)) |
|---|
| | 373 | (t |
|---|
| | 374 | (forward-sexp 1) |
|---|
| | 375 | (forward-line 1)))))) |
|---|
| | 376 | |
|---|
| | 377 | (when done-any |
|---|
| | 378 | (with-current-buffer outbuf |
|---|
| | 379 | (save-excursion |
|---|
| | 380 | ;; Insert the section-header line which lists the file name |
|---|
| | 381 | ;; and which functions are in it, etc. |
|---|
| | 382 | (goto-char output-start) |
|---|
| | 383 | (autoload-insert-section-header |
|---|
| | 384 | outbuf autoloads-done load-name file |
|---|
| | 385 | (nth 5 (file-attributes file))) |
|---|
| | 386 | (insert ";;; Generated autoloads from " |
|---|
| | 387 | (autoload-trim-file-name file) "\n")) |
|---|
| | 388 | (insert generate-autoload-section-trailer))) |
|---|
| | 389 | (message "Generating autoloads for %s...done" file)) |
|---|
| | 390 | (or visited |
|---|
| | 391 | ;; We created this buffer, so we should kill it. |
|---|
| | 392 | (kill-buffer (current-buffer)))) |
|---|
| | 393 | (not done-any))) |
|---|