about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-27T11·52+0100
committerVincent Ambo <tazjin@google.com>2019-12-27T11·54+0100
commit309d1ac50f4c0cf30a0fe7f312bf4f9333aa1b8e (patch)
treee29db5d9e407040c73bab7f7f8a33e2395823cbf /tools
parent29e71053bed3b6fd7193a1d5718408a7dd33e7ee (diff)
feat(dottime.el): Support dottime display in notmuch thread view r/310
Advises notmuch to display `Date` headers using dottime.
Diffstat (limited to 'tools')
-rw-r--r--tools/emacs-pkgs/dottime/dottime.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/emacs-pkgs/dottime/dottime.el b/tools/emacs-pkgs/dottime/dottime.el
index 79ad86e844..1e02ece8cf 100644
--- a/tools/emacs-pkgs/dottime/dottime.el
+++ b/tools/emacs-pkgs/dottime/dottime.el
@@ -66,7 +66,7 @@
 ;;
 ;; This will never display offsets in the chat window, as those are
 ;; always visible in the modeline anyways.
-(when (-contains? features 'telega)
+(when (featurep 'telega)
   (defun telega-ins--dottime-advice (orig timestamp)
     (let* ((dtime (decode-time timestamp t))
            (current-ts (time-to-seconds (current-time)))
@@ -78,4 +78,22 @@
 
   (advice-add 'telega-ins--date :around #'telega-ins--dottime-advice))
 
+;; Amend the time display in notmuch to use dottime.
+(when (featurep 'notmuch)
+  (defun notmuch-show--dottime-date-advice (orig header header-value)
+    (if (equal "Date" header)
+        ;; Unfortunately the header insertion functions do not have access
+        ;; to the message object, which means that the only information we
+        ;; have about the timestamp is its string rendering.
+        (-let* (((sec min hour day mon year dow dst tz)
+                 (parse-time-string header-value)))
+          (insert header ": "
+                  (dottime-format (encode-time sec min hour day mon year tz)
+                                  tz "%a, %Y-")
+                  "\n"))
+
+      (funcall orig header header-value)))
+
+  (advice-add 'notmuch-show-insert-header :around #'notmuch-show--dottime-date-advice))
+
 (provide 'dottime)