* mu4e: add 'human' dates, that is: show the time for today's message time,

the date otherwise, in the headers view
This commit is contained in:
djcb 2012-10-19 12:02:13 +03:00
parent 8890090c33
commit 47286442e1
5 changed files with 81 additions and 56 deletions

13
NEWS
View File

@ -4,10 +4,15 @@
** Release 0.9.9.x ** Release 0.9.9.x
*** mu
- add 'mu stats' command to show statistics about your messages. Requires
guile 2.0, gnuplot
*** mu4e *** mu4e
- scroll down in message view takes you to next message (but see - scroll down in message view takes you to next message (but see
`mu4e-view-scroll-to-next') `mu4e-view-scroll-to-next')
- support 'human dates', that is, show the time for today's messages, and
the date for older messages in the headers view
* Old news * Old news
:PROPERTIES: :PROPERTIES:
@ -24,7 +29,7 @@
- support signing / decryption of messages - support signing / decryption of messages
- improve address-autocompletion (e.g., ensure it's case-insensitive) - improve address-autocompletion (e.g., ensure it's case-insensitive)
- much faster when there are many maildirs - much faster when there are many maildirs
- improved line wrapping - improved line wrapping
- better handle attached messages - better handle attached messages
- improved URL-matching - improved URL-matching
- improved messages to user (mu4e-(warn|error|message)) - improved messages to user (mu4e-(warn|error|message))
@ -76,8 +81,8 @@
- fix sorting by subject (disregarding Re:, Fwd: etc.) - fix sorting by subject (disregarding Re:, Fwd: etc.)
- much faster handling when there are many maildirs (speedbar) - much faster handling when there are many maildirs (speedbar)
- handle mailto: links - handle mailto: links
- improved, extended documentation - improved, extended documentation
*** mu *** mu
- support .noupdate files (parallel to .noindex, dir is ignored unless we're - support .noupdate files (parallel to .noindex, dir is ignored unless we're

10
TODO
View File

@ -22,12 +22,6 @@
- new-mail warning - new-mail warning
==> [ workaround available, using mu4e-index-updated-hook ] ==> [ workaround available, using mu4e-index-updated-hook ]
- custom header fields in headers-view, message-view - custom header fields in headers-view, message-view
- 'human' dates
- guile integration
- statistics
- check if we can speed up mu4e-proc parsing by using search rather than
regexp search
==> probably not
- show maildirs as a tree, not a list in speed bar - show maildirs as a tree, not a list in speed bar
- review emacs menus - review emacs menus
- re-factor / separate window/buffer management - re-factor / separate window/buffer management
@ -52,7 +46,9 @@
- mu4e: scroll down > go to next message - mu4e: scroll down > go to next message
- mu: add contact: as a shortcut for matching from/to/cc/bcc: - mu: add contact: as a shortcut for matching from/to/cc/bcc:
- guile integration
- statistics
- 'human' dates in the headers view
* Done * Done
:PROPERTIES: :PROPERTIES:

View File

@ -47,7 +47,7 @@
:group 'mu4e) :group 'mu4e)
(defcustom mu4e-headers-fields (defcustom mu4e-headers-fields
'( (:date . 25) '( (:human-date . 25)
(:flags . 6) (:flags . 6)
(:from . 22) (:from . 22)
(:subject . nil)) (:subject . nil))
@ -59,12 +59,18 @@ field. For the complete list of available headers, see
:type (list 'symbol) :type (list 'symbol)
:group 'mu4e-headers) :group 'mu4e-headers)
(defcustom mu4e-headers-date-format "%x %X" (defcustom mu4e-headers-date-format "%x"
"Date format to use in the headers view, in the format of "Date format to use in the headers view, in the format of
`format-time-string'." `format-time-string'."
:type 'string :type 'string
:group 'mu4e-headers) :group 'mu4e-headers)
(defcustom mu4e-headers-time-format "%X"
"Time format to use in the headers view, in the format of
`format-time-string'."
:type 'string
:group 'mu4e-headers)
(defcustom mu4e-headers-visible-lines 10 (defcustom mu4e-headers-visible-lines 10
"Number of lines to display in the header view when using the "Number of lines to display in the header view when using the
horizontal split-view. This includes the header-line at the top, horizontal split-view. This includes the header-line at the top,
@ -133,7 +139,7 @@ PREDICATE-FUNC as PARAM. This is useful for getting user-input.")
(defvar mu4e-headers-sortfield :date (defvar mu4e-headers-sortfield :date
"Field to sort the headers by. Field must be a symbol, one of: "Field to sort the headers by. Field must be a symbol, one of:
date, subject, size, prio, from, to.") :date, :subject, :size, :prio, :from, :to.")
(defvar mu4e-headers-sort-revert t (defvar mu4e-headers-sort-revert t
"Whether to revert the sort-order, i.e. Z->A instead of A-Z. When "Whether to revert the sort-order, i.e. Z->A instead of A-Z. When
@ -324,48 +330,57 @@ show the from address; prefixed with the appropriate
(concat (car mu4e-headers-from-or-to-prefix) (concat (car mu4e-headers-from-or-to-prefix)
(mu4e~headers-contact-str (mu4e-message-field msg :from)))))) (mu4e~headers-contact-str (mu4e-message-field msg :from))))))
;; note: this function is very performance-sensitive (defsubst mu4e~headers-human-date (msg)
"Show a 'human' date -- that is, if the date is today, show the
date, otherwise, show the time."
(let ((date (mu4e-msg-field msg :date)))
(if (= (nth 3 (decode-time date)) (nth 3 (decode-time (current-time))))
(format-time-string mu4e-headers-time-format date)
(format-time-string mu4e-headers-date-format date))))
;; note: this function is very performance-sensitive
(defun mu4e~headers-header-handler (msg &optional point) (defun mu4e~headers-header-handler (msg &optional point)
"Create a one line description of MSG in this buffer, at POINT, "Create a one line description of MSG in this buffer, at POINT,
if provided, or at the end of the buffer otherwise." if provided, or at the end of the buffer otherwise."
(let ((docid (mu4e-message-field msg :docid)) (line "")) (let ((docid (mu4e-message-field msg :docid)) (line ""))
(dolist (f-w mu4e-headers-fields) (dolist (f-w mu4e-headers-fields)
(let ((field (car f-w)) (width (cdr f-w)) (let ((field (car f-w)) (width (cdr f-w))
(val (mu4e-message-field msg (car f-w))) (str)) (val (mu4e-message-field msg (car f-w))) (str))
(setq str (setq str
(case field (case field
(:subject (:subject
(concat ;; prefix subject with a thread indicator (concat ;; prefix subject with a thread indicator
(mu4e~headers-thread-prefix (mu4e-message-field msg :thread)) (mu4e~headers-thread-prefix (mu4e-message-field msg :thread))
;; "["(plist-get (mu4e-message-field msg :thread) :path) "] " ;; "["(plist-get (mu4e-message-field msg :thread) :path) "] "
val)) val))
((:maildir :path) val) ((:maildir :path) val)
((:to :from :cc :bcc) (mu4e~headers-contact-str val)) ((:to :from :cc :bcc) (mu4e~headers-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show ;; if we (ie. `user-mail-address' is the 'From', show
;; 'To', otherwise show From ;; 'To', otherwise show From
(:from-or-to (mu4e~headers-from-or-to msg)) (:from-or-to (mu4e~headers-from-or-to msg))
(:date (format-time-string mu4e-headers-date-format val)) (:date (format-time-string mu4e-headers-date-format val))
(:flags (propertize (mu4e~headers-flags-str val) (:human-date (mu4e~headers-human-date msg))
'help-echo (format "%S" val))) (:flags (propertize (mu4e~headers-flags-str val)
(:size (mu4e-display-size val)) 'help-echo (format "%S" val)))
(t (mu4e-error "Unsupported header field (%S)" field)))) (:size (mu4e-display-size val))
(when str (t (mu4e-error "Unsupported header field (%S)" field))))
(setq line (when str
(concat line (setq line
(if (not width) (concat line
str (if (not width)
(truncate-string-to-width str width 0 ?\s t)) " "))))) str
;; now, propertize it. (truncate-string-to-width str width 0 ?\s t)) " ")))))
(setq line (propertize line 'face ;; now, propertize it.
(case (car-safe (mu4e-message-field msg :flags)) (setq line (propertize line 'face
('draft 'mu4e-draft-face) (case (car-safe (mu4e-message-field msg :flags))
('trash 'mu4e-trashed-face) ('draft 'mu4e-draft-face)
((unread new) 'mu4e-unread-face) ('trash 'mu4e-trashed-face)
('flagged 'mu4e-flagged-face) ((unread new) 'mu4e-unread-face)
((replied passed) 'mu4e-replied-face) ('flagged 'mu4e-flagged-face)
(t 'mu4e-header-face)))) ((replied passed) 'mu4e-replied-face)
;; now, append the header line (t 'mu4e-header-face))))
(mu4e~headers-add-header line docid point msg))) ;; now, append the header line
(mu4e~headers-add-header line docid point msg)))
(defconst mu4e~no-matches (purecopy "No matching messages found")) (defconst mu4e~no-matches (purecopy "No matching messages found"))
(defconst mu4e~end-of-results (purecopy "End of search results")) (defconst mu4e~end-of-results (purecopy "End of search results"))

View File

@ -460,6 +460,11 @@ headers)."
:shortname "Date" :shortname "Date"
:help "Date/time when the message was written" :help "Date/time when the message was written"
:sortable t)) :sortable t))
(:human-date .
( :name "Date"
:shortname "Date"
:help "Date/time when the message was written."
:sortable t))
(:flags . (:flags .
( :name "Flags" ( :name "Flags"
:shortname "Flgs" :shortname "Flgs"

View File

@ -703,6 +703,12 @@ Some notes to explain what you see in the example:
@item The fields shown in the headers view can be influenced by customizing @item The fields shown in the headers view can be influenced by customizing
the variable @code{mu4e-headers-fields}; see @code{mu4e-header-info} for the the variable @code{mu4e-headers-fields}; see @code{mu4e-header-info} for the
list of available fields. list of available fields.
@item By default, the date is shown with the @t{:human-date} field, which
shows the @emph{time} for today's messages, and the @emph{date} for older
messages. If you want to distinguish between 'today' and 'older', you can use
the @t{:date} field instead.
@item You can customize the date and time formats with the variable
@t{mu4e-headers-date-format} and @t{mu4e-headers-time-format}, respectively.
@item The header field used for sorting is indicated by ``@t{V}'' or @item The header field used for sorting is indicated by ``@t{V}'' or
``@t{^}''@footnote{or you can use little graphical triangles; see variable ``@t{^}''@footnote{or you can use little graphical triangles; see variable
@code{mu4e-use-fancy-chars}}, indicating the sort order (descending or @code{mu4e-use-fancy-chars}}, indicating the sort order (descending or
@ -722,8 +728,6 @@ F=@emph{flagged} (i.e., 'starred'), N=@emph{new}, P=@emph{passed} (i.e.,
forwarded), R=@emph{replied}, S=@emph{seen}, T=@emph{trashed}, forwarded), R=@emph{replied}, S=@emph{seen}, T=@emph{trashed},
a=@emph{has-attachment}, x=@emph{encrypted}, s=@emph{signed}, a=@emph{has-attachment}, x=@emph{encrypted}, s=@emph{signed},
u=@emph{unread}. The tooltip for this field also contains this information. u=@emph{unread}. The tooltip for this field also contains this information.
@item You can customize the date format with the variable
@t{mu4e-headers-date-format}
@item The subject field also indicates the discussion threads @footnote{using @item The subject field also indicates the discussion threads @footnote{using
Jamie Zawinski's mail threading algorithm, Jamie Zawinski's mail threading algorithm,
@url{http://www.jwz.org/doc/threading.html}}. @url{http://www.jwz.org/doc/threading.html}}.