--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 BF31D431FBF\r
+ for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 07:47:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 ML7WzdCWlT1E for <notmuch@notmuchmail.org>;\r
+ Tue, 11 Mar 2014 07:47:07 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+ [18.9.25.14])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id B2544431FBD\r
+ for <notmuch@notmuchmail.org>; Tue, 11 Mar 2014 07:47:06 -0700 (PDT)\r
+X-AuditID: 1209190e-f79ee6d000000c40-67-531f21e8383f\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id F6.ED.03136.8E12F135; Tue, 11 Mar 2014 10:47:04 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s2BEl2XA001010; \r
+ Tue, 11 Mar 2014 10:47:02 -0400\r
+Received: from drake.dyndns.org\r
+ (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [216.15.114.40]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s2BEkxON024934\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Tue, 11 Mar 2014 10:47:01 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WNNxL-0005t1-ML; Tue, 11 Mar 2014 10:46:59 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Combine notmuch-combine-face-text-property{,-string}\r
+Date: Tue, 11 Mar 2014 10:46:55 -0400\r
+Message-Id: <1394549215-22508-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+In-Reply-To: <8761nl31gl.fsf@awakening.csail.mit.edu>\r
+References: <8761nl31gl.fsf@awakening.csail.mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsUixCmqrftCUT7Y4PpBE4vVc3ksrt+cyezA\r
+ 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZew8tZalYJdmxd/JO5kbGLcodjFyckgImEhs\r
+ X7+KCcIWk7hwbz1bFyMXh5DAbCaJ7w87oJyNjBJrd69kBakSErjDJNF7ghMiMZdR4sSRn8wg\r
+ CTYBDYlt+5czgtgiAtISO+/OBmtgFnCU+Lx/EdAkDg5hAR+JWa18IGEWAVWJE68bwDbzCjhI\r
+ /PzUCXWFksTCU9vAWjkFTCUOvf/NDrHXRGLC36tsExj5FzAyrGKUTcmt0s1NzMwpTk3WLU5O\r
+ zMtLLdI11svNLNFLTSndxAgOI0m+HYxfDyodYhTgYFTi4Q3wlQsWYk0sK67MPcQoycGkJMr7\r
+ R0I+WIgvKT+lMiOxOCO+qDQntfgQowQHs5IIb7I4UI43JbGyKrUoHyYlzcGiJM7bd1YiWEgg\r
+ PbEkNTs1tSC1CCYrw8GhJME7VwGoUbAoNT21Ii0zpwQhzcTBCTKcB2g4WA1vcUFibnFmOkT+\r
+ FKOilDjvDnmghABIIqM0D64XFuevGMWBXhHmTQdp5wGmCLjuV0CDmYAGf9wqBzK4JBEhJdXA\r
+ ODXOb3qa/cwPuyOWBr9XPb/jwlTBuGXvpDN8Fs6Qivwcb3GYpbRhTQSjh6FQ7IG/Z08re8Xs\r
+ 5DyyL8pR+Ejpac+VbrahXs+ebq2ILJITW5CwIyRqksPTu5uuxXGIdezZ/9Hk1f6kFZcTu5/7\r
+ /5S+ci+Y0WnWX58OYx2Hrv9XZ9svD1zcc+npUSWW4oxEQy3mouJEADdtqTHOAgAA\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: Tue, 11 Mar 2014 14:47:12 -0000\r
+\r
+This combines our two face combining functions into one, easy to use\r
+function with a much shorter name: `notmuch-apply-face'. This\r
+function takes the full set of arguments that\r
+`notmuch-combine-face-text-property' took, but takes them in a more\r
+convenient order and provides smarter defaults that make the function\r
+easy to use on both strings and buffers.\r
+---\r
+\r
+Here's the combined, cleaned up face combiner interface I mentioned on\r
+IRC. I think the new `notmuch-apply-face' function introduced here\r
+would be ideal for use in notmuch-tag-formats to fix the problem with\r
+propertize overriding the entire face.\r
+\r
+ emacs/notmuch-lib.el | 35 ++++++++++++++++++-----------------\r
+ emacs/notmuch-tag.el | 4 ++--\r
+ emacs/notmuch-tree.el | 2 +-\r
+ emacs/notmuch.el | 2 +-\r
+ 4 files changed, 22 insertions(+), 21 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 2fefdad..05be5b8 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -578,23 +578,32 @@ single element face list."\r
+ face\r
+ (list face)))\r
+ \r
+-(defun notmuch-combine-face-text-property (start end face &optional below object)\r
+- "Combine FACE into the 'face text property between START and END.\r
++(defun notmuch-apply-face (object face &optional start end below)\r
++ "Combine FACE into the 'face text property of OBJECT between START and END.\r
+ \r
+ This function combines FACE with any existing faces between START\r
+-and END in OBJECT (which defaults to the current buffer).\r
+-Attributes specified by FACE take precedence over existing\r
+-attributes unless BELOW is non-nil. FACE must be a face name (a\r
+-symbol or string), a property list of face attributes, or a list\r
+-of these. For convenience when applied to strings, this returns\r
+-OBJECT."\r
++and END in OBJECT. Attributes specified by FACE take precedence\r
++over existing attributes unless BELOW is non-nil.\r
++\r
++OBJECT may be a string, a buffer, or nil (which means the current\r
++buffer). If object is a string, START and END are 0-based;\r
++otherwise they are buffer positions (integers or markers). FACE\r
++must be a face name (a symbol or string), a property list of face\r
++attributes, or a list of these. If START and/or END are omitted,\r
++they default to the beginning/end of OBJECT. For convenience\r
++when applied to strings, this returns OBJECT."\r
+ \r
+ ;; A face property can have three forms: a face name (a string or\r
+ ;; symbol), a property list, or a list of these two forms. In the\r
+ ;; list case, the faces will be combined, with the earlier faces\r
+ ;; taking precedent. Here we canonicalize everything to list form\r
+ ;; to make it easy to combine.\r
+- (let ((pos start)\r
++ (let ((pos (cond (start start)\r
++ ((stringp object) 0)\r
++ (t 1)))\r
++ (end (cond (end end)\r
++ ((stringp object) (length object))\r
++ (t (1+ (buffer-size object)))))\r
+ (face-list (notmuch-face-ensure-list-form face)))\r
+ (while (< pos end)\r
+ (let* ((cur (get-text-property pos 'face object))\r
+@@ -607,14 +616,6 @@ OBJECT."\r
+ (setq pos next))))\r
+ object)\r
+ \r
+-(defun notmuch-combine-face-text-property-string (string face &optional below)\r
+- (notmuch-combine-face-text-property\r
+- 0\r
+- (length string)\r
+- face\r
+- below\r
+- string))\r
+-\r
+ (defun notmuch-map-text-property (start end prop func &optional object)\r
+ "Transform text property PROP using FUNC.\r
+ \r
+diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
+index 908e7ad..d7deaf0 100644\r
+--- a/emacs/notmuch-tag.el\r
++++ b/emacs/notmuch-tag.el\r
+@@ -151,13 +151,13 @@ This can be used with `notmuch-tag-format-image-data'."\r
+ (defun notmuch-tag-format-tags (tags &optional face)\r
+ "Return a string representing formatted TAGS."\r
+ (let ((face (or face 'notmuch-tag-face)))\r
+- (notmuch-combine-face-text-property-string\r
++ (notmuch-apply-face\r
+ (mapconcat #'identity\r
+ ;; nil indicated that the tag was deliberately hidden\r
+ (delq nil (mapcar #'notmuch-tag-format-tag tags))\r
+ " ")\r
+ face\r
+- t)))\r
++ nil nil t)))\r
+ \r
+ (defcustom notmuch-before-tag-hook nil\r
+ "Hooks that are run before tags of a message are modified.\r
+diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el\r
+index 4f2ac02..bc4c0b0 100644\r
+--- a/emacs/notmuch-tree.el\r
++++ b/emacs/notmuch-tree.el\r
+@@ -715,7 +715,7 @@ unchanged ADDRESS if parsing fails."\r
+ (dolist (spec field-list result-string)\r
+ (let ((field-string (notmuch-tree-format-field (car spec) (cdr spec) msg)))\r
+ (setq result-string (concat result-string field-string))))\r
+- (notmuch-combine-face-text-property-string result-string face t)))\r
++ (notmuch-apply-face result-string face nil nil t)))\r
+ \r
+ (defun notmuch-tree-insert-msg (msg)\r
+ "Insert the message MSG according to notmuch-tree-result-format"\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 0471750..222d8b1 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -649,7 +649,7 @@ foreground and blue background."\r
+ (let ((tag (car elem))\r
+ (attributes (cdr elem)))\r
+ (when (member tag line-tag-list)\r
+- (notmuch-combine-face-text-property start end attributes))))\r
++ (notmuch-apply-face nil attributes start end))))\r
+ ;; Reverse the list so earlier entries take precedence\r
+ (reverse notmuch-search-line-faces)))\r
+ \r
+-- \r
+1.8.4.rc3\r
+\r