Gnus development mailing list
 help / color / mirror / Atom feed
From: "Adam Sjøgren" <asjo@koldfront.dk>
To: ding@gnus.org
Subject: [PATCH] Add new gnus-article-date-headers option combined-local-lapsed
Date: Sat, 20 Jul 2019 11:50:56 +0200	[thread overview]
Message-ID: <87imrxdofz.fsf_-_@tullinup.koldfront.dk> (raw)
In-Reply-To: <m34l4hj3j0.fsf@gnus.org>

* 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




  reply	other threads:[~2019-07-20  9:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Adam Sjøgren [this message]
2019-07-20 13:02     ` [PATCH] Add new gnus-article-date-headers option combined-local-lapsed Lars Ingebrigtsen
2019-07-20 13:16       ` Adam Sjøgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87imrxdofz.fsf_-_@tullinup.koldfront.dk \
    --to=asjo@koldfront.dk \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).