From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/88680 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Adam_Sj=C3=B8gren?= Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Add new gnus-article-date-headers option combined-local-lapsed Date: Sat, 20 Jul 2019 11:50:56 +0200 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <87imrxdofz.fsf_-_@tullinup.koldfront.dk> References: <87imvlhtcz.fsf@tullinup.koldfront.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="176388"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: ding@gnus.org Original-X-From: ding-owner+M36884@lists.math.uh.edu Sat Jul 20 11:51:25 2019 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from lists1.math.uh.edu ([129.7.128.208]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hom1V-000jnW-4i for ding-account@gmane.org; Sat, 20 Jul 2019 11:51:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.92) (envelope-from ) id 1hom1H-0007KR-QN; Sat, 20 Jul 2019 04:51:11 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hom1C-0007HK-8f for ding@lists.math.uh.edu; Sat, 20 Jul 2019 04:51:06 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hom1A-0000RN-RL for ding@lists.math.uh.edu; Sat, 20 Jul 2019 04:51:06 -0500 Original-Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226] helo=blaine.gmane.org) by quimby.gnus.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hom17-0000xy-GT for ding@gnus.org; Sat, 20 Jul 2019 11:51:03 +0200 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hom16-000jP2-UA for ding@gnus.org; Sat, 20 Jul 2019 11:51:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc Mail-Follow-Up-To: never X-Now-Playing: Space Song, Depression Cherry (Beach House) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97,Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:88680 Archived-At: * 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 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