Skip to content

Instantly share code, notes, and snippets.

@mhayashi1120
Created January 5, 2012 12:59
Show Gist options
  • Save mhayashi1120/1565163 to your computer and use it in GitHub Desktop.
Save mhayashi1120/1565163 to your computer and use it in GitHub Desktop.
Display local date for Mew message
(defvar mew-my-message-date-overlay nil)
(defun mew-my-message-date-overlay ()
(or
mew-my-message-date-overlay
(setq mew-my-message-date-overlay
(make-overlay (point-min) (point-min)))))
(defun mew-my-message-display-local-date ()
(condition-case err
(save-excursion
(goto-char (point-min))
(when (re-search-forward (concat "^" mew-date: " *\\(.*\\)") nil t)
(let* ((original (match-string 1))
(start (match-beginning 1))
(end (match-end 1))
(ov (mew-my-message-date-overlay))
(time (parse-time-string original))
(orig-tz (nth 8 time))
(tz (nth 8 (decode-time (current-time))))
(date (apply 'encode-time time))
(local (mew-time-ctz-to-rfc date)))
(unless (equal orig-tz tz)
(let ((new (format "%s == %s" original local)))
(move-overlay ov start end (current-buffer))
(overlay-put ov 'display new))))))
(error
(message "%s" err))))
(add-hook 'mew-message-hook 'mew-my-message-display-local-date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment