From: Adam Sjøgren Date: Sat, 20 Jul 2019 13:02:22 +0000 (+0200) Subject: Enable showing local time and lapsed time in Gnus X-Git-Tag: emacs-27.0.90~1848 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2019a6d8a8aa354eaf1197a663f3c41f60325ad8;p=emacs.git Enable showing local time and lapsed time in Gnus * 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. --- diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 7c5bc3eee85..f688e84e7e8 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -12040,6 +12040,10 @@ The time elapsed since the message was posted. @item combined-lapsed Both the original date header and a (shortened) elapsed time. +@item combined-local-lapsed +Both the time in the user's local time zone a (shortened) elapsed +time. + @item original The original date header. diff --git a/etc/NEWS b/etc/NEWS index 9b7cfd7bb7e..d0a9c031e94 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -923,6 +923,10 @@ Of course it will still find it if you have it in '~/.ecompleterc'. ** Gnus +*** There's a new value for `gnus-article-date-headers', +`combined-local-lapsed', which will show both the time (in the local +timezone) and the lapsed time. + --- *** Gnus now maps imaps to 993 only on old MS-Windows versions. The nnimap backend used to do this unconditionally to work around diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 42e1a821b90..65e1c8106d5 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -999,6 +999,7 @@ on parts -- for instance, adding Vcard info to a database." 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 @@ Some of these headers are updated automatically. See (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 @@ possible values." (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 @@ possible values." (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)))