[PATCH] emacs: Add notmuch-show-local-dates option
Kevin J. Foley
kevin at kevinjfoley.me
Thu Jun 25 06:30:16 PDT 2020
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 at 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 at 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 at 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 at ryngle.com> (2009-11-17) (inbox)
+Subject: [notmuch] What a great idea!
+ Jan Janak <jan at ryngle.com> (2009-11-17) (inbox)
+ Subject: [notmuch] What a great idea!
+ To: notmuch at 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 at cworth.org> (2009-11-18) (inbox unread)
--
2.19.0
More information about the notmuch
mailing list