*** empty log message ***
[gnus] / lisp / gnus-util.el
index fbbe712..6ce52ae 100644 (file)
 ;;; Code:
 
 (require 'custom)
-(require 'cl)
+(eval-when-compile (require 'cl))
 (require 'nnheader)
 (require 'timezone)
 (require 'message)
 
+(eval-and-compile
+  (autoload 'nnmail-date-to-time "nnmail"))
+
 (defun gnus-boundp (variable)
   "Return non-nil if VARIABLE is bound and non-nil."
   (and (boundp variable)
@@ -86,7 +89,8 @@
 (defsubst gnus-functionp (form)
   "Return non-nil if FORM is funcallable."
   (or (and (symbolp form) (fboundp form))
-      (and (listp form) (eq (car form) 'lambda))))
+      (and (listp form) (eq (car form) 'lambda))
+      (compiled-function-p form)))
 
 (defsubst gnus-goto-char (point)
   (and point (goto-char point)))
 (defun gnus-byte-code (func)
   "Return a form that can be `eval'ed based on FUNC."
   (let ((fval (symbol-function func)))
-    (if (byte-code-function-p fval)
+    (if (compiled-function-p fval)
        (let ((flist (append fval nil)))
          (setcar flist 'byte-code)
          flist)
         (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
         (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
     (encode-time (caddr time) (cadr time) (car time)
-                (caddr date) (cadr date) (car date) (nth 4 date))))
+                (caddr date) (cadr date) (car date)
+                (* 60 (timezone-zone-to-minute (nth 4 date))))))
 
 (defun gnus-time-minus (t1 t2)
   "Subtract two internal times."
 
 (defun gnus-completing-read (default prompt &rest args)
   ;; Like `completing-read', except that DEFAULT is the default argument.
-  (let* ((prompt (if default 
+  (let* ((prompt (if default
                     (concat prompt " (default " default ") ")
                   (concat prompt " ")))
         (answer (apply 'completing-read prompt args)))
@@ -372,11 +377,11 @@ Cache the result as a text property stored in DATE."
 (defsubst gnus-time-iso8601 (time)
   "Return a string of TIME in YYMMDDTHHMMSS format."
   (format-time-string "%Y%m%dT%H%M%S" time))
-  
+
 (defun gnus-date-iso8601 (header)
   "Convert the date field in HEADER to YYMMDDTHHMMSS"
   (condition-case ()
-      (gnus-time-iso8601 (gnus-date-get-time (mail-header-date header)))
+      (gnus-time-iso8601 (gnus-date-get-time header))
     (error "")))
 
 (defun gnus-mode-string-quote (string)
@@ -453,9 +458,11 @@ jabbering all the time."
 If N, return the Nth ancestor instead."
   (when references
     (let ((ids (inline (gnus-split-references references))))
-      (car (last ids (or n 1))))))
+      (while (nthcdr (or n 1) ids)
+       (setq ids (cdr ids)))
+      (car ids))))
 
-(defun gnus-buffer-live-p (buffer)
+(defsubst gnus-buffer-live-p (buffer)
   "Say whether BUFFER is alive or not."
   (and buffer
        (get-buffer buffer)
@@ -478,7 +485,7 @@ If N, return the Nth ancestor instead."
       (goto-char orig)
       ;; Scroll horizontally to center (sort of) the point.
       (if (> max (window-width))
-         (set-window-hscroll 
+         (set-window-hscroll
           (get-buffer-window (current-buffer) t)
           (min (- (current-column) (/ (window-width) 3))
                (+ 2 (- max (window-width)))))
@@ -496,8 +503,8 @@ If N, return the Nth ancestor instead."
 Timezone package is used."
   (condition-case ()
       (progn
-       (setq date (inline (timezone-fix-time 
-                           date nil 
+       (setq date (inline (timezone-fix-time
+                           date nil
                            (aref (inline (timezone-parse-date date)) 4))))
        (inline
          (timezone-make-sortable-date
@@ -506,7 +513,7 @@ Timezone package is used."
             (timezone-make-time-string
              (aref date 3) (aref date 4) (aref date 5))))))
     (error "")))
-  
+
 (defun gnus-copy-file (file &optional to)
   "Copy FILE to TO."
   (interactive
@@ -521,10 +528,10 @@ Timezone package is used."
 
 (defun gnus-kill-all-overlays ()
   "Delete all overlays in the current buffer."
-  (when (fboundp 'overlay-lists)
+  (unless gnus-xemacs
     (let* ((overlayss (overlay-lists))
           (buffer-read-only nil)
-          (overlays (nconc (car overlayss) (cdr overlayss))))
+          (overlays (delq nil (nconc (car overlayss) (cdr overlayss)))))
       (while overlays
        (delete-overlay (pop overlays))))))
 
@@ -549,7 +556,7 @@ Timezone package is used."
 
 (defun gnus-make-sort-function (funs)
   "Return a composite sort condition based on the functions in FUNC."
-  (cond 
+  (cond
    ((not (listp funs)) funs)
    ((null funs) funs)
    ((cdr funs)
@@ -704,6 +711,7 @@ with potentially long computations."
 
 ;;; Functions for saving to babyl/mail files.
 
+(defvar rmail-default-rmail-file)
 (defun gnus-output-to-rmail (filename &optional ask)
   "Append the current article to an Rmail file named FILENAME."
   (require 'rmail)