]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Clean up notmuch-search-show-result
authorAustin Clements <amdragon@MIT.EDU>
Mon, 9 Jul 2012 21:42:34 +0000 (17:42 -0400)
committerDavid Bremner <bremner@debian.org>
Thu, 12 Jul 2012 23:38:34 +0000 (17:38 -0600)
This simplifies the code and makes it no longer cubic in the number of
result fields.

emacs/notmuch.el

index c6236db26cf5327d8ad152ffa9363eb3dfb6ddb7..8ad0b68054ce228080120f1c96549a8281bb2876 100644 (file)
@@ -707,29 +707,30 @@ non-authors is found, assume that all of the authors match."
          (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
       (insert padding))))
 
-(defun notmuch-search-insert-field (field date count authors subject tags)
+(defun notmuch-search-insert-field (field format-string date count authors subject tags)
   (cond
    ((string-equal field "date")
-    (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) date)
+    (insert (propertize (format format-string date)
                        'face 'notmuch-search-date)))
    ((string-equal field "count")
-    (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) count)
+    (insert (propertize (format format-string count)
                        'face 'notmuch-search-count)))
    ((string-equal field "subject")
-    (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) subject)
+    (insert (propertize (format format-string subject)
                        'face 'notmuch-search-subject)))
 
    ((string-equal field "authors")
-    (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors))
+    (notmuch-search-insert-authors format-string authors))
 
    ((string-equal field "tags")
+    ;; Ignore format-string here because notmuch-search-set-tags
+    ;; depends on the format of this
     (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")")))))
 
 (defun notmuch-search-show-result (date count authors subject tags)
-  (let ((fields) (field))
-    (setq fields (mapcar 'car notmuch-search-result-format))
-    (loop for field in fields
-         do (notmuch-search-insert-field field date count authors subject tags)))
+  (dolist (spec notmuch-search-result-format)
+    (notmuch-search-insert-field (car spec) (cdr spec)
+                                date count authors subject tags))
   (insert "\n"))
 
 (defun notmuch-search-process-filter (proc string)