gnus-util: change default value of gnus-user-date-format-alist
authorJulien Danjou <julien@danjou.info>
Thu, 3 Feb 2011 13:13:46 +0000 (14:13 +0100)
committerJulien Danjou <julien@danjou.info>
Thu, 3 Feb 2011 13:59:04 +0000 (14:59 +0100)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/gnus-sum.el
lisp/gnus-util.el
lisp/gnus.el
texi/gnus.texi

index 1b72138..ebe2b02 100644 (file)
@@ -1,3 +1,12 @@
+2011-02-03  Julien Danjou  <julien@danjou.info>
+
+       * 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  <rgm@gnu.org>
 
        * nnimap.el (gnus-fetch-headers): Declare.
index 3b003b7..c40fcc7 100644 (file)
@@ -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."
index d298c71..67c4909 100644 (file)
@@ -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 ()
index 0b84038..afbef3b 100644 (file)
@@ -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
index dac0952..d89493c 100644 (file)
@@ -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