fix(dottime.el): Defer package-specific setup
This commit is contained in:
parent
a54cc040ad
commit
100f451b0a
2 changed files with 33 additions and 30 deletions
|
@ -60,40 +60,42 @@
|
||||||
(if (or (eq arg 0) (eq arg nil))
|
(if (or (eq arg 0) (eq arg nil))
|
||||||
(advice-remove 'display-time-update #'dottime--display-time-update-advice)
|
(advice-remove 'display-time-update #'dottime--display-time-update-advice)
|
||||||
(advice-add 'display-time-update :around #'dottime--display-time-update-advice))
|
(advice-add 'display-time-update :around #'dottime--display-time-update-advice))
|
||||||
(display-time-update))
|
(display-time-update)
|
||||||
|
|
||||||
;; Amend the time display in telega.el to use dottime.
|
;; Amend the time display in telega.el to use dottime.
|
||||||
;;
|
;;
|
||||||
;; This will never display offsets in the chat window, as those are
|
;; This will never display offsets in the chat window, as those are
|
||||||
;; always visible in the modeline anyways.
|
;; always visible in the modeline anyways.
|
||||||
(when (featurep 'telega)
|
(when (featurep 'telega)
|
||||||
(defun telega-ins--dottime-advice (orig timestamp)
|
(require 'telega)
|
||||||
(let* ((dtime (decode-time timestamp t))
|
(defun telega-ins--dottime-advice (orig timestamp)
|
||||||
(current-ts (time-to-seconds (current-time)))
|
(let* ((dtime (decode-time timestamp t))
|
||||||
(ctime (decode-time current-ts))
|
(current-ts (time-to-seconds (current-time)))
|
||||||
(today00 (telega--time-at00 current-ts ctime)))
|
(ctime (decode-time current-ts))
|
||||||
(if (> timestamp today00)
|
(today00 (telega--time-at00 current-ts ctime)))
|
||||||
(telega-ins-fmt "%02d·%02d" (nth 2 dtime) (nth 1 dtime))
|
(if (> timestamp today00)
|
||||||
(funcall orig timestamp))))
|
(telega-ins-fmt "%02d·%02d" (nth 2 dtime) (nth 1 dtime))
|
||||||
|
(funcall orig timestamp))))
|
||||||
|
|
||||||
(advice-add 'telega-ins--date :around #'telega-ins--dottime-advice))
|
(advice-add 'telega-ins--date :around #'telega-ins--dottime-advice))
|
||||||
|
|
||||||
;; Amend the time display in notmuch to use dottime.
|
;; Amend the time display in notmuch to use dottime.
|
||||||
(when (featurep 'notmuch)
|
(when (featurep 'notmuch)
|
||||||
(defun notmuch-show--dottime-date-advice (orig header header-value)
|
(require 'notmuch)
|
||||||
(if (equal "Date" header)
|
(defun notmuch-show--dottime-date-advice (orig header header-value)
|
||||||
;; Unfortunately the header insertion functions do not have access
|
(if (equal "Date" header)
|
||||||
;; to the message object, which means that the only information we
|
;; Unfortunately the header insertion functions do not have access
|
||||||
;; have about the timestamp is its string rendering.
|
;; to the message object, which means that the only information we
|
||||||
(-let* (((sec min hour day mon year dow dst tz)
|
;; have about the timestamp is its string rendering.
|
||||||
(parse-time-string header-value)))
|
(-let* (((sec min hour day mon year dow dst tz)
|
||||||
(insert header ": "
|
(parse-time-string header-value)))
|
||||||
(dottime-format (encode-time sec min hour day mon year tz)
|
(insert header ": "
|
||||||
tz "%a, %Y-")
|
(dottime-format (encode-time sec min hour day mon year tz)
|
||||||
"\n"))
|
tz "%a, %Y-")
|
||||||
|
"\n"))
|
||||||
|
|
||||||
(funcall orig header header-value)))
|
(funcall orig header header-value)))
|
||||||
|
|
||||||
(advice-add 'notmuch-show-insert-header :around #'notmuch-show--dottime-date-advice))
|
(advice-add 'notmuch-show-insert-header :around #'notmuch-show--dottime-date-advice)))
|
||||||
|
|
||||||
(provide 'dottime)
|
(provide 'dottime)
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
(use-package dash-functional)
|
(use-package dash-functional)
|
||||||
|
|
||||||
(use-package dottime
|
(use-package dottime
|
||||||
|
:demand
|
||||||
:after (notmuch telega)
|
:after (notmuch telega)
|
||||||
:config (dottime-display-mode t))
|
:config (dottime-display-mode t))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue