X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgnus-util.el;h=8fc3812779d1c0a6db495bf09c4a66137810f55c;hb=1a96d7bf660263f25557962103bc0ec2495d1d07;hp=9eea286511d53f333ef0775de7430d0f9a9800a2;hpb=c0931b6e45bf6fef08d57a55408d58919f6f076f;p=gnus diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el index 9eea28651..8fc381277 100644 --- a/lisp/gnus-util.el +++ b/lisp/gnus-util.el @@ -228,6 +228,12 @@ (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)) @@ -340,6 +346,13 @@ 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