[PATCH v2 10/11] emacs: notmuch-search: add display thread sizes capability

Subject: [PATCH v2 10/11] emacs: notmuch-search: add display thread sizes capability

Date: Fri, 19 May 2017 01:27:07 +0300

To: notmuch@notmuchmail.org

Cc:

From: Ioan-Adrian Ratiu


By default this is off because it's tiresome to look at all those
numbers in every search view. It's much more pleasant to have it
enabled by default in notmuch-show even if you apply searches and sort
results based on file size.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
---
 emacs/notmuch.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 5b9c1d07..dbcd67eb 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -73,7 +73,7 @@
     ("subject" . "%s ")
     ("tags" . "(%s)"))
   "Search result formatting. Supported fields are:
-	date, count, authors, subject, tags
+	date, count, total_filesize, authors, subject, tags
 For example:
 	(setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
 					     \(\"subject\" . \"%s\"\)\)\)
@@ -262,6 +262,12 @@ there will be called at other points of notmuch execution."
  :group 'notmuch-show
  :group 'notmuch-faces)
 
+(defface notmuch-search-thread-total-filesize
+  '((t :inherit default))
+  "Face used in search mode for total thread filesizes."
+  :group 'notmuch-search
+  :group 'notmuch-faces)
+
 (defface notmuch-search-date
   '((t :inherit default))
   "Face used in search mode for dates."
@@ -801,6 +807,9 @@ non-authors is found, assume that all of the authors match."
 
 (defun notmuch-search-insert-field (field format-string result)
   (cond
+   ((string-equal field "total-filesize")
+    (insert (propertize (format format-string (file-size-human-readable (plist-get result :total_filesize)))
+			'face 'notmuch-search-thread-total-filesize)))
    ((string-equal field "date")
     (insert (propertize (format format-string (plist-get result :date_relative))
 			'face 'notmuch-search-date)))
-- 
2.13.0


Thread: