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

10
TODO
View File

@ -22,12 +22,6 @@
- new-mail warning
==> [ workaround available, using mu4e-index-updated-hook ]
- 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
- review emacs menus
- re-factor / separate window/buffer management
@ -52,7 +46,9 @@
- mu4e: scroll down > go to next message
- mu: add contact: as a shortcut for matching from/to/cc/bcc:
- guile integration
- statistics
- 'human' dates in the headers view
* Done
:PROPERTIES:

View File

@ -47,7 +47,7 @@
:group 'mu4e)
(defcustom mu4e-headers-fields
'( (:date . 25)
'( (:human-date . 25)
(:flags . 6)
(:from . 22)
(:subject . nil))
@ -59,12 +59,18 @@ field. For the complete list of available headers, see
:type (list 'symbol)
: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
`format-time-string'."
:type 'string
: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
"Number of lines to display in the header view when using the
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
"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
"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)
(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)
"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."
(let ((docid (mu4e-message-field msg :docid)) (line ""))
(dolist (f-w mu4e-headers-fields)
(let ((field (car f-w)) (width (cdr f-w))
(val (mu4e-message-field msg (car f-w))) (str))
(setq str
(case field
(:subject
(concat ;; prefix subject with a thread indicator
(mu4e~headers-thread-prefix (mu4e-message-field msg :thread))
;; "["(plist-get (mu4e-message-field msg :thread) :path) "] "
val))
((:maildir :path) val)
((:to :from :cc :bcc) (mu4e~headers-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show
;; 'To', otherwise show From
(:from-or-to (mu4e~headers-from-or-to msg))
(:date (format-time-string mu4e-headers-date-format val))
(:flags (propertize (mu4e~headers-flags-str val)
'help-echo (format "%S" val)))
(:size (mu4e-display-size val))
(t (mu4e-error "Unsupported header field (%S)" field))))
(when str
(setq line
(concat line
(if (not width)
str
(truncate-string-to-width str width 0 ?\s t)) " ")))))
;; now, propertize it.
(setq line (propertize line 'face
(case (car-safe (mu4e-message-field msg :flags))
('draft 'mu4e-draft-face)
('trash 'mu4e-trashed-face)
((unread new) 'mu4e-unread-face)
('flagged 'mu4e-flagged-face)
((replied passed) 'mu4e-replied-face)
(t 'mu4e-header-face))))
;; now, append the header line
(mu4e~headers-add-header line docid point msg)))
(let ((docid (mu4e-message-field msg :docid)) (line ""))
(dolist (f-w mu4e-headers-fields)
(let ((field (car f-w)) (width (cdr f-w))
(val (mu4e-message-field msg (car f-w))) (str))
(setq str
(case field
(:subject
(concat ;; prefix subject with a thread indicator
(mu4e~headers-thread-prefix (mu4e-message-field msg :thread))
;; "["(plist-get (mu4e-message-field msg :thread) :path) "] "
val))
((:maildir :path) val)
((:to :from :cc :bcc) (mu4e~headers-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show
;; 'To', otherwise show From
(:from-or-to (mu4e~headers-from-or-to msg))
(:date (format-time-string mu4e-headers-date-format val))
(:human-date (mu4e~headers-human-date msg))
(:flags (propertize (mu4e~headers-flags-str val)
'help-echo (format "%S" val)))
(:size (mu4e-display-size val))
(t (mu4e-error "Unsupported header field (%S)" field))))
(when str
(setq line
(concat line
(if (not width)
str
(truncate-string-to-width str width 0 ?\s t)) " ")))))
;; now, propertize it.
(setq line (propertize line 'face
(case (car-safe (mu4e-message-field msg :flags))
('draft 'mu4e-draft-face)
('trash 'mu4e-trashed-face)
((unread new) 'mu4e-unread-face)
('flagged 'mu4e-flagged-face)
((replied passed) 'mu4e-replied-face)
(t 'mu4e-header-face))))
;; now, append the header line
(mu4e~headers-add-header line docid point msg)))
(defconst mu4e~no-matches (purecopy "No matching messages found"))
(defconst mu4e~end-of-results (purecopy "End of search results"))

View File

@ -460,6 +460,11 @@ headers)."
:shortname "Date"
:help "Date/time when the message was written"
:sortable t))
(:human-date .
( :name "Date"
:shortname "Date"
:help "Date/time when the message was written."
:sortable t))
(:flags .
( :name "Flags"
: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
the variable @code{mu4e-headers-fields}; see @code{mu4e-header-info} for the
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
``@t{^}''@footnote{or you can use little graphical triangles; see variable
@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},
a=@emph{has-attachment}, x=@emph{encrypted}, s=@emph{signed},
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
Jamie Zawinski's mail threading algorithm,
@url{http://www.jwz.org/doc/threading.html}}.