unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Add notmuch-show-local-dates option
@ 2020-06-25 13:30 Kevin J. Foley
  2020-07-02 19:38 ` Daniel Kahn Gillmor
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin J. Foley @ 2020-06-25 13:30 UTC (permalink / raw)
  To: notmuch

Allows users to specify they'd like dates to be displayed in local time
---
 emacs/notmuch-show.el                         | 12 +++++++++
 test/T310-emacs.sh                            |  9 +++++++
 .../notmuch-show-message-with-local-dates     | 25 +++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 test/emacs.expected-output/notmuch-show-message-with-local-dates

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c9170466..cc87735d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -84,6 +84,11 @@ (defcustom notmuch-show-relative-dates t
   :type 'boolean
   :group 'notmuch-show)

+(defcustom notmuch-show-local-dates nil
+  "Display local dates in the message header."
+  :type 'boolean
+  :group 'notmuch-show)
+
 (defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers)
   "A list of functions called to decorate the headers listed in
 `notmuch-message-headers'.")
@@ -1067,6 +1072,13 @@ (defun notmuch-show-insert-msg (msg depth)

     (setq message-start (point-marker))

+    (when notmuch-show-local-dates
+      (plist-put headers :Date
+		 (format-time-string
+		  "%a, %d %b %Y %H:%M:%S %z"
+		  (apply #'encode-time
+			 (parse-time-string (plist-get headers :Date))))))
+
     (notmuch-show-insert-headerline headers
 				    (or (if notmuch-show-relative-dates
 					    (plist-get msg :date_relative)
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 5f74305d..5b1b4972 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -824,6 +824,15 @@ test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.g
 	(test-visible-output)'
 test_expect_equal_file $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed OUTPUT

+test_begin_subtest "notmuch-show: show local dates"
+test_emacs \
+	'(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
+	       (notmuch-message-headers-visible t)
+               (notmuch-show-local-dates t))
+	   (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
+	   (test-visible-output))'
+test_expect_equal_file $EXPECTED/notmuch-show-message-with-local-dates OUTPUT
+
 test_begin_subtest "Stashing in notmuch-show"
 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
     '[from]="Some One <someone@somewhere.org>"' \
diff --git a/test/emacs.expected-output/notmuch-show-message-with-local-dates b/test/emacs.expected-output/notmuch-show-message-with-local-dates
new file mode 100644
index 00000000..4669e823
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-show-message-with-local-dates
@@ -0,0 +1,25 @@
+Jan Janak <jan@ryngle.com> (2009-11-17) (inbox)
+Subject: [notmuch] What a great idea!
+ Jan Janak <jan@ryngle.com> (2009-11-17) (inbox)
+ Subject: [notmuch] What a great idea!
+ To: notmuch@notmuchmail.org
+ Date: Tue, 17 Nov 2009 22:38:47 +0000
+
+ On Tue, Nov 17, 2009 at 11:35 PM, Jan Janak <jan at ryngle.com> wrote:
+ > Hello,
+ >
+ > First of all, notmuch is a wonderful idea, both the cmdline tool and
+ [ 2 more citation lines. Click/Enter to show. ]
+ >
+ > Have you considered sending an announcement to the org-mode mailing list?
+ > http://org-mode.org
+
+ Sorry, wrong URL, the correct one is: http://orgmode.org
+
+ > Various ways of searching/referencing emails from emacs were discussed
+ > there several times and none of them were as elegant as notmuch (not
+ > even close). Maybe notmuch would attract some of the developers
+ > there..
+
+   -- Jan
+ Carl Worth <cworth@cworth.org> (2009-11-18) (inbox unread)
--
2.19.0

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

* Re: [PATCH] emacs: Add notmuch-show-local-dates option
  2020-06-25 13:30 [PATCH] emacs: Add notmuch-show-local-dates option Kevin J. Foley
@ 2020-07-02 19:38 ` Daniel Kahn Gillmor
  2020-07-02 22:02   ` Kevin Foley
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Kahn Gillmor @ 2020-07-02 19:38 UTC (permalink / raw)
  To: Kevin J. Foley, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1557 bytes --]

This proposed notmuch-show-local-dates feature is a nice one.  It
renders the Date header in a format that is likely to be more useful to
the viewer.  I certainly find this more useful than having to do the
TZ conversions in my head.

But, setting this to t hides the sender's TZ from the viewer -- and i
often find it useful to learn the sender's TZ from the Date: header.

What would be really useful for me is to see the Date header represented
both ways: in my local time *and* the Date header that the sender sent.
But a boolean setting doesn't give me much room to express that
preference.

On Thu 2020-06-25 09:30:16 -0400, Kevin J. Foley wrote:
> Allows users to specify they'd like dates to be displayed in local time

This comment says "time", but the emacs config variable name says
"dates".  This confusion is worse because the Date: header actually
contains a timestamp, not a date ☹

Perhaps we should rename the variable notmuch-show-date-header-localtime,
and it could take three values:

 - nil (default), shows the Date: header as received
 - t, shows the timestamp from the Date: header in local time, 
   with the as-received header in parens afterward (see below)
 - "only", shows only the timestamp in localtime

so if your system is TZ=UTC, and notmuch-show-date-header-localtime is
set to t, and you're looking at a message sent from TZ=America/New_York,
you might see:

Date: Thu, 02 Jul 2020 19:34:53 +0000 (Thu, 02 Jul 2020 15:34:53 -0400)

Would that be too much configurability?

   --dkg

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

[-- Attachment #2: Type: text/plain, Size: 158 bytes --]

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

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

* Re: [PATCH] emacs: Add notmuch-show-local-dates option
  2020-07-02 19:38 ` Daniel Kahn Gillmor
@ 2020-07-02 22:02   ` Kevin Foley
  2020-07-03 21:37     ` Daniel Kahn Gillmor
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Foley @ 2020-07-02 22:02 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, notmuch

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> But, setting this to t hides the sender's TZ from the viewer -- and i
> often find it useful to learn the sender's TZ from the Date: header.
>
> What would be really useful for me is to see the Date header represented
> both ways: in my local time *and* the Date header that the sender sent.
> But a boolean setting doesn't give me much room to express that
> preference.

Good point, this is something I hadn't considered but I agree would be
useful to allow.

> This comment says "time", but the emacs config variable name says
> "dates".  This confusion is worse because the Date: header actually
> contains a timestamp, not a date ☹
>
> Perhaps we should rename the variable notmuch-show-date-header-localtime,

I struggled with a name for the reasons you listed =), I think your
proposed name is much clearer and will use that. 

> and it could take three values:
>
>  - nil (default), shows the Date: header as received
>  - t, shows the timestamp from the Date: header in local time, 
>    with the as-received header in parens afterward (see below)
>  - "only", shows only the timestamp in localtime
>

I feel like "only" makes more sense as the option to be used for t, and
having "both" as another option.

> so if your system is TZ=UTC, and notmuch-show-date-header-localtime is
> set to t, and you're looking at a message sent from TZ=America/New_York,
> you might see:
>
> Date: Thu, 02 Jul 2020 19:34:53 +0000 (Thu, 02 Jul 2020 15:34:53 -0400)

Actually, seeing it written out here makes me realize some people could
potentially prefer:

Date: {sent-tz-datetime} ({system-tz-datetime})

or some other kind of formatting.

Would it make sense to allow a function instead of "both", which would
be passed the time and let the user return it formatted how they would
like?  Or is that over-complicating things?

Kevin


_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

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

* Re: [PATCH] emacs: Add notmuch-show-local-dates option
  2020-07-02 22:02   ` Kevin Foley
@ 2020-07-03 21:37     ` Daniel Kahn Gillmor
  2020-07-03 22:58       ` David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Kahn Gillmor @ 2020-07-03 21:37 UTC (permalink / raw)
  To: Kevin Foley, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 2373 bytes --]

On Thu 2020-07-02 18:02:34 -0400, Kevin Foley wrote:
> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>> and it could take three values:
>>
>>  - nil (default), shows the Date: header as received
>>  - t, shows the timestamp from the Date: header in local time, 
>>    with the as-received header in parens afterward (see below)
>>  - "only", shows only the timestamp in localtime
>>
>
> I feel like "only" makes more sense as the option to be used for t, and
> having "both" as another option.

I'm fine either way.

>> so if your system is TZ=UTC, and notmuch-show-date-header-localtime is
>> set to t, and you're looking at a message sent from TZ=America/New_York,
>> you might see:
>>
>> Date: Thu, 02 Jul 2020 19:34:53 +0000 (Thu, 02 Jul 2020 15:34:53 -0400)
>
> Actually, seeing it written out here makes me realize some people could
> potentially prefer:
>
> Date: {sent-tz-datetime} ({system-tz-datetime})
>
> or some other kind of formatting.
>
> Would it make sense to allow a function instead of "both", which would
> be passed the time and let the user return it formatted how they would
> like?  Or is that over-complicating things?

For a toolkit, i like the idea of a function.  For an end-user-facing
MUA, i like opinionated decisions that do obviously the right thing,
without requiring the user to fiddle with anything.

We're struggling a bit here because notmuch-emacs is sort of in the
middle of these two things -- sometimes the one, other times the other.

Pushing on the "just do the right thing" front:

What if there were no configuration variable at all, and it just always
shows "both" ?  Or, even cleverer, what if it only shows both if the
current TZ differs from the sender's TZ?

So if i'm in TZ=America/New_York, and the sender is in
TZ=America/New_York, i would just see the normal header:

    Date: Fri, 03 Jul 2020 13:22:36 -0400

But if the sender is in TZ=Europe/Berlin, i would see:

    Date: Fri, 03 Jul 2020 13:22:36 -0400 [Fri, 03 Jul 2020 19:22:36 +0200]

(Note that RFC 5322 Date format shows the hour offset, but not the
actual TZ -- i can't tell from -0400 whether someone is in
TZ=America/New_York or TZ=America/Manaus)

Is there anyone who would complain about this just being the default
behavior -- with no additional settings to change?

         --dkg

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

[-- Attachment #2: Type: text/plain, Size: 158 bytes --]

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

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

* Re: [PATCH] emacs: Add notmuch-show-local-dates option
  2020-07-03 21:37     ` Daniel Kahn Gillmor
@ 2020-07-03 22:58       ` David Bremner
  2020-07-04 13:26         ` Daniel Kahn Gillmor
  2020-07-04 13:32         ` Tomi Ollila
  0 siblings, 2 replies; 7+ messages in thread
From: David Bremner @ 2020-07-03 22:58 UTC (permalink / raw)
  To: Daniel Kahn Gillmor, Kevin Foley, notmuch

Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:

> But if the sender is in TZ=Europe/Berlin, i would see:
>
>     Date: Fri, 03 Jul 2020 13:22:36 -0400 [Fri, 03 Jul 2020 19:22:36 +0200]
>
> (Note that RFC 5322 Date format shows the hour offset, but not the
> actual TZ -- i can't tell from -0400 whether someone is in
> TZ=America/New_York or TZ=America/Manaus)
>
> Is there anyone who would complain about this just being the default
> behavior -- with no additional settings to change?

The bikeshed must be blue! Uh, I mean what about narrowish screens (80
columns or so) and or deeply indented threads?

d
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

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

* Re: [PATCH] emacs: Add notmuch-show-local-dates option
  2020-07-03 22:58       ` David Bremner
@ 2020-07-04 13:26         ` Daniel Kahn Gillmor
  2020-07-04 13:32         ` Tomi Ollila
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Kahn Gillmor @ 2020-07-04 13:26 UTC (permalink / raw)
  To: David Bremner, Kevin Foley, notmuch


[-- Attachment #1.1: Type: text/plain, Size: 1002 bytes --]

On Fri 2020-07-03 19:58:23 -0300, David Bremner wrote:
> The bikeshed must be blue! Uh, I mean what about narrowish screens (80
> columns or so) and or deeply indented threads?

You mean what should happen to messages with headers that are much
longer, like:

To: David Bremner <david@tethera.net>, Kevin Foley <kevin@kevinjfoley.me>, notmuch@notmuchmail.org

?  😛

If someone wants to propose an alternate compact representation that
includes both the local time and the sender's TZ offset from where the
reader is, but is shorter than what i'd proposed, i'm all ears…

I originally tried the more compact:

Date: Sat, 04 Jul 2020 09:25:26 -0400 (Sender's TZ +0200)

But that isn't quite as useful as knowing what time the sender thought
it was when they hit "send" (i don't want to have to do the math in my
head).  I also tried just showing the time (not the date) but then that
gets confusing around the international date line.

Time is hard, who knew‽

   --dkg

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

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



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

* Re: [PATCH] emacs: Add notmuch-show-local-dates option
  2020-07-03 22:58       ` David Bremner
  2020-07-04 13:26         ` Daniel Kahn Gillmor
@ 2020-07-04 13:32         ` Tomi Ollila
  1 sibling, 0 replies; 7+ messages in thread
From: Tomi Ollila @ 2020-07-04 13:32 UTC (permalink / raw)
  To: David Bremner, Daniel Kahn Gillmor, Kevin Foley, notmuch

On Fri, Jul 03 2020, David Bremner wrote:

> Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
>
>> But if the sender is in TZ=Europe/Berlin, i would see:
>>
>>     Date: Fri, 03 Jul 2020 13:22:36 -0400 [Fri, 03 Jul 2020 19:22:36 +0200]
>>
>> (Note that RFC 5322 Date format shows the hour offset, but not the
>> actual TZ -- i can't tell from -0400 whether someone is in
>> TZ=America/New_York or TZ=America/Manaus)
>>
>> Is there anyone who would complain about this just being the default
>> behavior -- with no additional settings to change?
>
> The bikeshed must be blue! Uh, I mean what about narrowish screens (80
> columns or so) and or deeply indented threads?

After very casual read-thru we have had similar discussion in thread starting

id:1427132722-20346-1-git-send-email-tomi.ollila@iki.fi

https://nmbug.notmuchmail.org/nmweb/search/id%3A1427132722-20346-1-git-send-email-tomi.ollila%40iki.fi

I've been patching my notmuch-emacs interface with that ever since, using 

https://github.com/domo141/nottoomuch/blob/master/build/01-date-local.patch

The Date header from David's email looked to me as

Date: Fri, 03 Jul 2020 19:58:23 -0300  (Sat, 04 Jul 2020 01:58:23 +0300)

(and fits fine in 80-column terminal window ;D -- 72 chars used -- when
 indent or replies with > goes too deep, everything wraps (or gets cut)...) 

Anyway, there are good comments in that thread -- and every now and then
I've tried to figure out a bit different way to "solve" this -- but as
my workaround work I've usually stopped short on that.

For me the interests are to know what time the user sent the email (their
timezone) and how that relates the time the other emails I've received
(my timezone) -- not too much the (exact) location sender is...

>
> d

Tomi

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

end of thread, other threads:[~2020-07-05 17:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 13:30 [PATCH] emacs: Add notmuch-show-local-dates option Kevin J. Foley
2020-07-02 19:38 ` Daniel Kahn Gillmor
2020-07-02 22:02   ` Kevin Foley
2020-07-03 21:37     ` Daniel Kahn Gillmor
2020-07-03 22:58       ` David Bremner
2020-07-04 13:26         ` Daniel Kahn Gillmor
2020-07-04 13:32         ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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 read-only IMAP folder(s) and NNTP newsgroup(s).