[gnus git] branch master updated: =1= gnus-util: change default value of gnus-user-date-format-alist
Julien Danjou <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 5620c24a0351a007eba58deada3a1c3eada7cb4a (commit)
from 32b306203222e469b85f8e6f368d7e6489d8746c (commit)
- Log -----------------------------------------------------------------
commit 5620c24a0351a007eba58deada3a1c3eada7cb4a
Author: Julien Danjou <[email protected]>
Date: Thu Feb 3 14:13:46 2011 +0100
gnus-util: change default value of gnus-user-date-format-alist
Signed-off-by: Julien Danjou <[email protected]>
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1b72138..ebe2b02 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2011-02-03 Julien Danjou <[email protected]>
+
+ * 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 <[email protected]>
* nnimap.el (gnus-fetch-headers): Declare.
diff --git a/lisp/gnus-sum.el b/lisp/gnus-sum.el
index 3b003b7..c40fcc7 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 d298c71..67c4909 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 0b84038..afbef3b 100644
--- a/lisp/gnus.el
+++ b/lisp/gnus.el
@@ -2909,7 +2909,8 @@ 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)
+%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)
@@ -2918,7 +2919,8 @@ with some simple extensions.
%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
+%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)
@@ -2927,11 +2929,15 @@ with some simple extensions.
%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 \" \")
+ 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)
@@ -2945,12 +2951,16 @@ with some simple extensions.
%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.
+%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 dac0952..d89493c 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
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 9 +++++
lisp/gnus-sum.el | 52 +++++++++++++++++++++++++++-
lisp/gnus-util.el | 45 ------------------------
lisp/gnus.el | 98 +++++++++++++++++++++++++++++------------------------
texi/gnus.texi | 2 +-
5 files changed, 115 insertions(+), 91 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project