[PATCH 3/4] contrib: pick: allow recursive message field formats
authorMark Walters <markwalters1009@gmail.com>
Mon, 2 Sep 2013 03:28:07 +0000 (04:28 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:49 +0000 (09:56 -0800)
54/47ce5fc466314d68da59b804034be271f6ef06 [new file with mode: 0644]

diff --git a/54/47ce5fc466314d68da59b804034be271f6ef06 b/54/47ce5fc466314d68da59b804034be271f6ef06
new file mode 100644 (file)
index 0000000..f471760
--- /dev/null
@@ -0,0 +1,117 @@
+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 2AAAC431FC3\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Sep 2013 20:28:28 -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 PS3arKU3VstE for <notmuch@notmuchmail.org>;\r
+       Sun,  1 Sep 2013 20:28:23 -0700 (PDT)\r
+Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com\r
+ [74.125.82.49])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 614D9431FCB   for <notmuch@notmuchmail.org>; Sun,  1 Sep 2013 20:28:19 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f49.google.com with SMTP id l18so487667wgh.4\r
+       for <notmuch@notmuchmail.org>; Sun, 01 Sep 2013 20:28:18 -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=5dkBYhkrwOnwBRl9iwX3cmDChllaonwaR/LJUd7GoPA=;\r
+       b=FAevX8bPCP40zCbWkg6qqGLH3J4a3JzgwfVBuTzpDRvpMbb+amQJ9mYbIWpt8lJX3J\r
+       kLnfPNA6RLkrVdPyq+kQhDnzdLRAN6NXC8g04hS+/8eqecfK2U5Kf+VLlT35Z3VzRaCH\r
+       yK8njKhvNCJHRLTEYFL2qEtqb6grH1L0vJKN4dEkdO1ZGip5U6OFt7tO+6qHBAHP2FVl\r
+       InlikN1cFl3qRVZCEBy4QgjPA1qOWmXeE1/pucwGZFOW0i7RM6VTxNX9ygaBx6LAlCr9\r
+       TDLMAbnpI6bsv+Mij0+dMP3nufQb15FB7eO8NKMQxQRDBtqRNGeJQg6fgu0U3XwJ2/x8\r
+       6dHA==\r
+X-Received: by 10.180.100.202 with SMTP id fa10mr4985867wib.8.1378092498263;\r
+       Sun, 01 Sep 2013 20:28:18 -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 li9sm14430706wic.4.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 01 Sep 2013 20:28:17 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/4] contrib: pick: allow recursive message field formats\r
+Date: Mon,  2 Sep 2013 04:28:07 +0100\r
+Message-Id: <1378092488-32050-4-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:28 -0000\r
+\r
+Previously, the message format was fixed: each part had to be a\r
+certain width and either left or right justified. This allows the user\r
+to specify that two parts can be variable width but that combined they\r
+should be some fixed width. We do this by allowing the user to set as\r
+a "field" a list of the normal result-format form which is formatted\r
+and then itself inserted according to the format string specified.\r
+\r
+This means all existing formats work but allows more general things\r
+too. This will be used in the next patch to allow the user to specify\r
+where the tree box graphics are drawn but allow, e.g., the total width\r
+of the tree box graphics and subject to be specified.\r
+---\r
+ contrib/notmuch-pick/notmuch-pick.el |   14 ++++++++++++--\r
+ 1 files changed, 12 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index f01be94..5dfcef3 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -616,6 +616,10 @@ unchanged ADDRESS if parsing fails."\r
+       (match (plist-get msg :match))\r
+       formatted-field)\r
+     (cond\r
++     ((listp field)\r
++      (setq formatted-field\r
++          (format format-string (notmuch-pick-format-field-list field msg))))\r
++\r
+      ((string-equal field "date")\r
+       (let ((face (if match\r
+                     'notmuch-pick-match-date-face\r
+@@ -663,13 +667,19 @@ unchanged ADDRESS if parsing fails."\r
+                         'face face)))))\r
+     formatted-field))\r
\r
++(defun notmuch-pick-format-field-list (field-list msg)\r
++  "Format fields of MSG according to FIELD-LIST and return string"\r
++  (let (result-string)\r
++    (dolist (spec field-list result-string)\r
++      (let ((field-string (notmuch-pick-format-field (car spec) (cdr spec) msg)))\r
++      (setq result-string (concat result-string field-string))))))\r
++\r
+ (defun notmuch-pick-insert-msg (msg)\r
+   "Insert the message MSG according to notmuch-pick-result-format"\r
+   ;; We need to save the previous subject as it will get overwritten\r
+   ;; by the insert-field calls.\r
+   (let ((previous-subject notmuch-pick-previous-subject))\r
+-    (dolist (spec notmuch-pick-result-format)\r
+-      (insert (notmuch-pick-format-field (car spec) (cdr spec) msg)))\r
++    (insert (notmuch-pick-format-field-list notmuch-pick-result-format 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