From: Julien Danjou Date: Thu, 3 Feb 2011 13:13:46 +0000 (+0100) Subject: gnus-util: change default value of gnus-user-date-format-alist X-Git-Url: https://cgit.sxemacs.org/?a=commitdiff_plain;h=5620c24a0351a007eba58deada3a1c3eada7cb4a;p=gnus gnus-util: change default value of gnus-user-date-format-alist Signed-off-by: Julien Danjou --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1b7213816..ebe2b023c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2011-02-03 Julien Danjou + + * gnus.el (gnus-summary-line-format): Mention &user-date format in + docstring. + + * gnus.el (gnus-user-date-format-alist): Change default value. Use + defcustom, with type and group. Move from gnus-util.el. Rename to + gnus-summary-user-date-format-alist. + 2011-02-03 Glenn Morris * nnimap.el (gnus-fetch-headers): Declare. diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el index 3b003b746..c40fcc7fe 100644 --- a/lisp/gnus-sum.el +++ b/lisp/gnus-sum.el @@ -1395,7 +1395,7 @@ the normal Gnus MIME machinery." (?u gnus-tmp-user-defined ?s) (?P (gnus-pick-line-number) ?d) (?B gnus-tmp-thread-tree-header-string ?s) - (user-date (gnus-user-date + (user-date (gnus-summary-user-date ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s)) "An alist of format specifications that can appear in summary lines. These are paired with what variables they correspond with, along with @@ -3852,6 +3852,56 @@ This function is intended to be used in ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024)))) (t (format "%dM" (/ c (* 1024.0 1024))))))) +(defcustom gnus-summary-user-date-format-alist + '(((gnus-seconds-today) . "Today, %H:%M") + ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M") + (604800 . "%A %H:%M") ; That's one week + ((gnus-seconds-month) . "%A %d") + ((gnus-seconds-year) . "%B %d") + (t . "%b %d %Y")) ; This one is used when no other + ; does match + "Specifies date format depending on age of article. +This is an alist of items (AGE . FORMAT). AGE can be a number (of +seconds) or a Lisp expression evaluating to a number. When the age of +the article is less than this number, then use `format-time-string' +with the corresponding FORMAT for displaying the date of the article. +If AGE is not a number or a Lisp expression evaluating to a +non-number, then the corresponding FORMAT is used as a default value. + +Note that the list is processed from the beginning, so it should be +sorted by ascending AGE. Also note that items following the first +non-number AGE will be ignored. + +You can use the functions `gnus-seconds-today', `gnus-seconds-month' +and `gnus-seconds-year' in the AGE spec. They return the number of +seconds passed since the start of today, of this month, of this year, +respectively." + :version "24.1" + :group 'gnus-summary-format + :type '(alist :key-type sexp :value-type string)) +(make-obsolete-variable 'gnus-user-date-format-alist + 'gnus-summary-user-date-format-alist "24.1") + +(defun gnus-summary-user-date (messy-date) + "Format the messy-date according to `gnus-summary-user-date-format-alist'. +Returns \" ? \" if there's bad input or if another error occurs. +Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"." + (condition-case () + (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date))) + (now (gnus-float-time)) + ;;If we don't find something suitable we'll use this one + (my-format "%b %d '%y")) + (let* ((difference (- now messy-date)) + (templist gnus-summary-user-date-format-alist) + (top (eval (caar templist)))) + (while (if (numberp top) (< top difference) (not top)) + (progn + (setq templist (cdr templist)) + (setq top (eval (caar templist))))) + (if (stringp (cdr (car templist))) + (setq my-format (cdr (car templist))))) + (format-time-string (eval my-format) (seconds-to-time messy-date))) + (error " ? "))) (defun gnus-summary-set-local-parameters (group) "Go through the local params of GROUP and set all variable specs in that list." diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el index d298c7154..67c49096b 100644 --- a/lisp/gnus-util.el +++ b/lisp/gnus-util.el @@ -477,51 +477,6 @@ Cache the result as a text property stored in DATE." (put-text-property 0 1 'gnus-time time d) time))))) -(defvar gnus-user-date-format-alist - '(((gnus-seconds-today) . "%k:%M") - (604800 . "%a %k:%M") ;;that's one week - ((gnus-seconds-month) . "%a %d") - ((gnus-seconds-year) . "%b %d") - (t . "%b %d '%y")) ;;this one is used when no - ;;other does match - "Specifies date format depending on age of article. -This is an alist of items (AGE . FORMAT). AGE can be a number (of -seconds) or a Lisp expression evaluating to a number. When the age of -the article is less than this number, then use `format-time-string' -with the corresponding FORMAT for displaying the date of the article. -If AGE is not a number or a Lisp expression evaluating to a -non-number, then the corresponding FORMAT is used as a default value. - -Note that the list is processed from the beginning, so it should be -sorted by ascending AGE. Also note that items following the first -non-number AGE will be ignored. - -You can use the functions `gnus-seconds-today', `gnus-seconds-month' -and `gnus-seconds-year' in the AGE spec. They return the number of -seconds passed since the start of today, of this month, of this year, -respectively.") - -(defun gnus-user-date (messy-date) - "Format the messy-date according to gnus-user-date-format-alist. -Returns \" ? \" if there's bad input or if another error occurs. -Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"." - (condition-case () - (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date))) - (now (gnus-float-time)) - ;;If we don't find something suitable we'll use this one - (my-format "%b %d '%y")) - (let* ((difference (- now messy-date)) - (templist gnus-user-date-format-alist) - (top (eval (caar templist)))) - (while (if (numberp top) (< top difference) (not top)) - (progn - (setq templist (cdr templist)) - (setq top (eval (caar templist))))) - (if (stringp (cdr (car templist))) - (setq my-format (cdr (car templist))))) - (format-time-string (eval my-format) (seconds-to-time messy-date))) - (error " ? "))) - (defun gnus-dd-mmm (messy-date) "Return a string like DD-MMM from a big messy string." (condition-case () diff --git a/lisp/gnus.el b/lisp/gnus.el index 0b8403837..afbef3b22 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el @@ -2907,50 +2907,60 @@ gnus-registry.el will populate this if it's loaded.") It works along the same lines as a normal formatting string, with some simple extensions. -%N Article number, left padded with spaces (string) -%S Subject (string) -%s Subject if it is at the root of a thread, and \"\" otherwise (string) -%n Name of the poster (string) -%a Extracted name of the poster (string) -%A Extracted address of the poster (string) -%F Contents of the From: header (string) -%f Contents of the From: or To: headers (string) -%x Contents of the Xref: header (string) -%D Date of the article (string) -%d Date of the article (string) in DD-MMM format -%o Date of the article (string) in YYYYMMDD`T'HHMMSS format -%M Message-id of the article (string) -%r References of the article (string) -%c Number of characters in the article (integer) -%k Pretty-printed version of the above (string) - For example, \"1.2k\" or \"0.4M\". -%L Number of lines in the article (integer) -%I Indentation based on thread level (a string of spaces) -%B A complex trn-style thread tree (string) - The variables `gnus-sum-thread-*' can be used for customization. -%T A string with two possible values: 80 spaces if the article - is on thread level two or larger and 0 spaces on level one -%R \"A\" if this article has been replied to, \" \" otherwise (character) -%U Status of this article (character, \"R\", \"K\", \"-\" or \" \") -%[ Opening bracket (character, \"[\" or \"<\") -%] Closing bracket (character, \"]\" or \">\") -%> Spaces of length thread-level (string) -%< Spaces of length (- 20 thread-level) (string) -%i Article score (number) -%z Article zcore (character) -%t Number of articles under the current thread (number). -%e Whether the thread is empty or not (character). -%V Total thread score (number). -%P The line number (number). -%O Download mark (character). -%* If present, indicates desired cursor position - (instead of after first colon). -%u User defined specifier. The next character in the format string should - be a letter. Gnus will call the function gnus-user-format-function-X, - where X is the letter following %u. The function will be passed the - current header as argument. The function should return a string, which - will be inserted into the summary just like information from any other - summary specifier. +%N Article number, left padded with spaces (string) +%S Subject (string) +%s Subject if it is at the root of a thread, and \"\" + otherwise (string) +%n Name of the poster (string) +%a Extracted name of the poster (string) +%A Extracted address of the poster (string) +%F Contents of the From: header (string) +%f Contents of the From: or To: headers (string) +%x Contents of the Xref: header (string) +%D Date of the article (string) +%d Date of the article (string) in DD-MMM format +%o Date of the article (string) in YYYYMMDD`T'HHMMSS + format +%M Message-id of the article (string) +%r References of the article (string) +%c Number of characters in the article (integer) +%k Pretty-printed version of the above (string) + For example, \"1.2k\" or \"0.4M\". +%L Number of lines in the article (integer) +%I Indentation based on thread level (a string of spaces) +%B A complex trn-style thread tree (string) + The variables `gnus-sum-thread-*' can be used for + customization. +%T A string with two possible values: 80 spaces if the + article is on thread level two or larger and 0 spaces + on level one +%R \"A\" if this article has been replied to, \" \" + otherwise (character) +%U Status of this article (character, \"R\", \"K\", \"-\" + or \" \") +%[ Opening bracket (character, \"[\" or \"<\") +%] Closing bracket (character, \"]\" or \">\") +%> Spaces of length thread-level (string) +%< Spaces of length (- 20 thread-level) (string) +%i Article score (number) +%z Article zcore (character) +%t Number of articles under the current thread (number). +%e Whether the thread is empty or not (character). +%V Total thread score (number). +%P The line number (number). +%O Download mark (character). +%* If present, indicates desired cursor position + (instead of after first colon). +%u User defined specifier. The next character in the + format string should be a letter. Gnus will call the + function gnus-user-format-function-X, where X is the + letter following %u. The function will be passed the + current header as argument. The function should return + a string, which will be inserted into the summary just + like information from any other summary specifier. +&user-date Age sensitive date format. Various date format is + defined in `gnus-summary-user-date-format-alist'. + The %U (status), %R (replied) and %z (zcore) specs have to be handled with care. For reasons of efficiency, Gnus will compute what column diff --git a/texi/gnus.texi b/texi/gnus.texi index dac095217..d89493c6c 100644 --- a/texi/gnus.texi +++ b/texi/gnus.texi @@ -4941,7 +4941,7 @@ Download mark. Desired cursor position (instead of after first colon). @item &user-date; Age sensitive date format. Various date format is defined in -@code{gnus-user-date-format-alist}. +@code{gnus-summary-user-date-format-alist}. @item u User defined specifier. The next character in the format string should be a letter. Gnus will call the function