Gnus development mailing list
 help / color / mirror / Atom feed
* gnus-article-date-headers, new type "combined-local"?
@ 2019-04-11  7:51 Adam Sjøgren
  2019-04-11 17:38 ` Andreas Schwab
  2019-06-22 10:52 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 10+ messages in thread
From: Adam Sjøgren @ 2019-04-11  7:51 UTC (permalink / raw)
  To: ding

Currently I have gnus-article-date-headers set to the default,
'(combined-lapsed)).

But what I really would like is the local time + lapsed, i.e. instead
of:

  Thu, 11 Apr 2019 07:02:50 +0000 (47 minutes, 59 seconds ago)

I would like to see:

  Thu, 11 Apr 2019 09:02:50 +0200 (47 minutes, 59 seconds ago)

(my timezone currently is +0200.)

It looks like adding that would be another type in
article-make-date-line, say combined-local.

What do you think, would it make sense to add that, or is there an
"easier" way?


  Best regards,

    Adam

-- 
 "Everything needs to change.                                 Adam Sjøgren
  And it has to start today."                            asjo@koldfront.dk




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

* Re: gnus-article-date-headers, new type "combined-local"?
  2019-04-11  7:51 gnus-article-date-headers, new type "combined-local"? Adam Sjøgren
@ 2019-04-11 17:38 ` Andreas Schwab
  2019-04-11 17:55   ` Adam Sjøgren
  2019-06-22 10:52 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2019-04-11 17:38 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding

On Apr 11 2019, Adam Sjøgren <asjo@koldfront.dk> wrote:

> Currently I have gnus-article-date-headers set to the default,
> '(combined-lapsed)).
>
> But what I really would like is the local time + lapsed, i.e. instead
> of:
>
>   Thu, 11 Apr 2019 07:02:50 +0000 (47 minutes, 59 seconds ago)
>
> I would like to see:
>
>   Thu, 11 Apr 2019 09:02:50 +0200 (47 minutes, 59 seconds ago)
>
> (my timezone currently is +0200.)
>
> It looks like adding that would be another type in
> article-make-date-line, say combined-local.
>
> What do you think, would it make sense to add that, or is there an
> "easier" way?

Try 'user-defined.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



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

* Re: gnus-article-date-headers, new type "combined-local"?
  2019-04-11 17:38 ` Andreas Schwab
@ 2019-04-11 17:55   ` Adam Sjøgren
  2019-04-11 19:31     ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Sjøgren @ 2019-04-11 17:55 UTC (permalink / raw)
  To: ding

Andreas writes:

> On Apr 11 2019, Adam Sjøgren <asjo@koldfront.dk> wrote:
>
>> It looks like adding that would be another type in
>> article-make-date-line, say combined-local.
>>
>> What do you think, would it make sense to add that, or is there an
>> "easier" way?
>
> Try 'user-defined.

The documentation of gnus-article-date-headers says:

  ‘user-defined’ (a user-defined format defined by the
  ‘gnus-article-time-format’ variable).

which is almost as information-free as your answer.

The default value of gnus-article-time-format is "%a, %d %b %Y %T %Z".

To implement combined-lapsed, I find this piece of code:

	 ((eq type 'combined-lapsed)
	  (let ((date-string (article-make-date-line date 'original))
		(segments 3)
		lapsed-string)
	    (while (and
                    time
		    (setq lapsed-string
			  (concat " (" (article-lapsed-string time segments) ")"))
		    (> (+ (length date-string)
			  (length lapsed-string))
		       (+ fill-column 6))
		    (> segments 0))
	      (setq segments (1- segments)))
	    (if (> segments 0)
		(concat date-string lapsed-string)
	      date-string)))

Which kind of makes me think that it probably can't be done with a
user-defined string.

Maybe it really is trivial using 'user-defined, it's hard to tell from
your reply.


  Best regards,

    Adam

-- 
 "Everything needs to change.                                 Adam Sjøgren
  And it has to start today."                            asjo@koldfront.dk




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

* Re: gnus-article-date-headers, new type "combined-local"?
  2019-04-11 17:55   ` Adam Sjøgren
@ 2019-04-11 19:31     ` Andreas Schwab
  2019-04-11 19:33       ` Adam Sjøgren
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2019-04-11 19:31 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding

On Apr 11 2019, Adam Sjøgren <asjo@koldfront.dk> wrote:

> Andreas writes:
>
>> On Apr 11 2019, Adam Sjøgren <asjo@koldfront.dk> wrote:
>>
>>> It looks like adding that would be another type in
>>> article-make-date-line, say combined-local.
>>>
>>> What do you think, would it make sense to add that, or is there an
>>> "easier" way?
>>
>> Try 'user-defined.
>
> The documentation of gnus-article-date-headers says:
>
>   ‘user-defined’ (a user-defined format defined by the
>   ‘gnus-article-time-format’ variable).
>
> which is almost as information-free as your answer.

RTFM.

gnus-article-time-format is a variable defined in ‘gnus-art.el’.
Its value is "%a, %d %b %Y %T %Z"

Documentation:
Format for display of Date headers in article bodies.
See ‘format-time-string’ for the possible values.

The variable can also be function, which should return a complete Date
header.  The function is called with one argument, the time, which can
be fed to ‘format-time-string’.

You can customize this variable.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



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

* Re: gnus-article-date-headers, new type "combined-local"?
  2019-04-11 19:31     ` Andreas Schwab
@ 2019-04-11 19:33       ` Adam Sjøgren
  2019-04-11 20:02         ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Sjøgren @ 2019-04-11 19:33 UTC (permalink / raw)
  To: ding

Andreas writes:

> RTFM.

Now you're just being stupid.


  Best regards,

    Adam

-- 
 "Everything needs to change.                                 Adam Sjøgren
  And it has to start today."                            asjo@koldfront.dk




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

* Re: gnus-article-date-headers, new type "combined-local"?
  2019-04-11 19:33       ` Adam Sjøgren
@ 2019-04-11 20:02         ` Andreas Schwab
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2019-04-11 20:02 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding

Sorry, I cannot help if you are unable to read.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



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

* Re: gnus-article-date-headers, new type "combined-local"?
  2019-04-11  7:51 gnus-article-date-headers, new type "combined-local"? Adam Sjøgren
  2019-04-11 17:38 ` Andreas Schwab
@ 2019-06-22 10:52 ` Lars Ingebrigtsen
  2019-07-20  9:50   ` [PATCH] Add new gnus-article-date-headers option combined-local-lapsed Adam Sjøgren
  1 sibling, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-22 10:52 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding

Adam Sjøgren <asjo@koldfront.dk> writes:

> Currently I have gnus-article-date-headers set to the default,
> '(combined-lapsed)).
>
> But what I really would like is the local time + lapsed, i.e. instead
> of:
>
>   Thu, 11 Apr 2019 07:02:50 +0000 (47 minutes, 59 seconds ago)
>
> I would like to see:
>
>   Thu, 11 Apr 2019 09:02:50 +0200 (47 minutes, 59 seconds ago)
>
> (my timezone currently is +0200.)
>
> It looks like adding that would be another type in
> article-make-date-line, say combined-local.

Yeah, that sounds like something I could see people wanting...  But
perhaps the name should be `combined-local-lapsed' or something.

Patches welcome.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* [PATCH] Add new gnus-article-date-headers option combined-local-lapsed
  2019-06-22 10:52 ` Lars Ingebrigtsen
@ 2019-07-20  9:50   ` Adam Sjøgren
  2019-07-20 13:02     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Sjøgren @ 2019-07-20  9:50 UTC (permalink / raw)
  To: ding

* lisp/gnus/gnus-art.el (article-make-date-combine-with-lapsed) factor
code out into new function, used for providing both combined-lapsed
and combined-local-lapsed.
---
Lars writes:

> Adam Sjøgren <asjo@koldfront.dk> writes:
>
>> Currently I have gnus-article-date-headers set to the default,
>> '(combined-lapsed)).
>>
>> But what I really would like is the local time + lapsed
>
> Yeah, that sounds like something I could see people wanting...  But
> perhaps the name should be `combined-local-lapsed' or something.
>
> Patches welcome.  :-)

Here's one.

 lisp/gnus/gnus-art.el | 41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 42e1a821b9..65e1c8106d 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -999,6 +999,7 @@ gnus-article-date-headers
 Valid formats are `ut' (Universal Time), `local' (local time
 zone), `english' (readable English), `lapsed' (elapsed time),
 `combined-lapsed' (both the original date and the elapsed time),
+`combined-local-lapsed' (both the local time and the elapsed time),
 `original' (the original date header), `iso8601' (ISO8601
 format), and `user-defined' (a user-defined format defined by the
 `gnus-article-time-format' variable).
@@ -1014,6 +1015,7 @@ gnus-article-date-headers
 	  (const :tag "Readable English" english)
 	  (const :tag "Elapsed time" lapsed)
 	  (const :tag "Original and elapsed time" combined-lapsed)
+	  (const :tag "Local and elapsed time" combined-local-lapsed)
 	  (const :tag "Original date header" original)
 	  (const :tag "ISO8601 format" iso8601)
 	  (const :tag "User-defined" user-defined)))
@@ -3528,10 +3530,28 @@ article-transform-date
 	    (put-text-property (match-beginning 1) (match-end 1)
 			       'face eface)))))))
 
+(defun article-make-date-combine-with-lapsed (date time type)
+  "Return type of date with lapsed time added."
+  (let ((date-string (article-make-date-line date type))
+	(segments 3)
+	lapsed-string)
+    (while (and
+            time
+	    (setq lapsed-string
+		  (concat " (" (article-lapsed-string time segments) ")"))
+	    (> (+ (length date-string)
+		  (length lapsed-string))
+	       (+ fill-column 6))
+	    (> segments 0))
+      (setq segments (1- segments)))
+    (if (> segments 0)
+	(concat date-string lapsed-string)
+      date-string)))
+
 (defun article-make-date-line (date type)
   "Return a DATE line of TYPE."
   (unless (memq type '(local ut original user-defined iso8601 lapsed english
-			     combined-lapsed))
+			     combined-lapsed combined-local-lapsed))
     (error "Unknown conversion type: %s" type))
   (condition-case ()
       (let ((time (ignore-errors (date-to-time date))))
@@ -3569,21 +3589,10 @@ article-make-date-line
 	  (concat "Date: " (article-lapsed-string time)))
 	 ;; A combined date/lapsed format.
 	 ((eq type 'combined-lapsed)
-	  (let ((date-string (article-make-date-line date 'original))
-		(segments 3)
-		lapsed-string)
-	    (while (and
-                    time
-		    (setq lapsed-string
-			  (concat " (" (article-lapsed-string time segments) ")"))
-		    (> (+ (length date-string)
-			  (length lapsed-string))
-		       (+ fill-column 6))
-		    (> segments 0))
-	      (setq segments (1- segments)))
-	    (if (> segments 0)
-		(concat date-string lapsed-string)
-	      date-string)))
+          (article-make-date-combine-with-lapsed date time 'original))
+         ;; A combined local/lapsed format.
+         ((eq type 'combined-local-lapsed)
+          (article-make-date-combine-with-lapsed date time 'local))
 	 ;; Display the date in proper English
 	 ((eq type 'english)
 	  (let ((dtime (decode-time time)))
-- 
2.22.0

-- 
 "Frankly, I'd like to have the issue resolved before         Adam Sjøgren
  I expend any more energy on this."                     asjo@koldfront.dk




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

* Re: [PATCH] Add new gnus-article-date-headers option combined-local-lapsed
  2019-07-20  9:50   ` [PATCH] Add new gnus-article-date-headers option combined-local-lapsed Adam Sjøgren
@ 2019-07-20 13:02     ` Lars Ingebrigtsen
  2019-07-20 13:16       ` Adam Sjøgren
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-20 13:02 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding

Adam Sjøgren <asjo@koldfront.dk> writes:

> * lisp/gnus/gnus-art.el (article-make-date-combine-with-lapsed) factor
> code out into new function, used for providing both combined-lapsed
> and combined-local-lapsed.

Looks good; I've pushed it to the trunk (along with a NEWS item and
manual entry).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: [PATCH] Add new gnus-article-date-headers option combined-local-lapsed
  2019-07-20 13:02     ` Lars Ingebrigtsen
@ 2019-07-20 13:16       ` Adam Sjøgren
  0 siblings, 0 replies; 10+ messages in thread
From: Adam Sjøgren @ 2019-07-20 13:16 UTC (permalink / raw)
  To: ding

Lars writes:

> Adam Sjøgren <asjo@koldfront.dk> writes:
>
>> * lisp/gnus/gnus-art.el (article-make-date-combine-with-lapsed) factor
>> code out into new function, used for providing both combined-lapsed
>> and combined-local-lapsed.
>
> Looks good; I've pushed it to the trunk (along with a NEWS item and
> manual entry).

Thanks!

I looked for "combined-lapsed" in the manual, but missed it.

Hmm. Probably mistyped and searched for "combined-local". D'oh.


  Best regards,

    Adam

-- 
 "Mere snak, mindre musik                                     Adam Sjøgren
  Det her går den gale vej"                              asjo@koldfront.dk




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

end of thread, other threads:[~2019-07-20 13:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  7:51 gnus-article-date-headers, new type "combined-local"? Adam Sjøgren
2019-04-11 17:38 ` Andreas Schwab
2019-04-11 17:55   ` Adam Sjøgren
2019-04-11 19:31     ` Andreas Schwab
2019-04-11 19:33       ` Adam Sjøgren
2019-04-11 20:02         ` Andreas Schwab
2019-06-22 10:52 ` Lars Ingebrigtsen
2019-07-20  9:50   ` [PATCH] Add new gnus-article-date-headers option combined-local-lapsed Adam Sjøgren
2019-07-20 13:02     ` Lars Ingebrigtsen
2019-07-20 13:16       ` Adam Sjøgren

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).