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