Commit e66466a6 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(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.
parent ceea9b18
2007-06-25 Stefan Monnier <monnier@iro.umontreal.ca> 2007-06-25 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/autoload.el (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.
* emacs-lisp/autoload.el: Refactor for upcoming changes. * emacs-lisp/autoload.el: Refactor for upcoming changes.
(autoload-find-destination): New function extracted from (autoload-find-destination): New function extracted from
update-file-autoloads. update-file-autoloads.
......
...@@ -402,6 +402,13 @@ Return non-nil in the case where no autoloads were added in the buffer." ...@@ -402,6 +402,13 @@ Return non-nil in the case where no autoloads were added in the buffer."
(kill-buffer (current-buffer)))) (kill-buffer (current-buffer))))
(not output-start))) (not output-start)))
(defvar autoload-modified-buffers nil)
(defun autoload-save-buffers ()
(while autoload-modified-buffers
(with-current-buffer (pop autoload-modified-buffers)
(save-buffer))))
;;;###autoload ;;;###autoload
(defun update-file-autoloads (file &optional save-after) (defun update-file-autoloads (file &optional save-after)
"Update the autoloads for FILE in `generated-autoload-file' "Update the autoloads for FILE in `generated-autoload-file'
...@@ -411,23 +418,24 @@ save the buffer too. ...@@ -411,23 +418,24 @@ save the buffer too.
Return FILE if there was no autoload cookie in it, else nil." Return FILE if there was no autoload cookie in it, else nil."
(interactive "fUpdate autoloads for file: \np") (interactive "fUpdate autoloads for file: \np")
(let ((existing-buffer (get-file-buffer file))) (let ((existing-buffer (get-file-buffer file))
(no-autoloads nil))
(with-temp-buffer (with-temp-buffer
;; Let's presume the file is not visited, so we call ;; Let's presume the file is not visited, so we call
;; autoload-find-destination from a dummy buffer, except if the file ;; autoload-find-destination from a dummy buffer, except if the file
;; is visited, in which case we use that buffer instead. ;; is visited, in which case we use that buffer instead.
(if existing-buffer (set-buffer existing-buffer)) (if existing-buffer (set-buffer existing-buffer))
(catch 'up-to-date (if (catch 'up-to-date
(let ((buf (autoload-find-destination file))) (with-current-buffer (autoload-find-destination file)
(with-current-buffer buf (setq no-autoloads (generate-file-autoloads file))
(let ((no-autoloads (generate-file-autoloads file))) t))
(if save-after (autoload-save-buffers))
(and save-after (if (interactive-p)
(buffer-modified-p) (message "Autoload section for %s is up to date." file))))
(save-buffer)) ;; If we caught `up-to-date', it means there are autoload entries, since
;; otherwise we wouldn't have detected their up-to-dateness.
(if no-autoloads file)))))))) (if no-autoloads file)))
(defun autoload-find-destination (file) (defun autoload-find-destination (file)
"Find the destination point of the current buffer's autoloads. "Find the destination point of the current buffer's autoloads.
...@@ -486,6 +494,8 @@ to call it from a dummy buffer if FILE is not currently visited." ...@@ -486,6 +494,8 @@ to call it from a dummy buffer if FILE is not currently visited."
;; No later sections in the file. Put before the last page. ;; No later sections in the file. Put before the last page.
(goto-char (point-max)) (goto-char (point-max))
(search-backward "\f" nil t))) (search-backward "\f" nil t)))
(unless (memq (current-buffer) autoload-modified-buffers)
(push (current-buffer) autoload-modified-buffers))
(current-buffer)))) (current-buffer))))
(defun autoload-remove-section (begin) (defun autoload-remove-section (begin)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment