* [DRAFT PATCH] emacs: show local date next to Date: in case value differs
@ 2015-03-23 17:45 Tomi Ollila
2015-04-01 23:30 ` David Bremner
2015-04-06 8:02 ` Mark Walters
0 siblings, 2 replies; 7+ messages in thread
From: Tomi Ollila @ 2015-03-23 17:45 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila, Tomi Ollila
From: Tomi Ollila <too@iki.fi>
When adding Date: header of a message to notmuch-show buffer, compare the
date string with local representation of it and if these differ, output
Date: {original-date-string} ({local-date-representation})
This is useful e.g. when mail system provides Date: strings with
different timezone information than the sender is located at.
---
emacs/notmuch-show.el | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f15f981..7e81859 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -460,15 +460,28 @@ (defun notmuch-show-insert-header (header header-value)
"Insert a single header."
(insert header ": " (notmuch-sanitize header-value) "\n"))
-(defun notmuch-show-insert-headers (headers)
+(defun notmuch--make-date (timestamp)
+ (if (> timestamp 2147483647)
+ (message-make-date (seconds-to-time timestamp))
+ (message-make-date (encode-time timestamp 0 0 1 1 1970 t))))
+
+(defun notmuch-show-insert-headers (headers &optional timestamp)
"Insert the headers of the current message."
- (let ((start (point)))
+ (let ((start (point))
+ date-local)
(mapc (lambda (header)
(let* ((header-symbol (intern (concat ":" header)))
(header-value (plist-get headers header-symbol)))
- (if (and header-value
- (not (string-equal "" header-value)))
- (notmuch-show-insert-header header header-value))))
+ (when (and header-value
+ (not (string-equal "" header-value)))
+ (if (and timestamp
+ (string-equal header "Date")
+ (not (string-equal
+ (setq date-local (notmuch--make-date timestamp))
+ header-value)))
+ (setq header-value
+ (format "%s (%s)" header-value date-local)))
+ (notmuch-show-insert-header header header-value))))
notmuch-message-headers)
(save-excursion
(save-restriction
@@ -1012,7 +1025,7 @@ (defun notmuch-show-insert-msg (msg depth)
;; Set `headers-start' to point after the 'Subject:' header to be
;; compatible with the existing implementation. This just sets it
;; to after the first header.
- (notmuch-show-insert-headers headers)
+ (notmuch-show-insert-headers headers (plist-get msg :timestamp))
(save-excursion
(goto-char content-start)
;; If the subject of this message is the same as that of the
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs
2015-03-23 17:45 [DRAFT PATCH] emacs: show local date next to Date: in case value differs Tomi Ollila
@ 2015-04-01 23:30 ` David Bremner
2015-04-07 8:42 ` Tomi Ollila
2015-04-06 8:02 ` Mark Walters
1 sibling, 1 reply; 7+ messages in thread
From: David Bremner @ 2015-04-01 23:30 UTC (permalink / raw)
To: Tomi Ollila, notmuch
Tomi Ollila <tomi.ollila@iki.fi> writes:
> When adding Date: header of a message to notmuch-show buffer, compare the
> date string with local representation of it and if these differ, output
> Date: {original-date-string} ({local-date-representation})
One thing I found confusing is that the local date representation is
mostly redundant in the default configuration, as the date shown in the
"headerline" is already in the local time zone if
"notmuch-show-relative-dates" is t. From the fact that you made this
patch I'm guessing that you don't use that setting.
One option which would have the advantage not being as wide on the
screen (Maybe my use case is strange, but I often use notmuch is 66
column half screen-width terminals) would be to (optionally?) display
the non-relative date in the headerline in the local time zone.
> This is useful e.g. when mail system provides Date: strings with
> different timezone information than the sender is located at.
I'm not sure how local time information helps with the sender? Unless
you happen to be in the same time zone.
d
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs
2015-04-01 23:30 ` David Bremner
@ 2015-04-07 8:42 ` Tomi Ollila
2015-08-16 10:15 ` David Bremner
0 siblings, 1 reply; 7+ messages in thread
From: Tomi Ollila @ 2015-04-07 8:42 UTC (permalink / raw)
To: David Bremner, notmuch
On Thu, Apr 02 2015, David Bremner <david@tethera.net> wrote:
> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> When adding Date: header of a message to notmuch-show buffer, compare the
>> date string with local representation of it and if these differ, output
>> Date: {original-date-string} ({local-date-representation})
>
> One thing I found confusing is that the local date representation is
> mostly redundant in the default configuration, as the date shown in the
> "headerline" is already in the local time zone if
> "notmuch-show-relative-dates" is t. From the fact that you made this
> patch I'm guessing that you don't use that setting.
I am using that setting...
Now I took a little better look why the 'relative' date is not enough for
me is that it doesn't always show the local date (it shows like
(28 mins. ago) or (March 30)). If these were (28 mins. ago (07:22)) and
(March 30 16:20) then it would be better (w/ +0300 that might be marginally
more useful in general but perhaps something that can be lived without).
In this position where I am now I often get email from person residing
like 50 footsteps from me (in current tz +0300, yet the email server
writes emails with tz -0500) Now if email was sent 28 minutes ago I cannot
immediately crasp what is that email in local time. Other similar effect
is when my old classmate puts a message to Facebook -- IIRC the timezones
of the notification emails there are -0700.
What makes this situation worse is that the notmuch-show buffer is showing
email arrived 28 mins. ago but the buffer has been sitting there for 2
hours while I've been doing something else; the relative date information
is not updated.
With (March 30) figuring out when that email was sent in local time is
harder as the granularity in relative date is 'one day'.
In IRC Jani mentioned it is feature to see the sender's TZ. I also consider
it as a feature. But also knowing the local time (quickly) is a feature to
me: An example: Someone(TM) sent email to a bunch of recipients yesterday
18:28 (that is 6.28 pm) from TZ -0500. Relative date showed that it was
sent (Today 02:28).
Just an hour ago we had a meeting where knowing that "half past 2" was
important information...
Based on this I start experimenting how I could "improve" the headerline
for my case -- so that in notmuch-show buffer the relative date has more
information. In notmuch-search buffer there is just not enough space.
Then I have to learn to look the headerline for this information...
Also, thanks to Mark for his comments of the implementation. Those will
be useful at least in some other stuff I've planned to do...
> One option which would have the advantage not being as wide on the
> screen (Maybe my use case is strange, but I often use notmuch is 66
> column half screen-width terminals) would be to (optionally?) display
> the non-relative date in the headerline in the local time zone.
Before thinking how the "headerline" could be "improved" (for notmuch-show
buffer) I thought whether the local date could just show (hh:mm [+-]nnnn).
Also the comparison whether to show this additional info could be just
based on difference in timezone strings...
>> This is useful e.g. when mail system provides Date: strings with
>> different timezone information than the sender is located at.
>
> I'm not sure how local time information helps with the sender? Unless
> you happen to be in the same time zone.
Yes, it would be exceptionally irritating someone living in different
timezone and the emails sent would show yet another timezone. Then seeing
local time would be more informational than the original Date:
>
> d
Tomi
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs
2015-04-07 8:42 ` Tomi Ollila
@ 2015-08-16 10:15 ` David Bremner
2015-08-16 19:43 ` Tomi Ollila
0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2015-08-16 10:15 UTC (permalink / raw)
To: Tomi Ollila, notmuch
Tomi Ollila <tomi.ollila@iki.fi> writes:
> Now I took a little better look why the 'relative' date is not enough for
> me is that it doesn't always show the local date (it shows like
> (28 mins. ago) or (March 30)). If these were (28 mins. ago (07:22)) and
> (March 30 16:20) then it would be better (w/ +0300 that might be marginally
> more useful in general but perhaps something that can be lived without).
Going back to this thread after a long time, what about an option to
show dates always in local absolute time only? This would be compact,
and somehow easy to decode. Or more generally, choose a TZ to display
all dates in?
d
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs
2015-08-16 10:15 ` David Bremner
@ 2015-08-16 19:43 ` Tomi Ollila
2015-08-17 12:29 ` David Bremner
0 siblings, 1 reply; 7+ messages in thread
From: Tomi Ollila @ 2015-08-16 19:43 UTC (permalink / raw)
To: David Bremner, notmuch
On Sun, Aug 16 2015, David Bremner <david@tethera.net> wrote:
> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> Now I took a little better look why the 'relative' date is not enough for
>> me is that it doesn't always show the local date (it shows like
>> (28 mins. ago) or (March 30)). If these were (28 mins. ago (07:22)) and
>> (March 30 16:20) then it would be better (w/ +0300 that might be marginally
>> more useful in general but perhaps something that can be lived without).
>
> Going back to this thread after a long time, what about an option to
> show dates always in local absolute time only? This would be compact,
> and somehow easy to decode. Or more generally, choose a TZ to display
> all dates in?
Somebody might like that, but *I* want to be able to see the sender date
(being it right or wrong, machine cannot be sure but human reader can
guess better) and local time (a version that is always absolute). In my
emacs buffer the Date: header in your email currently looked to me like:
Date: Sun, 16 Aug 2015 12:15:14 +0200 (Sun, 16 Aug 2015 13:15:14 +0300)
In this case the dates did not make much of a difference (and in this time
(22:39 +0300)) the message header bar there was (Today 13:15)). Anyway
sometimes IT matters and in my 80-character terminal window this fits fine.
I don't know better solution and don't know whether there is anyone else
interested in such a feature so I just keep using this for myself...
Tomi
> d
PS: last moment revelation: perhaps I could use just (13:15:14 +0300) there;
still if I'd be the single user of that...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [DRAFT PATCH] emacs: show local date next to Date: in case value differs
2015-03-23 17:45 [DRAFT PATCH] emacs: show local date next to Date: in case value differs Tomi Ollila
2015-04-01 23:30 ` David Bremner
@ 2015-04-06 8:02 ` Mark Walters
1 sibling, 0 replies; 7+ messages in thread
From: Mark Walters @ 2015-04-06 8:02 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila, Tomi Ollila
On Mon, 23 Mar 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> From: Tomi Ollila <too@iki.fi>
>
> When adding Date: header of a message to notmuch-show buffer, compare the
> date string with local representation of it and if these differ, output
> Date: {original-date-string} ({local-date-representation})
>
> This is useful e.g. when mail system provides Date: strings with
> different timezone information than the sender is located at.
I think this could be useful. I have to admit that until David pointed
it out in his reply I hadn't noticed the date in the headerline and I do
think the date header is a natural place to display this.
Jani made a comment on irc that the display could be rather cluttered
so I think it should be customizable. Ideally I would suggest having the
options of none (ie display just the sender date as now), local full
date (as your patch), and relative (to put the relative date in the
date header).
I have some small comments on the implementation:
> ---
> emacs/notmuch-show.el | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index f15f981..7e81859 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -460,15 +460,28 @@ (defun notmuch-show-insert-header (header header-value)
> "Insert a single header."
> (insert header ": " (notmuch-sanitize header-value) "\n"))
>
> -(defun notmuch-show-insert-headers (headers)
> +(defun notmuch--make-date (timestamp)
> + (if (> timestamp 2147483647)
> + (message-make-date (seconds-to-time timestamp))
> + (message-make-date (encode-time timestamp 0 0 1 1 1970 t))))
> +
> +(defun notmuch-show-insert-headers (headers &optional timestamp)
I suggest passing msg as an optional argument instead of timestamp. I
think it will be more flexible if people want to have other
header modification functions in the future (for example we could add
the senders name to the from line if we know it from other messages).
> "Insert the headers of the current message."
> - (let ((start (point)))
> + (let ((start (point))
> + date-local)
> (mapc (lambda (header)
> (let* ((header-symbol (intern (concat ":" header)))
> (header-value (plist-get headers header-symbol)))
> - (if (and header-value
> - (not (string-equal "" header-value)))
> - (notmuch-show-insert-header header header-value))))
> + (when (and header-value
> + (not (string-equal "" header-value)))
> + (if (and timestamp
> + (string-equal header "Date")
> + (not (string-equal
> + (setq date-local (notmuch--make-date timestamp))
> + header-value)))
> + (setq header-value
> + (format "%s (%s)" header-value date-local)))
I think I would extract this block as a date-header-wash function. Then
the one special case doesn't interrupt the main function. Something like
(let ((washed-header-value (if (string-equal header "Date")
(notmuch-date-header-wash header msg)
header-value)))
(This could go inside or outside the "when")
Best wishes
Mark
> + (notmuch-show-insert-header header header-value))))
> notmuch-message-headers)
> (save-excursion
> (save-restriction
> @@ -1012,7 +1025,7 @@ (defun notmuch-show-insert-msg (msg depth)
> ;; Set `headers-start' to point after the 'Subject:' header to be
> ;; compatible with the existing implementation. This just sets it
> ;; to after the first header.
> - (notmuch-show-insert-headers headers)
> + (notmuch-show-insert-headers headers (plist-get msg :timestamp))
> (save-excursion
> (goto-char content-start)
> ;; If the subject of this message is the same as that of the
> --
> 1.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-08-17 12:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-23 17:45 [DRAFT PATCH] emacs: show local date next to Date: in case value differs Tomi Ollila
2015-04-01 23:30 ` David Bremner
2015-04-07 8:42 ` Tomi Ollila
2015-08-16 10:15 ` David Bremner
2015-08-16 19:43 ` Tomi Ollila
2015-08-17 12:29 ` David Bremner
2015-04-06 8:02 ` Mark Walters
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).