unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "Kevin J. Foley" <kevin@kevinjfoley.me>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: Add notmuch-show-local-dates option
Date: Thu, 25 Jun 2020 09:30:16 -0400	[thread overview]
Message-ID: <20200625133016.29701-1-kevin@kevinjfoley.me> (raw)

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

             reply	other threads:[~2020-06-25 13:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 13:30 Kevin J. Foley [this message]
2020-07-02 19:38 ` [PATCH] emacs: Add notmuch-show-local-dates option 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200625133016.29701-1-kevin@kevinjfoley.me \
    --to=kevin@kevinjfoley.me \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).