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