Mercurial > emacs
comparison lisp/emacs-lisp/autoload.el @ 81604:feafa882a0cf
(autoload-modified-buffers): New var.
(autoload-find-destination): Keep it uptodate.
(autoload-save-buffers): New fun.
(update-file-autoloads): Use it. Re-add the "up to date" message.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 25 Jun 2007 05:09:05 +0000 |
parents | 6a5ecb520686 |
children | 56b815dd1abb |
comparison
equal
deleted
inserted
replaced
81603:6a5ecb520686 | 81604:feafa882a0cf |
---|---|
400 (or visited | 400 (or visited |
401 ;; We created this buffer, so we should kill it. | 401 ;; We created this buffer, so we should kill it. |
402 (kill-buffer (current-buffer)))) | 402 (kill-buffer (current-buffer)))) |
403 (not output-start))) | 403 (not output-start))) |
404 | 404 |
405 (defvar autoload-modified-buffers nil) | |
406 | |
407 (defun autoload-save-buffers () | |
408 (while autoload-modified-buffers | |
409 (with-current-buffer (pop autoload-modified-buffers) | |
410 (save-buffer)))) | |
411 | |
405 ;;;###autoload | 412 ;;;###autoload |
406 (defun update-file-autoloads (file &optional save-after) | 413 (defun update-file-autoloads (file &optional save-after) |
407 "Update the autoloads for FILE in `generated-autoload-file' | 414 "Update the autoloads for FILE in `generated-autoload-file' |
408 \(which FILE might bind in its local variables). | 415 \(which FILE might bind in its local variables). |
409 If SAVE-AFTER is non-nil (which is always, when called interactively), | 416 If SAVE-AFTER is non-nil (which is always, when called interactively), |
410 save the buffer too. | 417 save the buffer too. |
411 | 418 |
412 Return FILE if there was no autoload cookie in it, else nil." | 419 Return FILE if there was no autoload cookie in it, else nil." |
413 (interactive "fUpdate autoloads for file: \np") | 420 (interactive "fUpdate autoloads for file: \np") |
414 (let ((existing-buffer (get-file-buffer file))) | 421 (let ((existing-buffer (get-file-buffer file)) |
422 (no-autoloads nil)) | |
415 (with-temp-buffer | 423 (with-temp-buffer |
416 ;; Let's presume the file is not visited, so we call | 424 ;; Let's presume the file is not visited, so we call |
417 ;; autoload-find-destination from a dummy buffer, except if the file | 425 ;; autoload-find-destination from a dummy buffer, except if the file |
418 ;; is visited, in which case we use that buffer instead. | 426 ;; is visited, in which case we use that buffer instead. |
419 (if existing-buffer (set-buffer existing-buffer)) | 427 (if existing-buffer (set-buffer existing-buffer)) |
420 | 428 |
421 (catch 'up-to-date | 429 (if (catch 'up-to-date |
422 (let ((buf (autoload-find-destination file))) | 430 (with-current-buffer (autoload-find-destination file) |
423 (with-current-buffer buf | 431 (setq no-autoloads (generate-file-autoloads file)) |
424 (let ((no-autoloads (generate-file-autoloads file))) | 432 t)) |
425 | 433 (if save-after (autoload-save-buffers)) |
426 (and save-after | 434 (if (interactive-p) |
427 (buffer-modified-p) | 435 (message "Autoload section for %s is up to date." file)))) |
428 (save-buffer)) | 436 ;; If we caught `up-to-date', it means there are autoload entries, since |
429 | 437 ;; otherwise we wouldn't have detected their up-to-dateness. |
430 (if no-autoloads file)))))))) | 438 (if no-autoloads file))) |
431 | 439 |
432 (defun autoload-find-destination (file) | 440 (defun autoload-find-destination (file) |
433 "Find the destination point of the current buffer's autoloads. | 441 "Find the destination point of the current buffer's autoloads. |
434 FILE is the file name of the current buffer. | 442 FILE is the file name of the current buffer. |
435 Returns a buffer whose point is placed at the requested location. | 443 Returns a buffer whose point is placed at the requested location. |
484 (or found | 492 (or found |
485 (progn | 493 (progn |
486 ;; No later sections in the file. Put before the last page. | 494 ;; No later sections in the file. Put before the last page. |
487 (goto-char (point-max)) | 495 (goto-char (point-max)) |
488 (search-backward "\f" nil t))) | 496 (search-backward "\f" nil t))) |
497 (unless (memq (current-buffer) autoload-modified-buffers) | |
498 (push (current-buffer) autoload-modified-buffers)) | |
489 (current-buffer)))) | 499 (current-buffer)))) |
490 | 500 |
491 (defun autoload-remove-section (begin) | 501 (defun autoload-remove-section (begin) |
492 (goto-char begin) | 502 (goto-char begin) |
493 (search-forward generate-autoload-section-trailer) | 503 (search-forward generate-autoload-section-trailer) |