*** empty log message ***
[gnus] / lisp / gnus-util.el
index 9eea286..8fc3812 100644 (file)
     (timezone-absolute-from-gregorian
      (nth 1 dat) (nth 2 dat) (car dat))))
 
+(defun gnus-time-to-day (time)
+  "Convert TIME to day number."
+  (let ((tim (decode-time time)))
+    (timezone-absolute-from-gregorian
+     (nth 4 tim) (nth 3 tim) (nth 5 tim))))
+
 (defun gnus-encode-date (date)
   "Convert DATE to internal time."
   (let* ((parse (timezone-parse-date date))
                         timezone-months-assoc))
                   "???"))))))
 
+(defun gnus-date-iso8601 (header)
+  "Convert the date field in HEADER to YYMMDDTHHMMSS"
+  (condition-case ()
+      (format-time-string "%Y%m%dT%H%M%S"
+                         (nnmail-date-to-time (mail-header-date header)))
+    (error "")))
+
 (defun gnus-mode-string-quote (string)
   "Quote all \"%\" in STRING."
   (save-excursion
@@ -394,11 +407,11 @@ jabbering all the time.")
        (sit-for duration))))
   nil)
 
-(defun gnus-parent-id (references)
-  "Return the last Message-ID in REFERENCES."
-  (when (and references
-            (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
-    (substring references (match-beginning 1) (match-end 1))))
+(defun gnus-parent-id (references &optional n)
+  "Return the last Message-ID in REFERENCES.
+If N, return the Nth ancestor instead."
+  (let ((ids (gnus-split-references references)))
+    (car (last ids (or n 1)))))
 
 (defun gnus-split-references (references)
   "Return a list of Message-IDs in REFERENCES."
@@ -495,8 +508,8 @@ Timezone package is used."
 (defmacro gnus-group-real-name (group)
   "Find the real name of a foreign newsgroup."
   `(let ((gname ,group))
-     (if (string-match ":[^:]+$" gname)
-        (substring gname (1+ (match-beginning 0)))
+     (if (string-match "^[^:]+:" gname)
+        (substring gname (match-end 0))
        gname)))
 
 (defun gnus-make-sort-function (funs)
@@ -506,7 +519,22 @@ Timezone package is used."
           (and (not (,(car funs) t2 t1))
                ,(gnus-make-sort-function (cdr funs))))
     `(,(car funs) t1 t2)))
-                
+
+(defun gnus-turn-off-edit-menu (type)
+  "Turn off edit meny in `gnus-TYPE-mode-map'."
+  (define-key (symbol-value (intern (format "gnus-%s-mode-map" type)))
+    [menu-bar edit] 'undefined))
+
+(defun gnus-prin1 (form)
+  "Use `prin1' on FORM in the current buffer.
+Bind `print-quoted' to t while printing."
+  (let ((print-quoted t))
+    (prin1 form (current-buffer))))
+
+(defun gnus-prin1-to-string (form)
+  "The same as `prin1', but but `print-quoted' to t."
+  (prin1-to-string form))
 (provide 'gnus-util)
 
 ;;; gnus-util.el ends here