[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v |
Date: |
Mon, 25 Jun 2007 03:01:23 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 07/06/25 03:01:23
Index: emacs-lisp/autoload.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/autoload.el,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -b -r1.120 -r1.121
--- emacs-lisp/autoload.el 23 Jun 2007 20:31:31 -0000 1.120
+++ emacs-lisp/autoload.el 25 Jun 2007 03:01:21 -0000 1.121
@@ -412,29 +412,50 @@
Return FILE if there was no autoload cookie in it, else nil."
(interactive "fUpdate autoloads for file: \np")
+ (let ((existing-buffer (get-file-buffer file)))
+ (with-temp-buffer
+ ;; Let's presume the file is not visited, so we call
+ ;; autoload-find-destination from a dummy buffer, except if the file
+ ;; is visited, in which case we use that buffer instead.
+ (if existing-buffer (set-buffer existing-buffer))
+
+ (catch 'up-to-date
+ (let ((buf (autoload-find-destination file)))
+ (with-current-buffer buf
+ (let ((no-autoloads (generate-file-autoloads file)))
+
+ (and save-after
+ (buffer-modified-p)
+ (save-buffer))
+
+ (if no-autoloads file))))))))
+
+(defun autoload-find-destination (file)
+ "Find the destination point of the current buffer's autoloads.
+FILE is the file name of the current buffer.
+Returns a buffer whose point is placed at the requested location.
+Throws `up-to-date' if the file's autoloads are uptodate, otherwise
+removes any prior now out-of-date autoload entries.
+The current buffer only matters if it is visiting a file or if it has a
buffer-local
+value for some variables such as `generated-autoload-file', so it's OK
+to call it from a dummy buffer if FILE is not currently visited."
+ ;; (message "autoload-find-destination %S" file)
(let ((load-name (autoload-file-load-name file))
- (found nil)
- (existing-buffer (get-file-buffer file))
- (no-autoloads nil))
- (save-excursion
- ;; We want to get a value for generated-autoload-file from
- ;; the local variables section if it's there.
- (if existing-buffer
- (set-buffer existing-buffer))
+ (existing-buffer (if buffer-file-name (current-buffer)))
+ (found nil))
+ (with-current-buffer
;; We must read/write the file without any code conversion,
;; but still decode EOLs.
(let ((coding-system-for-read 'raw-text))
- (set-buffer (find-file-noselect
+ (find-file-noselect
(autoload-ensure-default-file (autoload-generated-file))))
;; This is to make generated-autoload-file have Unix EOLs, so
;; that it is portable to all platforms.
- (setq buffer-file-coding-system 'raw-text-unix))
+ (setq buffer-file-coding-system 'raw-text-unix)
(or (> (buffer-size) 0)
(error "Autoloads file %s does not exist" buffer-file-name))
(or (file-writable-p buffer-file-name)
(error "Autoloads file %s is not writable" buffer-file-name))
- (save-excursion
- (save-restriction
(widen)
(goto-char (point-min))
;; Look for the section for LOAD-NAME.
@@ -451,14 +472,8 @@
(not (buffer-modified-p existing-buffer)))
(listp last-time) (= (length last-time) 2)
(not (time-less-p last-time file-time)))
- (progn
- (if (interactive-p)
- (message "\
-Autoload section for %s is up to date."
- file))
- (setq found 'up-to-date))
- (search-forward generate-autoload-section-trailer)
- (delete-region begin (point))
+ (throw 'up-to-date nil)
+ (autoload-remove-section (match-beginning 0))
(setq found t))))
((string< load-name (nth 2 form))
;; We've come to a section alphabetically later than
@@ -466,20 +481,13 @@
;; there must be no section for LOAD-NAME. We will
;; insert one before the section here.
(goto-char (match-beginning 0))
- (setq found 'new)))))
+ (setq found t)))))
(or found
(progn
- (setq found 'new)
;; No later sections in the file. Put before the last page.
(goto-char (point-max))
(search-backward "\f" nil t)))
- (or (eq found 'up-to-date)
- (setq no-autoloads (generate-file-autoloads file)))))
- (and save-after
- (buffer-modified-p)
- (save-buffer))
-
- (if no-autoloads file))))
+ (current-buffer))))
(defun autoload-remove-section (begin)
(goto-char begin)
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v, Stefan Monnier, 2007/06/23
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v, Stefan Monnier, 2007/06/24
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v, Stefan Monnier, 2007/06/25
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v, Stefan Monnier, 2007/06/25
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v, Stefan Monnier, 2007/06/26
- [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/autoload.el,v, Stefan Monnier, 2007/06/26