(article-transform-date): Fix infinite recursion.
[gnus] / lisp / gnus-util.el
index 1f391f0..d298c71 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
@@ -39,6 +38,8 @@
 (eval-when-compile
   (require 'cl))
 
+(require 'time-date)
+
 (defcustom gnus-completing-read-function 'gnus-emacs-completing-read
   "Function use to do completing read."
   :version "24.1"
@@ -332,10 +333,11 @@ Symbols are also allowed; their print names are used instead."
        (and (= (car fdate) (car date))
             (> (nth 1 fdate) (nth 1 date))))))
 
+;; Every version of Emacs Gnus supports has built-in float-time.
+;; The featurep test silences an irritating compiler warning.
 (eval-and-compile
   (if (or (featurep 'emacs)
-         (and (fboundp 'float-time)
-              (subrp (symbol-function 'float-time))))
+         (fboundp 'float-time))
       (defalias 'gnus-float-time 'float-time)
     (defun gnus-float-time (&optional time)
       "Convert time value TIME to a floating point number.
@@ -902,6 +904,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 +1140,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 +1232,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 +2039,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)