Re: timezone in notmuch

2020-04-15 Thread Teemu Likonen
Tomi Ollila [2020-04-15T23:17:32+03] wrote:

> I use this:
>
> https://github.com/domo141/nottoomuch/blob/master/build/01-date-local.patch
>
> I've been thinking if some hook could be added to notmuch-emacs so
> that such a custom date mangling can be done outside of the
> notmuch-emacs source...

Formerly I used Emacs Gnus and its hook to change the date. For this
discussion I adapted the idea to Notmuch. The code below is based on
idea that after article display there is a hook which can do anything
user wants. I wanted ISO 8601 date.



;; Add a hook for changing article's date string.
(add-hook 'some-article-display-hook 'tl-notmuch-custom-article-date)


(defmacro notmuch-narrow-to-article-headers ( body)
  ;; Implement macro which uses NARROW function to narrow current buffer
  ;; to article's headers only.
  `(progn ,@body))


(defun tl-notmuch-custom-article-date ()
  (save-excursion
(save-match-data
  (notmuch-narrow-to-article-headers
   (goto-char (point-min))
   (when (re-search-forward "^Date: \\(.+\\)$" nil t)
 (let ((inhibit-read-only t))
   (replace-match (tl-message-date-string-iso
   (match-string-no-properties 1))
  nil t nil 1)))


(defun tl-message-date-string-iso (string)
  ;; Parse message date STRING and return ISO 8601 time string.
  (require 'parse-time)
  (condition-case nil
  (let* ((date-list (parse-time-string string))
 (year (nth 5 date-list))
 (month (nth 4 date-list))
 (day (nth 3 date-list))
 (hour (nth 2 date-list))
 (min (nth 1 date-list))
 (sec (nth 0 date-list))
 (tz-total-sec (nth 8 date-list)))

(format "%04d-%02d-%02dT%02d:%02d:%02d%s"
year month day hour min sec
(if (not tz-total-sec)
""
  (let* ((tz-sign (if (>= tz-total-sec 0) "+" "-"))
 (tz-hour (truncate (abs tz-total-sec) 3600))
 (tz-min (truncate (- (abs tz-total-sec)
  (* tz-hour 3600))
   60)))
(cond
 ((= tz-hour tz-min 0) "Z")
 ((= tz-min 0)
  (format "%s%02d" tz-sign tz-hour))
 (t
  (format "%s%02d:%02d" tz-sign tz-hour tz-min)))

(error string)))


-- 
/// Teemu Likonen - .-.. http://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: timezone in notmuch

2020-04-15 Thread Brian May
Tomi Ollila  writes:

> I use this:
>
> https://github.com/domo141/nottoomuch/blob/master/build/01-date-local.patch
>
> I've been thinking if some hook could be added to notmuch-emacs so
> that such a custom date mangling can be done outside of the notmuch-emacs
> source...

I would like to see something like this without having to patch notmuch.

As much as I like notmuch-show-relative-dates, occasionally, I just want
to be able to see the exact time an email was sent in my timezone.
-- 
Brian May 
https://linuxpenguins.xyz/brian/
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: timezone in notmuch

2020-04-15 Thread Tomi Ollila
On Tue, Apr 14 2020, di...@santanas.co.za wrote:

> Greetings :)
>
> In notmuch-show-mode, some emails have a date like this: Date: Thu, 09
> Apr 2020 14:34:42 + while others like this Date: Sun, 12 Apr 2020
> 21:04:01 +0200
>
> Is this something I can change in notmuch to always show the date/time
> in my local timezone (SAST/+0200)?

I use this:

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

I've been thinking if some hook could be added to notmuch-emacs so
that such a custom date mangling can be done outside of the notmuch-emacs
source...

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: timezone in notmuch

2020-04-15 Thread Divan Santana
>> There's no user customizable variable for this. The code in this part of
>> notmuch show is fairly simple, so someone could probably figure out how
>> to pass (notmuch-show-get-timestamp) to the appropriate emacs function
>> to format the date in the local timezone.
>
> I should mention that having "notmuch-show-relative-dates" on hides this
> problem, since it doesn't use timezones at all. Perhaps you would prefer
> that (or perhaps not).

Good to know thanks.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: timezone in notmuch

2020-04-14 Thread David Bremner
David Bremner  writes:

>
> There's no user customizable variable for this. The code in this part of
> notmuch show is fairly simple, so someone could probably figure out how
> to pass (notmuch-show-get-timestamp) to the appropriate emacs function
> to format the date in the local timezone.

I should mention that having "notmuch-show-relative-dates" on hides this
problem, since it doesn't use timezones at all. Perhaps you would prefer
that (or perhaps not).

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: timezone in notmuch

2020-04-14 Thread David Bremner
di...@santanas.co.za writes:

> Greetings :)
>
> In notmuch-show-mode, some emails have a date like this: Date: Thu, 09
> Apr 2020 14:34:42 + while others like this Date: Sun, 12 Apr 2020
> 21:04:01 +0200
>
> Is this something I can change in notmuch to always show the date/time
> in my local timezone (SAST/+0200)?

There's no user customizable variable for this. The code in this part of
notmuch show is fairly simple, so someone could probably figure out how
to pass (notmuch-show-get-timestamp) to the appropriate emacs function
to format the date in the local timezone.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


timezone in notmuch

2020-04-14 Thread divan
Greetings :)

In notmuch-show-mode, some emails have a date like this: Date: Thu, 09
Apr 2020 14:34:42 + while others like this Date: Sun, 12 Apr 2020
21:04:01 +0200

Is this something I can change in notmuch to always show the date/time
in my local timezone (SAST/+0200)?

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch