(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))
(message "")))
;; I suspect there's a better way, but I haven't taken the time to do
-;; it yet. -erik selberg@cs.washington.edu
+;; it yet. -erik selberg@cs.washington.edu
(defun gnus-dd-mmm (messy-date)
"Return a string like DD-MMM from a big messy string"
(let ((datevec (condition-case () (timezone-parse-date messy-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
(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."
+ (when references
+ (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."
(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)
+ "Return a composite sort condition based on the functions in FUNC."
+ (cond
+ ((not (listp funs)) funs)
+ ((null funs) funs)
+ ((cdr funs)
+ `(lambda (t1 t2)
+ ,(gnus-make-sort-function-1 (reverse funs))))
+ (t
+ (car funs))))
+
+(defun gnus-make-sort-function-1 (funs)
"Return a composite sort condition based on the functions in FUNC."
(if (cdr funs)
`(or (,(car funs) t1 t2)
(and (not (,(car funs) t2 t1))
- ,(gnus-make-sort-function (cdr funs))))
+ ,(gnus-make-sort-function-1 (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))
+
+(defun gnus-make-directory (directory)
+ "Make DIRECTORY (and all its parents) if it doesn't exist."
+ (when (not (file-exists-p directory))
+ (make-directory directory t))
+ t)
+
(provide 'gnus-util)
;;; gnus-util.el ends here