Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] age depending date-format
@ 2001-10-16 19:42 Frank Schmitt
  2001-10-16 20:52 ` ShengHuo ZHU
                   ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Frank Schmitt @ 2001-10-16 19:42 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

Hi

I did some more testing and error handling on my code I posted in  
<archive.pu7pc20r.fsf@hschmi22.userfqdn.rz-online.de>.

It should work without problems. What it does is the following:
Add a new item (%q) to gnus-summary-line-format-alist which calls
gnus-user-date(date-header).

gnus-user-date formats the date accordingly to 
gnus-user-date-day
gnus-user-date-week
gnus-user-date-old

That means that if the message is of today you get e.g. 10:24
if not older than 7 days you Mon 12:35
and if it's older you Okt 16

gnus-user-* can hold any valid value for format-time-string.

here are the patches:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch against gnus-sum.el --]
[-- Type: text/x-patch, Size: 553 bytes --]

--- gnus-sum.el	Fri Oct  5 19:44:50 2001
+++ gnus-sum2.el	Tue Oct 16 19:23:34 2001
@@ -1055,6 +1055,7 @@
     (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
     (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
     (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
+    (?q (gnus-user-date (mail-header-date gnus-tmp-header)) ?s)
     (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
     (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
     (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Patch against gnus-util.el --]
[-- Type: text/x-patch, Size: 1985 bytes --]

--- gnus-util.el	Sun Oct  7 13:49:04 2001
+++ gnus-util2.el	Tue Oct 16 18:57:50 2001
@@ -299,6 +299,43 @@
       (yes-or-no-p prompt)
     (message "")))
 
+;; By Frank Schmitt <ich@Frank-Schmitt.net>. Allows to have age-depending
+;; date representations. (e.g. just the time when it's from today, the day 
+;; of the week if it's within the last 7 days and the full date if it's older)
+(defvar gnus-user-date-format-day "%k:%M" 
+  "Format used to display todays dates.
+See documentation of format-time-string for valid values")
+(defvar gnus-user-date-format-week "%a %k:%M"
+  "Format used to display dates not older than one week.
+See documentation of format-time-string for valid values")
+(defvar gnus-user-date-format-old "%d.%m."
+  "Format used to display dates older than one week.
+See documentation of format-time-string for valid values")
+
+(defun gnus-user-date (messy-date)
+  "Format the messy-date acording to gnus-user-date-format-*.
+Returns \"  ?  \" if there's bad input or if an other error occurs.
+Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
+  (condition-case ()
+      (progn
+	(setq messy-date (safe-date-to-time messy-date))
+	(setq now (current-time))
+	(setq my-format gnus-user-date-format-old)
+	(setq high (lsh (- (car now) (car messy-date)) 16))
+	(if (= (logand high 65535) 0)  ;;if nil then we've got an overflow
+	    (progn
+	     (setq difference (+ high (- (car (cdr now)) (car (cdr messy-date)))))
+	     (setq now (decode-time now))
+	     (if (> (- (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)) differenz) -1)
+		 ;;today
+		 (setq my-format gnus-user-date-format-day)
+	       (if (< difference 604801)
+		   ;;this week
+		   (setq my-format gnus-user-date-format-week)))))
+	  (format-time-string (eval my-format) messy-date))
+    (error "  ?   ")))
+;;end of Frank's code
+
 (defun gnus-dd-mmm (messy-date)
   "Return a string like DD-MMM from a big messy string."
   (condition-case ()


[-- Attachment #4: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-16 19:42 [patch] age depending date-format Frank Schmitt
@ 2001-10-16 20:52 ` ShengHuo ZHU
  2001-10-17  7:16   ` Frank Schmitt
                     ` (2 more replies)
  2001-10-17 10:51 ` [patch] age depending date-format Frank Schmitt
  2001-10-17 15:05 ` Yair Friedman (Jerusalem)
  2 siblings, 3 replies; 36+ messages in thread
From: ShengHuo ZHU @ 2001-10-16 20:52 UTC (permalink / raw)


Frank Schmitt <usereplyto@Frank-Schmitt.net> writes:

> Hi
> 
> I did some more testing and error handling on my code I posted in  
> <archive.pu7pc20r.fsf@hschmi22.userfqdn.rz-online.de>.
> 
> It should work without problems. What it does is the following:
> Add a new item (%q) to gnus-summary-line-format-alist which calls
> gnus-user-date(date-header).
> 
> gnus-user-date formats the date accordingly to 
> gnus-user-date-day
> gnus-user-date-week
> gnus-user-date-old
> 
> That means that if the message is of today you get e.g. 10:24
> if not older than 7 days you Mon 12:35
> and if it's older you Okt 16
> 
> gnus-user-* can hold any valid value for format-time-string.

It is cute, but we'd better let users use %uX instead of adding %q
into g-s-l-f-a.  For example, (defalias 'gnus-user-format-function-X
'gnus-user-date).

A suggestion. Is it better to use a variable like
gnus-user-data-format-alist instead of gnus-user-date-format-day and
it friends? g-u-d-f-a is a list of cons of elapsed time (or symbol)
and format.  For example,

(defvar gnus-user-data-format-alist
  '((day-in-seconds . "%k:%M")
    (604800  . "%a %k:%M")
    (t . "%d.%m))
   "Blah blah")

ShengHuo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-16 20:52 ` ShengHuo ZHU
@ 2001-10-17  7:16   ` Frank Schmitt
  2001-10-17 16:09     ` ShengHuo ZHU
  2001-10-17 11:50   ` Kai Großjohann
  2001-10-17 20:35   ` Update of gnus-user-date (was: [patch] age depending date-format) Frank Schmitt
  2 siblings, 1 reply; 36+ messages in thread
From: Frank Schmitt @ 2001-10-17  7:16 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

>It is cute, but we'd better let users use %uX instead of adding %q
>into g-s-l-f-a.  For example, (defalias 'gnus-user-format-function-X
>'gnus-user-date).

Why? Do you think too few would use it?

>A suggestion. Is it better to use a variable like
>gnus-user-data-format-alist instead of gnus-user-date-format-day and
>it friends? g-u-d-f-a is a list of cons of elapsed time (or symbol)
>and format.  For example,
>
>(defvar gnus-user-data-format-alist
>  '((day-in-seconds . "%k:%M")
>      (604800  . "%a %k:%M")
>      (t . "%d.%m))
>     "Blah blah")

This is a nice idea.

-- 
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
19. Dezember 2001



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-16 19:42 [patch] age depending date-format Frank Schmitt
  2001-10-16 20:52 ` ShengHuo ZHU
@ 2001-10-17 10:51 ` Frank Schmitt
  2001-10-17 15:05 ` Yair Friedman (Jerusalem)
  2 siblings, 0 replies; 36+ messages in thread
From: Frank Schmitt @ 2001-10-17 10:51 UTC (permalink / raw)


Frank Schmitt <usereplyto@Frank-Schmitt.net> writes:

>It should work without problems. What it does is the following:
>Add a new item (%q) to gnus-summary-line-format-alist which calls
>gnus-user-date(date-header).

Damned, a typo:

>+	     (if (> (- (+ (car now) (* (car (cdr now)) 60) (* (car(nthcdr 2 now)) 3600)) differenz) -1)
                                                                                        ^^^^^^^^^^ this should be difference     


-- 
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
19. Dezember 2001



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-16 20:52 ` ShengHuo ZHU
  2001-10-17  7:16   ` Frank Schmitt
@ 2001-10-17 11:50   ` Kai Großjohann
  2001-10-17 13:59     ` ShengHuo ZHU
  2001-10-17 20:35   ` Update of gnus-user-date (was: [patch] age depending date-format) Frank Schmitt
  2 siblings, 1 reply; 36+ messages in thread
From: Kai Großjohann @ 2001-10-17 11:50 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

> It is cute, but we'd better let users use %uX instead of adding %q
> into g-s-l-f-a.  For example, (defalias 'gnus-user-format-function-X
> 'gnus-user-date).

Isn't %uX reserved for user customizations?  Frank's proposal is to
become part of Gnus, and therefore not for user-specific stuff,
anymore.

Yes, we might run out of letters soon.  But I think it might be better
in this case to allow something like %(foo) or %{foo} or %[foo] style
longer identifiers.

Opinions?

kai
-- 
Linux provides a nice `poweroff' command, but where is `poweron'?



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 11:50   ` Kai Großjohann
@ 2001-10-17 13:59     ` ShengHuo ZHU
  2001-10-17 14:08       ` Didier Verna
                         ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: ShengHuo ZHU @ 2001-10-17 13:59 UTC (permalink / raw)


Kai.Grossjohann@cs.uni-dortmund.de (Kai Großjohann) writes:

> ShengHuo ZHU <zsh@cs.rochester.edu> writes:
> 
>> It is cute, but we'd better let users use %uX instead of adding %q
>> into g-s-l-f-a.  For example, (defalias 'gnus-user-format-function-X
>> 'gnus-user-date).
> 
> Isn't %uX reserved for user customizations?  Frank's proposal is to
> become part of Gnus, and therefore not for user-specific stuff,
> anymore.
> 
> Yes, we might run out of letters soon.  But I think it might be better
> in this case to allow something like %(foo) or %{foo} or %[foo] style
> longer identifiers.
> 
> Opinions?

Unfortunately, (), {}, <> and [] are all taken.

ShengHuo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 13:59     ` ShengHuo ZHU
@ 2001-10-17 14:08       ` Didier Verna
  2001-10-17 14:11         ` Colin Marquardt
                           ` (2 more replies)
  2001-10-17 15:09       ` Per Abrahamsen
  2001-10-17 15:15       ` Per Abrahamsen
  2 siblings, 3 replies; 36+ messages in thread
From: Didier Verna @ 2001-10-17 14:08 UTC (permalink / raw)


ShengHuo ZHU wrote:

> Unfortunately, (), {}, <> and [] are all taken.

        `' (note that I'm not much convinced myself ;-)

-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 53 14 59 22   didier@xemacs.org



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 14:08       ` Didier Verna
@ 2001-10-17 14:11         ` Colin Marquardt
  2001-10-17 14:36           ` Didier Verna
  2001-10-17 15:05         ` Kai Großjohann
  2001-10-17 15:30         ` Paul Jarc
  2 siblings, 1 reply; 36+ messages in thread
From: Colin Marquardt @ 2001-10-17 14:11 UTC (permalink / raw)


Didier Verna <didier@lrde.epita.fr> writes:

> ShengHuo ZHU wrote:
>
>> Unfortunately, (), {}, <> and [] are all taken.
>
>         `' (note that I'm not much convinced myself ;-)

Or /\?

Colin



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 14:11         ` Colin Marquardt
@ 2001-10-17 14:36           ` Didier Verna
  0 siblings, 0 replies; 36+ messages in thread
From: Didier Verna @ 2001-10-17 14:36 UTC (permalink / raw)
  Cc: ding

Colin Marquardt <c.marquardt@alcatel.de> wrote:

> Or /\?

        Yes, I thought of that too, but using backslash in strings would be
annoying.

-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 53 14 59 22   didier@xemacs.org



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 14:08       ` Didier Verna
  2001-10-17 14:11         ` Colin Marquardt
@ 2001-10-17 15:05         ` Kai Großjohann
  2001-10-17 15:33           ` Didier Verna
  2001-10-17 15:30         ` Paul Jarc
  2 siblings, 1 reply; 36+ messages in thread
From: Kai Großjohann @ 2001-10-17 15:05 UTC (permalink / raw)


Didier Verna <didier@lrde.epita.fr> writes:

> ShengHuo ZHU wrote:
> 
>> Unfortunately, (), {}, <> and [] are all taken.
> 
>         `' (note that I'm not much convinced myself ;-)

%/foo/
%:foo:
%`foo'

Yeah, all these would work, and there are certainly others.

And we could move the meaning for one of (), {}, <>, [] to some other
characters.  For example, %< could be renamed %<indent> and %> could
be renamed %<outdent> :-)

kai
-- 
Linux provides a nice `poweroff' command, but where is `poweron'?



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-16 19:42 [patch] age depending date-format Frank Schmitt
  2001-10-16 20:52 ` ShengHuo ZHU
  2001-10-17 10:51 ` [patch] age depending date-format Frank Schmitt
@ 2001-10-17 15:05 ` Yair Friedman (Jerusalem)
  2001-10-17 16:09   ` Frank Schmitt
  2 siblings, 1 reply; 36+ messages in thread
From: Yair Friedman (Jerusalem) @ 2001-10-17 15:05 UTC (permalink / raw)


Frank Schmitt <usereplyto@Frank-Schmitt.net> writes:

> Hi
>
> I did some more testing and error handling on my code I posted in  
> <archive.pu7pc20r.fsf@hschmi22.userfqdn.rz-online.de>.
>
> It should work without problems. What it does is the following:
> Add a new item (%q) to gnus-summary-line-format-alist which calls
> gnus-user-date(date-header).
>
> gnus-user-date formats the date accordingly to 
> gnus-user-date-day
> gnus-user-date-week
> gnus-user-date-old

Can we have gnus-user-date-month and gnus-user-date-year as well?




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 13:59     ` ShengHuo ZHU
  2001-10-17 14:08       ` Didier Verna
@ 2001-10-17 15:09       ` Per Abrahamsen
  2001-10-17 15:15       ` Per Abrahamsen
  2 siblings, 0 replies; 36+ messages in thread
From: Per Abrahamsen @ 2001-10-17 15:09 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

> Unfortunately, (), {}, <> and [] are all taken.

%( and %) wasn't documented in the info pages for some reason, I have
copied the explanation from the doc string, and commited that.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 13:59     ` ShengHuo ZHU
  2001-10-17 14:08       ` Didier Verna
  2001-10-17 15:09       ` Per Abrahamsen
@ 2001-10-17 15:15       ` Per Abrahamsen
  2001-10-17 15:19         ` Kai Großjohann
  2 siblings, 1 reply; 36+ messages in thread
From: Per Abrahamsen @ 2001-10-17 15:15 UTC (permalink / raw)


We could steal another rarely character, '&', and emulate SGML
entities.  Like "&date;".  "%&" (or "&amph;") would be needed to get a
literal "&" in the modeline.  I doubt it would break too many
customizations.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:15       ` Per Abrahamsen
@ 2001-10-17 15:19         ` Kai Großjohann
  2001-10-17 16:04           ` ShengHuo ZHU
  0 siblings, 1 reply; 36+ messages in thread
From: Kai Großjohann @ 2001-10-17 15:19 UTC (permalink / raw)
  Cc: ding

Per Abrahamsen <abraham@dina.kvl.dk> writes:

> We could steal another rarely character, '&', and emulate SGML
> entities.  Like "&date;".  "%&" (or "&amph;") would be needed to get a
> literal "&" in the modeline.  I doubt it would break too many
> customizations.

That's a way cool idea!

kai
-- 
GNU/Linux provides a nice `poweroff' command, but where is `poweron'?



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 14:08       ` Didier Verna
  2001-10-17 14:11         ` Colin Marquardt
  2001-10-17 15:05         ` Kai Großjohann
@ 2001-10-17 15:30         ` Paul Jarc
  2001-10-17 15:41           ` Didier Verna
                             ` (3 more replies)
  2 siblings, 4 replies; 36+ messages in thread
From: Paul Jarc @ 2001-10-17 15:30 UTC (permalink / raw)


Didier Verna <didier@lrde.epita.fr> wrote:
> ShengHuo ZHU wrote:
>> Unfortunately, (), {}, <> and [] are all taken.
>
>         `' (note that I'm not much convinced myself ;-)

` is a grave accent, not a quote.  It shouldn't be paired with '.


paul



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:05         ` Kai Großjohann
@ 2001-10-17 15:33           ` Didier Verna
  0 siblings, 0 replies; 36+ messages in thread
From: Didier Verna @ 2001-10-17 15:33 UTC (permalink / raw)
  Cc: ding

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) wrote:

> Didier Verna <didier@lrde.epita.fr> writes:
>
>> ShengHuo ZHU wrote:
>> 
>>> Unfortunately, (), {}, <> and [] are all taken.
>> 
>>         `' (note that I'm not much convinced myself ;-)
>
> %/foo/
> %:foo:
> %`foo'

        For some reason, I thought that the two characters had to be
different. If that's not the case, we have indeed several combinations left.


> Yeah, all these would work, and there are certainly others.
>
> And we could move the meaning for one of (), {}, <>, [] to some other
> characters.  For example, %< could be renamed %<indent> and %> could
> be renamed %<outdent> :-)

        :-)

-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 53 14 59 22   didier@xemacs.org



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:30         ` Paul Jarc
@ 2001-10-17 15:41           ` Didier Verna
  2001-10-17 16:14           ` Per Abrahamsen
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 36+ messages in thread
From: Didier Verna @ 2001-10-17 15:41 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) wrote:

>>         `' (note that I'm not much convinced myself ;-)
>
> ` is a grave accent, not a quote.  It shouldn't be paired with '.

        I was sure somebody would raise that :-)

-- 
Didier Verna, didier@lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 53 14 59 47
94276 Le Kremlin-Bicêtre, France   Fax.+33 (1) 53 14 59 22   didier@xemacs.org



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:19         ` Kai Großjohann
@ 2001-10-17 16:04           ` ShengHuo ZHU
  0 siblings, 0 replies; 36+ messages in thread
From: ShengHuo ZHU @ 2001-10-17 16:04 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> Per Abrahamsen <abraham@dina.kvl.dk> writes:
> 
>> We could steal another rarely character, '&', and emulate SGML
>> entities.  Like "&date;".  "%&" (or "&amph;") would be needed to get a
>> literal "&" in the modeline.  I doubt it would break too many
>> customizations.
> 
> That's a way cool idea!

%&foo; it is.

ShengHuo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17  7:16   ` Frank Schmitt
@ 2001-10-17 16:09     ` ShengHuo ZHU
  2001-10-17 16:34       ` Frank Schmitt
  0 siblings, 1 reply; 36+ messages in thread
From: ShengHuo ZHU @ 2001-10-17 16:09 UTC (permalink / raw)


Frank Schmitt <usereplyto@Frank-Schmitt.net> writes:

> ShengHuo ZHU <zsh@cs.rochester.edu> writes:
> 
>>It is cute, but we'd better let users use %uX instead of adding %q
>>into g-s-l-f-a.  For example, (defalias 'gnus-user-format-function-X
>>'gnus-user-date).
> 
> Why? Do you think too few would use it?

OK. I added the extended spec to gnus-spec.el. So we can use something
like "%&user-date;" or "%&fancy-date;" in the format.

>>A suggestion. Is it better to use a variable like
>>gnus-user-data-format-alist instead of gnus-user-date-format-day and
>>it friends? g-u-d-f-a is a list of cons of elapsed time (or symbol)
>>and format.  For example,
>>
>>(defvar gnus-user-data-format-alist
>>  '((day-in-seconds . "%k:%M")
>>      (604800  . "%a %k:%M")
>>      (t . "%d.%m))
>>     "Blah blah")
> 
> This is a nice idea.

Have you signed FSF paper? If not, I can send you the form.

ShengHuo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:05 ` Yair Friedman (Jerusalem)
@ 2001-10-17 16:09   ` Frank Schmitt
  0 siblings, 0 replies; 36+ messages in thread
From: Frank Schmitt @ 2001-10-17 16:09 UTC (permalink / raw)


"Yair Friedman (Jerusalem)" <YAIRFR@amdocs.com> writes:

>>gnus-user-date formats the date accordingly to 
>>gnus-user-date-day
>>gnus-user-date-week
>>gnus-user-date-old
>
>Can we have gnus-user-date-month and gnus-user-date-year as well?

I'm just working on it. I'll do it the Gnus way: As configurable as
possible. Therefor I'll do it like ShengHuo suggested:

gnus-user date calculates the difference between the current date and
the date it gets as argument. Then it looks in a variable
gnus-user-date-format-alist for the first element with a value bigger
than the calculated difference and format the date according to the
specified value.

gnus-user-date-format-alist will look like this:

(defvar gnus-user-data-format-alist
 '((seconds-today "%k:%M")
   (604800 "%a %k:%M")
   (seconds-this-month "%a %d")
   (seconds-this-year "%b %d")
   (t "%b %m '%y)) ;;this one is used when no other does match
  "Blah blah")

The seconds-* are (will be) functions which return the seconds since
today 00:00, since the 1st of this month 00:00, since the 1st of january
of this year 00:00.

So today the function would do the following:
gnus-user-date("Wed, 17 Oct 2001 13:34:39 +0200")=13:39
gnus-user-date("Sun, 14 Oct 2001 13:34:39 +0200")=Sun 13:39
gnus-user-date("Sun, 07 Oct 2001 13:34:39 +0200")=Sun 17
gnus-user-date("Sun, 30 Sep 2001 13:34:39 +0200")=Sep 30
gnus-user-date("Sun, 14 Oct 1999 13:34:39 +0200")=Oct 14 '99

Are this nice default values? I don't really know about the
international conventions for this.

-- 
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
19. Dezember 2001



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:30         ` Paul Jarc
  2001-10-17 15:41           ` Didier Verna
@ 2001-10-17 16:14           ` Per Abrahamsen
  2001-10-17 16:19             ` Paul Jarc
  2001-10-17 16:20           ` Amos Gouaux
  2001-10-17 16:51           ` Kai Großjohann
  3 siblings, 1 reply; 36+ messages in thread
From: Per Abrahamsen @ 2001-10-17 16:14 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

> Didier Verna <didier@lrde.epita.fr> wrote:
> > ShengHuo ZHU wrote:
>>> Unfortunately, (), {}, <> and [] are all taken.
>>
>>         `' (note that I'm not much convinced myself ;-)
>
> ` is a grave accent, not a quote.  It shouldn't be paired with '.

Emacs already treat them as matching in doc strings and regexps, so I
doubt this would be a problem.

Emacs should display "`" in doc strings as whatever the Unicode
character represent the "single quote begin" glyph when possible, but
I doubt it will be a problem that they don't match visually with
modern fonts in regexps or format strings.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:14           ` Per Abrahamsen
@ 2001-10-17 16:19             ` Paul Jarc
  2001-10-17 16:37               ` Simon Josefsson
                                 ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Paul Jarc @ 2001-10-17 16:19 UTC (permalink / raw)


Per Abrahamsen <abraham@dina.kvl.dk> wrote:
> prj@po.cwru.edu (Paul Jarc) writes:
>> ` is a grave accent, not a quote.  It shouldn't be paired with '.
>
> Emacs already treat them as matching in doc strings and regexps, so I
> doubt this would be a problem.

This use of `' wouldn't benefit from the previous mistake, so why
compound it?

> Emacs should display "`" in doc strings as whatever the Unicode
> character represent the "single quote begin" glyph when possible,

Maybe.  If so, that'll be a kluge to work around the mistake of using
` in the first place.  Ultimately, ` ought to be phased out as a quote
character.


paul



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:30         ` Paul Jarc
  2001-10-17 15:41           ` Didier Verna
  2001-10-17 16:14           ` Per Abrahamsen
@ 2001-10-17 16:20           ` Amos Gouaux
  2001-10-17 16:51           ` Kai Großjohann
  3 siblings, 0 replies; 36+ messages in thread
From: Amos Gouaux @ 2001-10-17 16:20 UTC (permalink / raw)


>>>>> On Wed, 17 Oct 2001 11:30:34 -0400,
>>>>> Paul Jarc <prj@po.cwru.edu> (pj) writes:

pj> ` is a grave accent, not a quote.  It shouldn't be paired with '.


Hey, I didn't do it, not this time!  ;-)


-- 
Amos




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:09     ` ShengHuo ZHU
@ 2001-10-17 16:34       ` Frank Schmitt
  0 siblings, 0 replies; 36+ messages in thread
From: Frank Schmitt @ 2001-10-17 16:34 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:
 
>>This is a nice idea.
>
>Have you signed FSF paper? If not, I can send you the form.

No, I haven't until now but am willing to do so.

-- 
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
19. Dezember 2001



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:19             ` Paul Jarc
@ 2001-10-17 16:37               ` Simon Josefsson
  2001-10-17 16:52               ` Kai Großjohann
  2001-10-17 18:08               ` Per Abrahamsen
  2 siblings, 0 replies; 36+ messages in thread
From: Simon Josefsson @ 2001-10-17 16:37 UTC (permalink / raw)
  Cc: ding

On Wed, 17 Oct 2001, Paul Jarc wrote:

> > Emacs should display "`" in doc strings as whatever the Unicode
> > character represent the "single quote begin" glyph when possible,
>
> Maybe.  If so, that'll be a kluge to work around the mistake of using
> ` in the first place.  Ultimately, ` ought to be phased out as a quote
> character.

Someone needs to fix the Unicode fonts before the argument of switching
has much effect on me -- for me ASCII `' looks better than Unicode `' in
Emacs, and the reverse is the only reason I've heard for switching
(that ASCII `' looks bad for some people, that is).  Emacs 21 and fonts
from RedHat 7.1.




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 15:30         ` Paul Jarc
                             ` (2 preceding siblings ...)
  2001-10-17 16:20           ` Amos Gouaux
@ 2001-10-17 16:51           ` Kai Großjohann
  2001-10-18  6:44             ` Yair Friedman (Jerusalem)
  3 siblings, 1 reply; 36+ messages in thread
From: Kai Großjohann @ 2001-10-17 16:51 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

> Didier Verna <didier@lrde.epita.fr> wrote:
>> ShengHuo ZHU wrote:
>>> Unfortunately, (), {}, <> and [] are all taken.
>>
>>         `' (note that I'm not much convinced myself ;-)
> 
> ` is a grave accent, not a quote.  It shouldn't be paired with '.

It is Emacs custom to pair these.  But we can be future-compatible by
allowing ´ in addition to ' as the counter part to `...

kai
-- 
GNU/Linux provides a nice `poweroff' command, but where is `poweron'?



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:19             ` Paul Jarc
  2001-10-17 16:37               ` Simon Josefsson
@ 2001-10-17 16:52               ` Kai Großjohann
  2001-10-17 17:03                 ` Paul Jarc
  2001-10-17 18:08               ` Per Abrahamsen
  2 siblings, 1 reply; 36+ messages in thread
From: Kai Großjohann @ 2001-10-17 16:52 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

> Maybe.  If so, that'll be a kluge to work around the mistake of using
> ` in the first place.  Ultimately, ` ought to be phased out as a quote
> character.

What should be used instead of `?  How does one get paired single
quotes?

kai
-- 
GNU/Linux provides a nice `poweroff' command, but where is `poweron'?



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:52               ` Kai Großjohann
@ 2001-10-17 17:03                 ` Paul Jarc
  2001-10-17 18:11                   ` Per Abrahamsen
  0 siblings, 1 reply; 36+ messages in thread
From: Paul Jarc @ 2001-10-17 17:03 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) wrote:
> What should be used instead of `?  How does one get paired single
> quotes?

In ASCII, 'this' is the best you can do.  ("'" is an apostrophe, not a
right quote; it ought to be vertical, though in many fonts, it isn't.)
Unicode has codes for left and right single quotes, but they're
outside the ASCII range.
<URL:http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html>


paul



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:19             ` Paul Jarc
  2001-10-17 16:37               ` Simon Josefsson
  2001-10-17 16:52               ` Kai Großjohann
@ 2001-10-17 18:08               ` Per Abrahamsen
  2 siblings, 0 replies; 36+ messages in thread
From: Per Abrahamsen @ 2001-10-17 18:08 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

> This use of `' wouldn't benefit from the previous mistake, so why
> compound it?

It wasn't a mistake in the first place, "`" was overloaded (ASCII only
has so many codepoints).

Since advanced Emacs users will have to know that "`" and "'" match,
it will continue to serve as a good mnemonic.

> Maybe.  If so, that'll be a kluge to work around the mistake of
> using ` in the first place.  Ultimately, ` ought to be phased out as
> a quote character.

In doc strings?  It should be continued to be used exclusively until
using the Unicode replacements become more practical to the
programmers.  It shouldn't matter for users what's in the source.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 17:03                 ` Paul Jarc
@ 2001-10-17 18:11                   ` Per Abrahamsen
  0 siblings, 0 replies; 36+ messages in thread
From: Per Abrahamsen @ 2001-10-17 18:11 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

> Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) wrote:
> > What should be used instead of `?  How does one get paired single
>> quotes?
>
> In ASCII, 'this' is the best you can do.

But of course don't use that where there is an establish standard
saying otherwise, like doc strings, ChangeLogs or TeX source.

I have started using it in Usenet and mail messages, though.



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Update of gnus-user-date (was: [patch] age depending date-format)
  2001-10-16 20:52 ` ShengHuo ZHU
  2001-10-17  7:16   ` Frank Schmitt
  2001-10-17 11:50   ` Kai Großjohann
@ 2001-10-17 20:35   ` Frank Schmitt
  2001-10-17 21:34     ` ShengHuo ZHU
  2001-10-19 17:11     ` Update of gnus-user-date (was: [patch] age depending date-format) Wes Hardaker
  2 siblings, 2 replies; 36+ messages in thread
From: Frank Schmitt @ 2001-10-17 20:35 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

ShengHuo ZHU <zsh@cs.rochester.edu> writes:

>A suggestion. Is it better to use a variable like
>gnus-user-data-format-alist instead of gnus-user-date-format-day and
>it friends? g-u-d-f-a is a list of cons of elapsed time (or symbol)
>and format.

Here we go. I really like it. Now I feel like a real Gnus-programmer: I
made something which is more customizable than you'll ever need and so
difficult that no one will ever understand it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch against gnus-util.el --]
[-- Type: text/x-patch, Size: 3245 bytes --]

--- gnus-util.el	Sun Oct  7 13:49:04 2001
+++ gnus-util2.el	Wed Oct 17 20:26:40 2001
@@ -299,6 +299,68 @@
       (yes-or-no-p prompt)
     (message "")))
 
+;; By Frank Schmitt <ich@Frank-Schmitt.net>. Allows to have age-depending
+;; date representations. (e.g. just the time if it's from today, the day 
+;; of the week if it's within the last 7 days and the full date if it's older)
+(defun gnus-seconds-today ()
+"Returns the number of seconds passed today"
+(setq now (decode-time (current-time)))
+(+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)))
+
+(defun gnus-seconds-month ()
+"Returns the number of seconds passed this month"
+(setq now (decode-time (current-time)))
+(+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) (* (- (car (nthcdr 3 now)) 1) 3600 24)))
+
+(defun gnus-seconds-year ()
+"Returns the number of seconds passed this year"
+(setq now (decode-time (current-time)))
+(setq days (format-time-string "%j" (current-time)))
+(+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) (* (- (string-to-number days) 1) 3600 24)))
+
+(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 %m '%y"))                      ;;this one is used when no other does match
+   "Alist of time in seconds and format specification used to display dates not older.
+The first element must be a number or a function returning a number. The second element
+is a format-specification as described in the documentation for format-time-string.
+The list must be ordered smallest number up. When there is an element, which is not a
+number, the corresponding format-specification will be used, disregarding any following
+elements.
+You can use the functions gnus-seconds-today, gnus-seconds-month, gnus-seconds-year 
+which will return the number of seconds which passed today/this month/this year.")
+
+(defun gnus-user-date (messy-date)
+  "Format the messy-date acording to gnus-user-date-format-alist.
+Returns \"  ?  \" if there's bad input or if an other error occurs.
+Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
+  (condition-case ()
+      (progn
+	(setq messy-date (safe-date-to-time messy-date))
+	(setq now (current-time))
+	(setq my-format "%b %m '%y") ;;If we don't find something suitable we'll use this one
+	(setq high (lsh (- (car now) (car messy-date)) 16))
+	(if (and (> high -1) (= (logand high 65535) 0))  ;;overflow and bad input
+	    (progn
+	     (setq difference (+ high (- (car (cdr now)) (car (cdr messy-date)))))
+	     (setq templist gnus-user-data-format-alist)
+	     (setq top (eval (caar templist)))
+	     (while (and (numberp top)  (< top difference))
+	       (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) messy-date))
+    (error "  ?   ")))
+;;end of Frank's code
+
 (defun gnus-dd-mmm (messy-date)
   "Return a string like DD-MMM from a big messy string."
   (condition-case ()


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Update of gnus-user-date (was: [patch] age depending date-format)
  2001-10-17 20:35   ` Update of gnus-user-date (was: [patch] age depending date-format) Frank Schmitt
@ 2001-10-17 21:34     ` ShengHuo ZHU
  2001-10-18  7:53       ` Update of gnus-user-date Frank Schmitt
  2001-10-19 17:11     ` Update of gnus-user-date (was: [patch] age depending date-format) Wes Hardaker
  1 sibling, 1 reply; 36+ messages in thread
From: ShengHuo ZHU @ 2001-10-17 21:34 UTC (permalink / raw)


Frank Schmitt <usereplyto@Frank-Schmitt.net> writes:

> ShengHuo ZHU <zsh@cs.rochester.edu> writes:
> 
>>A suggestion. Is it better to use a variable like
>>gnus-user-data-format-alist instead of gnus-user-date-format-day and
>>it friends? g-u-d-f-a is a list of cons of elapsed time (or symbol)
>>and format.
> 
> Here we go. I really like it. Now I feel like a real Gnus-programmer: I
> made something which is more customizable than you'll ever need and so
> difficult that no one will ever understand it.

Thanks. I've installed it with little modification. And %&user-date;
is the format spec.

ShengHuo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] age depending date-format
  2001-10-17 16:51           ` Kai Großjohann
@ 2001-10-18  6:44             ` Yair Friedman (Jerusalem)
  0 siblings, 0 replies; 36+ messages in thread
From: Yair Friedman (Jerusalem) @ 2001-10-18  6:44 UTC (permalink / raw)


Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

>
> It is Emacs custom to pair these.  But we can be future-compatible by
> allowing ´ in addition to ' as the counter part to `...

If you enter non-ASCII character you can use the «» pair instead.




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Update of gnus-user-date
  2001-10-17 21:34     ` ShengHuo ZHU
@ 2001-10-18  7:53       ` Frank Schmitt
  2001-10-18 10:08         ` Kai Großjohann
  0 siblings, 1 reply; 36+ messages in thread
From: Frank Schmitt @ 2001-10-18  7:53 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

>Thanks. I've installed it with little modification. And %&user-date;
>is the format spec.

I like your modifications. Well, one is ready, two still to go on my
"I liked it in XNews and want it in gnus to"-list.

1) Have a option to have a dummy article on top of each thread and nice
summary-highlight options for this one. (This dummy article line could
hold the number of articles in the thread, the biggest score in the
thread...)

2) Provide the possibility to have table-like summaries, therefor
provide an option to specify minimum and maximum width not only for one
element of the summary-line but for several. (so %-20,20%f&%d means that
from and date are together always 20 chars long)

-- 
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
19. Dezember 2001



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Update of gnus-user-date
  2001-10-18  7:53       ` Update of gnus-user-date Frank Schmitt
@ 2001-10-18 10:08         ` Kai Großjohann
  0 siblings, 0 replies; 36+ messages in thread
From: Kai Großjohann @ 2001-10-18 10:08 UTC (permalink / raw)
  Cc: ding

Frank Schmitt <usereplyto@Frank-Schmitt.net> writes:

> 1) Have a option to have a dummy article on top of each thread and nice
> summary-highlight options for this one. (This dummy article line could
> hold the number of articles in the thread, the biggest score in the
> thread...)

See the variable gnus-summary-make-false-root.  So you can see that
part of the functionality is already there, but it's not done for all
threads, yet.

(To see the effect, send yourself two messages with the same subject.)

kai
-- 
GNU/Linux provides a nice `poweroff' command, but where is `poweron'?



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Update of gnus-user-date (was: [patch] age depending date-format)
  2001-10-17 20:35   ` Update of gnus-user-date (was: [patch] age depending date-format) Frank Schmitt
  2001-10-17 21:34     ` ShengHuo ZHU
@ 2001-10-19 17:11     ` Wes Hardaker
  1 sibling, 0 replies; 36+ messages in thread
From: Wes Hardaker @ 2001-10-19 17:11 UTC (permalink / raw)
  Cc: ding

>>>>> On Wed, 17 Oct 2001 22:35:29 +0200, Frank Schmitt <usereplyto@Frank-Schmitt.net> said:

Frank> Here we go. I really like it. Now I feel like a real
Frank> Gnus-programmer: I made something which is more customizable
Frank> than you'll ever need and so difficult that no one will ever
Frank> understand it.

You've made laugh at this for a good 5 minutes (and I immediately
passed on the quote to some friends who greatly appreciated it).



-- 
"Ninjas aren't dangerous.  They're more afraid of you than you are of them."



^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2001-10-19 17:11 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-16 19:42 [patch] age depending date-format Frank Schmitt
2001-10-16 20:52 ` ShengHuo ZHU
2001-10-17  7:16   ` Frank Schmitt
2001-10-17 16:09     ` ShengHuo ZHU
2001-10-17 16:34       ` Frank Schmitt
2001-10-17 11:50   ` Kai Großjohann
2001-10-17 13:59     ` ShengHuo ZHU
2001-10-17 14:08       ` Didier Verna
2001-10-17 14:11         ` Colin Marquardt
2001-10-17 14:36           ` Didier Verna
2001-10-17 15:05         ` Kai Großjohann
2001-10-17 15:33           ` Didier Verna
2001-10-17 15:30         ` Paul Jarc
2001-10-17 15:41           ` Didier Verna
2001-10-17 16:14           ` Per Abrahamsen
2001-10-17 16:19             ` Paul Jarc
2001-10-17 16:37               ` Simon Josefsson
2001-10-17 16:52               ` Kai Großjohann
2001-10-17 17:03                 ` Paul Jarc
2001-10-17 18:11                   ` Per Abrahamsen
2001-10-17 18:08               ` Per Abrahamsen
2001-10-17 16:20           ` Amos Gouaux
2001-10-17 16:51           ` Kai Großjohann
2001-10-18  6:44             ` Yair Friedman (Jerusalem)
2001-10-17 15:09       ` Per Abrahamsen
2001-10-17 15:15       ` Per Abrahamsen
2001-10-17 15:19         ` Kai Großjohann
2001-10-17 16:04           ` ShengHuo ZHU
2001-10-17 20:35   ` Update of gnus-user-date (was: [patch] age depending date-format) Frank Schmitt
2001-10-17 21:34     ` ShengHuo ZHU
2001-10-18  7:53       ` Update of gnus-user-date Frank Schmitt
2001-10-18 10:08         ` Kai Großjohann
2001-10-19 17:11     ` Update of gnus-user-date (was: [patch] age depending date-format) Wes Hardaker
2001-10-17 10:51 ` [patch] age depending date-format Frank Schmitt
2001-10-17 15:05 ` Yair Friedman (Jerusalem)
2001-10-17 16:09   ` Frank Schmitt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).