[PATCH 2/4] contrib: pick: move the insertion of fields up a level
authorMark Walters <markwalters1009@gmail.com>
Mon, 2 Sep 2013 03:28:06 +0000 (04:28 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:49 +0000 (09:56 -0800)
39/f96dea4c325fff786c672fd2be3dced1ea7eb0 [new file with mode: 0644]

diff --git a/39/f96dea4c325fff786c672fd2be3dced1ea7eb0 b/39/f96dea4c325fff786c672fd2be3dced1ea7eb0
new file mode 100644 (file)
index 0000000..eef5150
--- /dev/null
@@ -0,0 +1,158 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 19DB3431FC7\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Sep 2013 20:28:26 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id BqbPAe0J2E3P for <notmuch@notmuchmail.org>;\r
+       Sun,  1 Sep 2013 20:28:21 -0700 (PDT)\r
+Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com\r
+ [74.125.82.42])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ AF369431FC9   for <notmuch@notmuchmail.org>; Sun,  1 Sep 2013 20:28:17 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f42.google.com with SMTP id c11so1336425wgh.5\r
+       for <notmuch@notmuchmail.org>; Sun, 01 Sep 2013 20:28:16 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+       bh=Nir72BTilBpsLbDhhNJlPQ5m4PSaxttcr1fgrFeGmrE=;\r
+       b=J3eeZ/VtlmO1p+/2AJpwmF9c8DGAkRztsB8HrWNhGBrD2KFbrh1axIHNJUZw0H2lg/\r
+       AS3FzBYjipJGKPGCyOmjcgecmQZ616dTX/KTxZC8KWBrvX+eGKAqRT9hNzuvK9nHseBJ\r
+       DXwXYujI3aM+6hRNlW/lioVSq3xJREIcEjCxTxQSSOnqTHUOm562EYnvYzODaQWoUoEg\r
+       xDJODFNzcVPX2qNh9F8iXbzx9FWWaBMZgQnwau5NXcMgZ00KVnOYMkOyLTVIEUfAQFin\r
+       ctyc1dURsvsA2ZrwkioWAwEz9FcGWt4q2QMrzACJ9WK6bMmrzcVDwQ26/4An6DXW4gX8\r
+       yszw==\r
+X-Received: by 10.180.205.163 with SMTP id lh3mr11750457wic.27.1378092496648; \r
+       Sun, 01 Sep 2013 20:28:16 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPSA id i3sm14853643wiw.7.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 01 Sep 2013 20:28:16 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] contrib: pick: move the insertion of fields up a level\r
+Date: Mon,  2 Sep 2013 04:28:06 +0100\r
+Message-Id: <1378092488-32050-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1378092488-32050-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1378092488-32050-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 02 Sep 2013 03:28:26 -0000\r
+\r
+This moves the actual insertion of message fields up from the field\r
+formatting function into the message insertion function. This will be\r
+useful in the next patch as we can apply further formatting to the\r
+insertion string before inserting.\r
+---\r
+ contrib/notmuch-pick/notmuch-pick.el |   41 +++++++++++++++++++--------------\r
+ 1 files changed, 24 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index 063d660..f01be94 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -610,16 +610,19 @@ unchanged ADDRESS if parsing fails."\r
+     ;; If we have a name return that otherwise return the address.\r
+     (or p-name p-address)))\r
\r
+-(defun notmuch-pick-insert-field (field format-string msg)\r
++(defun notmuch-pick-format-field (field format-string msg)\r
++  "Format a FIELD of MSG according to FORMAT-STRING and return string"\r
+   (let* ((headers (plist-get msg :headers))\r
+-      (match (plist-get msg :match)))\r
++      (match (plist-get msg :match))\r
++      formatted-field)\r
+     (cond\r
+      ((string-equal field "date")\r
+       (let ((face (if match\r
+                     'notmuch-pick-match-date-face\r
+                   'notmuch-pick-no-match-date-face)))\r
+-      (insert (propertize (format format-string (plist-get msg :date_relative))\r
+-                          'face face))))\r
++      (setq formatted-field\r
++            (propertize (format format-string (plist-get msg :date_relative))\r
++                        'face face))))\r
\r
+      ((string-equal field "subject")\r
+       (let ((tree-status (plist-get msg :tree-status))\r
+@@ -627,13 +630,14 @@ unchanged ADDRESS if parsing fails."\r
+           (face (if match\r
+                     'notmuch-pick-match-subject-face\r
+                   'notmuch-pick-no-match-subject-face)))\r
+-      (insert (propertize (format format-string\r
+-                                  (concat\r
+-                                   (mapconcat #'identity (reverse tree-status) "")\r
+-                                   (if (string= notmuch-pick-previous-subject bare-subject)\r
+-                                       " ..."\r
+-                                     bare-subject)))\r
+-                          'face face))\r
++      (setq formatted-field\r
++            (propertize (format format-string\r
++                                (concat\r
++                                 (mapconcat #'identity (reverse tree-status) "")\r
++                                 (if (string= notmuch-pick-previous-subject bare-subject)\r
++                                     " ..."\r
++                                   bare-subject)))\r
++                        'face face))\r
+       (setq notmuch-pick-previous-subject bare-subject)))\r
\r
+      ((string-equal field "authors")\r
+@@ -644,17 +648,20 @@ unchanged ADDRESS if parsing fails."\r
+                   'notmuch-pick-no-match-author-face)))\r
+       (when (> (length author) len)\r
+         (setq author (substring author 0 len)))\r
+-      (insert (propertize (format format-string author)\r
+-                          'face face))))\r
++      (setq formatted-field\r
++            (propertize (format format-string author)\r
++                        'face face))))\r
\r
+      ((string-equal field "tags")\r
+       (let ((tags (plist-get msg :tags))\r
+           (face (if match\r
+                         'notmuch-pick-match-tag-face\r
+                       'notmuch-pick-no-match-tag-face)))\r
+-      (insert (propertize (format format-string\r
+-                                  (mapconcat #'identity tags ", "))\r
+-                          'face face)))))))\r
++      (setq formatted-field\r
++            (propertize (format format-string\r
++                                (mapconcat #'identity tags ", "))\r
++                        'face face)))))\r
++    formatted-field))\r
\r
+ (defun notmuch-pick-insert-msg (msg)\r
+   "Insert the message MSG according to notmuch-pick-result-format"\r
+@@ -662,7 +669,7 @@ unchanged ADDRESS if parsing fails."\r
+   ;; by the insert-field calls.\r
+   (let ((previous-subject notmuch-pick-previous-subject))\r
+     (dolist (spec notmuch-pick-result-format)\r
+-      (notmuch-pick-insert-field (car spec) (cdr spec) msg))\r
++      (insert (notmuch-pick-format-field (car spec) (cdr spec) msg)))\r
+     (notmuch-pick-set-message-properties msg)\r
+     (notmuch-pick-set-prop :previous-subject previous-subject)\r
+     (insert "\n")))\r
+-- \r
+1.7.9.1\r
+\r