changeset 71047:e98e3d0ee915

(autoload-find-file): New fun. This one calls hack-local-variables. (generate-file-autoloads, update-file-autoloads): Use it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 29 May 2006 02:11:27 +0000
parents 7a762d10d1a2
children 29150c5d541b
files lisp/ChangeLog lisp/emacs-lisp/autoload.el
diffstat 2 files changed, 34 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon May 29 01:58:27 2006 +0000
+++ b/lisp/ChangeLog	Mon May 29 02:11:27 2006 +0000
@@ -1,5 +1,9 @@
 2006-05-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+	* emacs-lisp/autoload.el (autoload-find-file): New fun.
+	This one calls hack-local-variables.
+	(generate-file-autoloads, update-file-autoloads): Use it.
+
 	* textmodes/bibtex.el (bibtex-autokey-name-case-convert-function)
 	(bibtex-sort-entry-class): Add safe-local-variable predicate.
 	(bibtex-sort-entry-class-alist): Don't set the global value.
--- a/lisp/emacs-lisp/autoload.el	Mon May 29 01:58:27 2006 +0000
+++ b/lisp/emacs-lisp/autoload.el	Mon May 29 02:11:27 2006 +0000
@@ -273,6 +273,20 @@
 	(or (eolp)
 	    (insert "\n" generate-autoload-section-continuation))))))
 
+(defun autoload-find-file (file)
+  "Fetch file and put it in a temp buffer.  Return the buffer."
+  ;; It is faster to avoid visiting the file.
+  (with-current-buffer (get-buffer-create " *autoload-file*")
+    (kill-all-local-variables)
+    (erase-buffer)
+    (setq buffer-undo-list t
+          buffer-read-only nil)
+    (emacs-lisp-mode)
+    (insert-file-contents file nil)
+    (let ((enable-local-variables :safe))
+      (hack-local-variables))
+    (current-buffer)))
+
 (defun generate-file-autoloads (file)
   "Insert at point a loaddefs autoload section for FILE.
 autoloads are generated for defuns and defmacros in FILE
@@ -313,16 +327,9 @@
     (save-excursion
       (unwind-protect
 	  (progn
-	    (if visited
-		(set-buffer visited)
-	      ;; It is faster to avoid visiting the file.
-	      (set-buffer (get-buffer-create " *generate-autoload-file*"))
-	      (kill-all-local-variables)
-	      (erase-buffer)
-	      (setq buffer-undo-list t
-		    buffer-read-only nil)
-	      (emacs-lisp-mode)
-	      (insert-file-contents file nil))
+	    (set-buffer (or visited
+                            ;; It is faster to avoid visiting the file.
+                            (autoload-find-file file)))
 	    (save-excursion
 	      (save-restriction
 		(widen)
@@ -340,8 +347,7 @@
 					       (or (bolp) (forward-line 1))))
 			       (autoload (make-autoload form load-name)))
 			  (if autoload
-			      (setq autoloads-done (cons (nth 1 form)
-							 autoloads-done))
+			      (push (nth 1 form) autoloads-done)
 			    (setq autoload form))
 			  (let ((autoload-print-form-outbuf outbuf))
 			    (autoload-print-form autoload)))
@@ -460,31 +466,22 @@
 	      (and (eq found 'new)
 		   ;; Check that FILE has any cookies before generating a
 		   ;; new section for it.
-		   (save-excursion
-		     (if existing-buffer
-			 (set-buffer existing-buffer)
-		       ;; It is faster to avoid visiting the file.
-		       (set-buffer (get-buffer-create " *autoload-file*"))
-		       (kill-all-local-variables)
-		       (erase-buffer)
-		       (setq buffer-undo-list t
-			     buffer-read-only nil)
-		       (emacs-lisp-mode)
-		       (insert-file-contents file nil))
-		     (save-excursion
+		   (with-current-buffer
+                       (or existing-buffer
+                           ;; It is faster to avoid visiting the file.
+                           (autoload-find-file file))
+                     (save-excursion
 		       (save-restriction
 			 (widen)
 			 (goto-char (point-min))
 			 (prog1
-			     (if (re-search-forward
-				  (concat "^" (regexp-quote
-					       generate-autoload-cookie))
-				  nil t)
-				 nil
-			       (if (interactive-p)
-				   (message "%s has no autoloads" file))
-			       (setq no-autoloads t)
-			       t)
+			     (setq no-autoloads
+                                   (not (re-search-forward
+                                         (concat "^" (regexp-quote
+                                                      generate-autoload-cookie))
+                                         nil t)))
+                           (if (and no-autoloads (interactive-p))
+                               (message "%s has no autoloads" file))
 			   (or existing-buffer
 			       (kill-buffer (current-buffer))))))))
 	      (generate-file-autoloads file))))