From 309d1ac50f4c0cf30a0fe7f312bf4f9333aa1b8e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 27 Dec 2019 12:52:56 +0100 Subject: feat(dottime.el): Support dottime display in notmuch thread view Advises notmuch to display `Date` headers using dottime. --- tools/emacs-pkgs/dottime/dottime.el | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/emacs-pkgs/dottime/dottime.el b/tools/emacs-pkgs/dottime/dottime.el index 79ad86e844d4..1e02ece8cffa 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) -- cgit 1.4.1