Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / lisp / gnus / gnus-util.el
index 1f391f0..fc3c0b4 100644 (file)
@@ -1,7 +1,6 @@
 ;;; gnus-util.el --- utility functions for Gnus
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
@@ -902,6 +901,7 @@ Bind `print-quoted' and `print-readably' to t, and `print-length' and
 
 (defun gnus-write-buffer (file)
   "Write the current buffer's contents to FILE."
+  (require 'nnmail)
   (let ((file-name-coding-system nnmail-pathname-coding-system))
     ;; Make sure the directory exists.
     (gnus-make-directory (file-name-directory file))
@@ -1137,6 +1137,7 @@ In Emacs 22 this writes Babyl format; in Emacs 23 it writes mbox unless
 FILENAME exists and is Babyl format."
   (require 'rmail)
   (require 'mm-util)
+  (require 'nnmail)
   ;; Some of this codes is borrowed from rmailout.el.
   (setq filename (expand-file-name filename))
   ;; FIXME should we really be messing with this defcustom?
@@ -1228,6 +1229,7 @@ FILENAME exists and is Babyl format."
 
 (defun gnus-output-to-mail (filename &optional ask)
   "Append the current article to a mail file named FILENAME."
+  (require 'nnmail)
   (setq filename (expand-file-name filename))
   (let ((artbuf (current-buffer))
        (tmpbuf (get-buffer-create " *Gnus-output*")))
@@ -2034,22 +2036,26 @@ Same as `string-match' except this function does not change the match data."
     (save-match-data
       (string-match regexp string start))))
 
-(if (fboundp 'macroexpand-all)
-    (defalias 'gnus-macroexpand-all 'macroexpand-all)
-  (defun gnus-macroexpand-all (form)
-    "Return result of expanding macros at all levels in FORM.
-If no macros are expanded, FORM is returned unchanged."
-    (if (consp form)
-       (let ((idx 1)
-             (len (length (setq form (copy-sequence form))))
-             expanded)
-         (while (< idx len)
-           (setcar (nthcdr idx form) (gnus-macroexpand-all (nth idx form)))
-           (setq idx (1+ idx)))
-         (if (eq (setq expanded (macroexpand form)) form)
-             form
-           (gnus-macroexpand-all expanded)))
-      form)))
+(eval-and-compile
+  (if (fboundp 'macroexpand-all)
+      (defalias 'gnus-macroexpand-all 'macroexpand-all)
+    (defun gnus-macroexpand-all (form &optional environment)
+      "Return result of expanding macros at all levels in FORM.
+If no macros are expanded, FORM is returned unchanged.
+The second optional arg ENVIRONMENT specifies an environment of macro
+definitions to shadow the loaded ones for use in file byte-compilation."
+      (if (consp form)
+         (let ((idx 1)
+               (len (length (setq form (copy-sequence form))))
+               expanded)
+           (while (< idx len)
+             (setcar (nthcdr idx form) (gnus-macroexpand-all (nth idx form)
+                                                             environment))
+             (setq idx (1+ idx)))
+           (if (eq (setq expanded (macroexpand form environment)) form)
+               form
+             (gnus-macroexpand-all expanded environment)))
+       form))))
 
 (provide 'gnus-util)