1 Return-Path: <markwalters1009@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 9460B431FC9
\r
6 for <notmuch@notmuchmail.org>; Sat, 22 Mar 2014 04:51:30 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id p6z+ARD0eogM for <notmuch@notmuchmail.org>;
\r
18 Sat, 22 Mar 2014 04:51:25 -0700 (PDT)
\r
19 Received: from mail-we0-f175.google.com (mail-we0-f175.google.com
\r
20 [74.125.82.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id DC31C431FC2
\r
23 for <notmuch@notmuchmail.org>; Sat, 22 Mar 2014 04:51:24 -0700 (PDT)
\r
24 Received: by mail-we0-f175.google.com with SMTP id q58so2282275wes.34
\r
25 for <notmuch@notmuchmail.org>; Sat, 22 Mar 2014 04:51:23 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:in-reply-to:references;
\r
28 bh=gSliWsi5Qv4/R9XYHWk98eS0946wwZRKlUGWJlq/dtU=;
\r
29 b=O+TnEfOkdGr9mP885PJz439OCvTU2E6FLz7PrvIt5yrmhi7agwvdGToz9EP4D+PL0K
\r
30 v2eEN7BQ3oKdoiUE+mHF98WQl+DT7+3qamTq0mTfVTcM1foUMKLCC5IW0y9U0GhAbtTo
\r
31 BooR6k3dtxW7s5R2uAQinGh8AAP5vMZ/OJNqhAUFkFS272CdNBzA/2CEqj1D/U04IrHO
\r
32 cdFw7FRAugrZQZuMohlGJYQE4vhbWPDon2Q2FkROfORyWdxsBpsiTlqvwXYfcHZuy8Wx
\r
33 F0DOYPnXJJb90WseOCxciIcmiPTGmIFlCx8YGXjFAMxbFikUDDP+4To+vM7z/JnFXpxt
\r
35 X-Received: by 10.180.219.44 with SMTP id pl12mr3238423wic.12.1395489083803;
\r
36 Sat, 22 Mar 2014 04:51:23 -0700 (PDT)
\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])
\r
38 by mx.google.com with ESMTPSA id hp5sm16887304wjb.0.2014.03.22.04.51.22
\r
39 for <multiple recipients>
\r
40 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
41 Sat, 22 Mar 2014 04:51:23 -0700 (PDT)
\r
42 From: Mark Walters <markwalters1009@gmail.com>
\r
43 To: notmuch@notmuchmail.org,
\r
45 Subject: [Patch v4 1/8] emacs: Combine notmuch-combine-face-text-property{,
\r
47 Date: Sat, 22 Mar 2014 11:51:05 +0000
\r
48 Message-Id: <1395489072-19001-2-git-send-email-markwalters1009@gmail.com>
\r
49 X-Mailer: git-send-email 1.7.10.4
\r
50 In-Reply-To: <1395489072-19001-1-git-send-email-markwalters1009@gmail.com>
\r
51 References: <1395489072-19001-1-git-send-email-markwalters1009@gmail.com>
\r
52 X-BeenThere: notmuch@notmuchmail.org
\r
53 X-Mailman-Version: 2.1.13
\r
55 List-Id: "Use and development of the notmuch mail system."
\r
56 <notmuch.notmuchmail.org>
\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
60 List-Post: <mailto:notmuch@notmuchmail.org>
\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
64 X-List-Received-Date: Sat, 22 Mar 2014 11:51:30 -0000
\r
66 From: Austin Clements <amdragon@MIT.EDU>
\r
68 This combines our two face combining functions into one, easy to use
\r
69 function with a much shorter name: `notmuch-apply-face'. This
\r
70 function takes the full set of arguments that
\r
71 `notmuch-combine-face-text-property' took, but takes them in a more
\r
72 convenient order and provides smarter defaults that make the function
\r
73 easy to use on both strings and buffers.
\r
75 emacs/notmuch-lib.el | 35 ++++++++++++++++++-----------------
\r
76 emacs/notmuch-tag.el | 2 +-
\r
77 emacs/notmuch-tree.el | 2 +-
\r
78 emacs/notmuch.el | 2 +-
\r
79 4 files changed, 21 insertions(+), 20 deletions(-)
\r
81 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
82 index 2fefdad..fa7646f 100644
\r
83 --- a/emacs/notmuch-lib.el
\r
84 +++ b/emacs/notmuch-lib.el
\r
85 @@ -578,23 +578,32 @@ (defun notmuch-face-ensure-list-form (face)
\r
89 -(defun notmuch-combine-face-text-property (start end face &optional below object)
\r
90 - "Combine FACE into the 'face text property between START and END.
\r
91 +(defun notmuch-apply-face (object face &optional below start end)
\r
92 + "Combine FACE into the 'face text property of OBJECT between START and END.
\r
94 This function combines FACE with any existing faces between START
\r
95 -and END in OBJECT (which defaults to the current buffer).
\r
96 -Attributes specified by FACE take precedence over existing
\r
97 -attributes unless BELOW is non-nil. FACE must be a face name (a
\r
98 -symbol or string), a property list of face attributes, or a list
\r
99 -of these. For convenience when applied to strings, this returns
\r
101 +and END in OBJECT. Attributes specified by FACE take precedence
\r
102 +over existing attributes unless BELOW is non-nil.
\r
104 +OBJECT may be a string, a buffer, or nil (which means the current
\r
105 +buffer). If object is a string, START and END are 0-based;
\r
106 +otherwise they are buffer positions (integers or markers). FACE
\r
107 +must be a face name (a symbol or string), a property list of face
\r
108 +attributes, or a list of these. If START and/or END are omitted,
\r
109 +they default to the beginning/end of OBJECT. For convenience
\r
110 +when applied to strings, this returns OBJECT."
\r
112 ;; A face property can have three forms: a face name (a string or
\r
113 ;; symbol), a property list, or a list of these two forms. In the
\r
114 ;; list case, the faces will be combined, with the earlier faces
\r
115 ;; taking precedent. Here we canonicalize everything to list form
\r
116 ;; to make it easy to combine.
\r
117 - (let ((pos start)
\r
118 + (let ((pos (cond (start start)
\r
119 + ((stringp object) 0)
\r
121 + (end (cond (end end)
\r
122 + ((stringp object) (length object))
\r
123 + (t (1+ (buffer-size object)))))
\r
124 (face-list (notmuch-face-ensure-list-form face)))
\r
126 (let* ((cur (get-text-property pos 'face object))
\r
127 @@ -607,14 +616,6 @@ (defun notmuch-combine-face-text-property (start end face &optional below object
\r
131 -(defun notmuch-combine-face-text-property-string (string face &optional below)
\r
132 - (notmuch-combine-face-text-property
\r
139 (defun notmuch-map-text-property (start end prop func &optional object)
\r
140 "Transform text property PROP using FUNC.
\r
142 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
143 index 908e7ad..41b1687 100644
\r
144 --- a/emacs/notmuch-tag.el
\r
145 +++ b/emacs/notmuch-tag.el
\r
146 @@ -151,7 +151,7 @@ (defun notmuch-tag-format-tag (tag)
\r
147 (defun notmuch-tag-format-tags (tags &optional face)
\r
148 "Return a string representing formatted TAGS."
\r
149 (let ((face (or face 'notmuch-tag-face)))
\r
150 - (notmuch-combine-face-text-property-string
\r
151 + (notmuch-apply-face
\r
152 (mapconcat #'identity
\r
153 ;; nil indicated that the tag was deliberately hidden
\r
154 (delq nil (mapcar #'notmuch-tag-format-tag tags))
\r
155 diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
\r
156 index 4f2ac02..e3aa2cd 100644
\r
157 --- a/emacs/notmuch-tree.el
\r
158 +++ b/emacs/notmuch-tree.el
\r
159 @@ -715,7 +715,7 @@ (defun notmuch-tree-format-field-list (field-list msg)
\r
160 (dolist (spec field-list result-string)
\r
161 (let ((field-string (notmuch-tree-format-field (car spec) (cdr spec) msg)))
\r
162 (setq result-string (concat result-string field-string))))
\r
163 - (notmuch-combine-face-text-property-string result-string face t)))
\r
164 + (notmuch-apply-face result-string face t)))
\r
166 (defun notmuch-tree-insert-msg (msg)
\r
167 "Insert the message MSG according to notmuch-tree-result-format"
\r
168 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
169 index 0471750..5cddaac 100644
\r
170 --- a/emacs/notmuch.el
\r
171 +++ b/emacs/notmuch.el
\r
172 @@ -649,7 +649,7 @@ (defun notmuch-search-color-line (start end line-tag-list)
\r
173 (let ((tag (car elem))
\r
174 (attributes (cdr elem)))
\r
175 (when (member tag line-tag-list)
\r
176 - (notmuch-combine-face-text-property start end attributes))))
\r
177 + (notmuch-apply-face nil attributes nil start end))))
\r
178 ;; Reverse the list so earlier entries take precedence
\r
179 (reverse notmuch-search-line-faces)))
\r