autoloading eval-when forms
[bpt/emacs.git] / lisp / emacs-lisp / autoload.el
index e531bc0..9bd7cc1 100644 (file)
@@ -1,6 +1,6 @@
 ;; autoload.el --- maintain autoloads in loaddefs.el  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1991-1997, 2001-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1997, 2001-2014 Free Software Foundation, Inc.
 
 ;; Author: Roland McGrath <roland@gnu.org>
 ;; Keywords: maint
@@ -127,7 +127,9 @@ expression, in which case we want to handle forms differently."
         ;; (message "autoload of %S" (nth 1 form))
         `(autoload ,(nth 1 form) ,file ,doc ,interactive ,type)))
 
-     ((and expansion (memq car '(progn prog1)))
+     ((and expansion
+           (or (memq car '(progn prog1))
+               (and (eq car 'eval-when) (setq form (cdr form)))))
       (let ((end (memq :autoload-end form)))
        (when end             ;Cut-off anything after the :autoload-end marker.
           (setq form (copy-sequence form))
@@ -528,6 +530,9 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
                (if (stringp generated-autoload-load-name)
                    generated-autoload-load-name
                  (autoload-file-load-name absfile)))
+          ;; FIXME? Comparing file-names for equality with just equal
+          ;; is fragile, eg if one has an automounter prefix and one
+          ;; does not, but both refer to the same physical file.
           (when (and outfile
                      (not
                      (if (memq system-type '(ms-dos windows-nt))
@@ -553,7 +558,7 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
                           (princ `(push (purecopy
                                              ',(cons (intern package) version))
                                         package--builtin-versions))
-                         (newline)))))
+                         (princ "\n")))))
 
               (goto-char (point-min))
               (while (not (eobp))