mu4e: experimental :thread-subject field (one subject per thread)

with :thread-subject field, we attempt to only show one subject per
thread, somewhat like mutt does it.

the current implementation is straightforward, but does not take into
account whether the thread-subject is currently visible on the screen,
which is a bit tricky to implement
This commit is contained in:
djcb 2015-03-22 11:49:57 +02:00
parent f160ad95f1
commit 910e41e2fe
3 changed files with 29 additions and 6 deletions

View File

@ -434,6 +434,19 @@ date. The formats used for date and time are
(format-time-string mu4e-headers-date-format date))))))
(defsubst mu4e~headers-thread-subject (msg)
"Get the subject if it is the first one in a thread; otherwise,
return the thread-prefix without the subject-text. In other words,
show the subject of a thread only once, similar to e.g. 'mutt'."
(let ((tinfo (mu4e-message-field msg :thread))
(subj (mu4e-msg-field msg :subject)))
(concat ;; prefix subject with a thread indicator
(mu4e~headers-thread-prefix tinfo)
(if (or (zerop (plist-get tinfo :level))
(plist-get tinfo :empty-parent))
(truncate-string-to-width subj 600) ""))))
(defsubst mu4e~headers-mailing-list (list)
"Get some identifier for the mailing list."
(if list
@ -467,6 +480,7 @@ if provided, or at the end of the buffer otherwise."
;; work-around: emacs' display gets really slow when lines are too long;
;; so limit subject length to 600
(truncate-string-to-width val 600)))
(:thread-subject (mu4e~headers-thread-subject msg))
((:maildir :path :message-id) val)
((:to :from :cc :bcc) (mu4e~headers-contact-str val))
;; if we (ie. `user-mail-address' is the 'From', show

View File

@ -658,6 +658,11 @@ mu4e-compose-mode."
:shortname "Tags"
:help "Tags for the message"
:sortable nil))
(:thread-subject .
( :name "Subject"
:shortname "Subject"
:help "Subject of the thread"
:sortable :subject))
(:to .
( :name "To"
:shortname "T"

View File

@ -779,11 +779,15 @@ the @t{:date} field instead.
@code{mu4e-headers-date-format} and @code{mu4e-headers-time-format},
respectively. In the example, we use @code{:human-date}, which shows when the
time when the message was sent today, and the date otherwise.
@item By default, the subject is shown using the @t{:subject} field;
however, it is also possible to use @t{:thread-subject}, which shows
the subject of a thread only once, similar to the display of the
@t{mutt} e-mail client.
@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}}, corresponding to the sort order (descending or
ascending, respectively). You can influence this by a mouse click, or
@key{O}. Not all fields allow sorting.
``@t{^}''@footnote{or you can use little graphical triangles; see
variable @code{mu4e-use-fancy-chars}}, corresponding to the sort order
(descending or ascending, respectively). You can influence this by a
mouse click, or @key{O}. Not all fields allow sorting.
@item Instead of showing the @t{From:} and @t{To:} fields separately, you
can use From/To (@t{:from-or-to} in @code{mu4e-headers-fields} as a more
compact way to convey the most important information: it shows @t{From:}
@ -2984,10 +2988,10 @@ customize.
;; (better only use that for the last field.
;; These are the defaults:
(setq mu4e-headers-fields
'( (:date . 25)
'( (:date . 25) ;; alternatively, use :human-date
(:flags . 6)
(:from . 22)
(:subject . nil)))
(:subject . nil))) ;; alternatively, use :thread-subject
;; program to get mail; alternatives are 'fetchmail', 'getmail'
;; isync or your own shellscript. called when 'U' is pressed in