[PATCH v4 6/7] On deletion, replace with ghost when other active messages in thread
[notmuch-archives.git] / 5b / 5aff0e791e944e376d390605ae4ab8faf158f1
1 Return-Path: <amdragon@mit.edu>\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 716A9431FBC\r
6         for <notmuch@notmuchmail.org>; Mon,  4 Feb 2013 13:37:13 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id o7GFAuKUBv40 for <notmuch@notmuchmail.org>;\r
16         Mon,  4 Feb 2013 13:37:11 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
18         [18.7.68.35])\r
19         by olra.theworths.org (Postfix) with ESMTP id 1A759431FBD\r
20         for <notmuch@notmuchmail.org>; Mon,  4 Feb 2013 13:37:11 -0800 (PST)\r
21 X-AuditID: 12074423-b7f5b6d000007e03-f8-51102a0689c1\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 7F.F9.32259.60A20115; Mon,  4 Feb 2013 16:37:10 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r14Lb8kC004394; \r
27         Mon, 4 Feb 2013 16:37:08 -0500\r
28 Received: from drake.dyndns.org (26-4-172.dynamic.csail.mit.edu [18.26.4.172])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r14Lb69e016770\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Mon, 4 Feb 2013 16:37:07 -0500\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1U2Tis-0001mu-55; Mon, 04 Feb 2013 16:37:06 -0500\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 1/2] emacs: Handle all face forms when combining faces\r
40 Date: Mon,  4 Feb 2013 16:37:01 -0500\r
41 Message-Id: <1360013822-6562-2-git-send-email-amdragon@mit.edu>\r
42 X-Mailer: git-send-email 1.7.10.4\r
43 In-Reply-To: <1360013822-6562-1-git-send-email-amdragon@mit.edu>\r
44 References: <1360013822-6562-1-git-send-email-amdragon@mit.edu>\r
45 X-Brightmail-Tracker:\r
46  H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixCmqrcumJRBocHStgMWuu1uZLK7fnMns\r
47         wOSxc9Zddo9nq24xBzBFcdmkpOZklqUW6dslcGW0HLnBXrBIrOLJwRa2BsZHgl2MnBwSAiYS\r
48         jxfsYIewxSQu3FvP1sXIxSEksI9R4l/3UkaQhJDABkaJF29rIBKHmSQaJp1ggUjMZZRom6IL\r
49         YrMJaEhs278crEFEQFpi593ZrCA2s4C9xMZZr8E2CAu4Sbzo+QfWyyKgKjF9WzdQDQcHL1DN\r
50         hn8qEEcoSnQ/m8AGEuYUcJC4u4oHYpO9xLuL8xknMPIvYGRYxSibklulm5uYmVOcmqxbnJyY\r
51         l5dapGuml5tZopeaUrqJERRE7C7KOxj/HFQ6xCjAwajEwxt4jT9QiDWxrLgy9xCjJAeTkihv\r
52         kZJAoBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3o83gMp5UxIrq1KL8mFS0hwsSuK811Ju+gsJ\r
53         pCeWpGanphakFsFkZTg4lCR4p2sADRUsSk1PrUjLzClBSDNxcIIM5wEabg9Sw1tckJhbnJkO\r
54         kT/FqCglzpsJkhAASWSU5sH1wqL8FaM40CvCvE0gVTzABAHX/QpoMBPQYKUckKuLSxIRUlIN\r
55         jObR+rN/+urv4vxirXh6R+J39qX7rjnVSWi9/5ZuJmOz2LcuS/Ql94swjrj/drseLpJhmc0g\r
56         HDM337jn/btCzpMbPHasmegfvLKqrsS+Xb2icYnpHD7htbwnWBXktd9r7ZPVyXkd6K8/97j8\r
57         m8sTV94TaHmlXR2+TND3MLdvd5Nu4OSP3eIaSizFGYmGWsxFxYkARvfI3s0CAAA=\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 04 Feb 2013 21:37:13 -0000\r
71 \r
72 Previously, notmuch-combine-face-text-property assumed that any\r
73 existing face properties of the modified text were already in face\r
74 list form.  This was true as long as it was the only function\r
75 manipulating faces (since it always produced a list form face), but if\r
76 anything else has manipulated the face, it was more likely to be\r
77 either a face name or a face plist.  It also didn't correctly handle\r
78 face lists as arguments, even though the doc string claimed it did.\r
79 \r
80 This patch fixes notmuch-combine-face-text-property to handle all face\r
81 forms correctly by canonicalizing both the argument face and the\r
82 existing faces into list form.  This also means we can set the face to\r
83 a simpler non-list form if there's no existing face.\r
84 ---\r
85  emacs/notmuch-lib.el |   27 +++++++++++++++++++++++----\r
86  1 file changed, 23 insertions(+), 4 deletions(-)\r
87 \r
88 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
89 index d78bcf8..ad2816d 100644\r
90 --- a/emacs/notmuch-lib.el\r
91 +++ b/emacs/notmuch-lib.el\r
92 @@ -301,6 +301,16 @@ current buffer, if possible."\r
93    (loop for (key value . rest) on plist by #'cddr\r
94         collect (cons (intern (substring (symbol-name key) 1)) value)))\r
95  \r
96 +(defun notmuch-face-ensure-list-form (face)\r
97 +  "Return FACE in face list form.\r
98 +\r
99 +If FACE is already a face list, it will be returned as-is.  If\r
100 +FACE is a face name or face plist, it will be returned as a\r
101 +single element face list."\r
102 +  (if (and (listp face) (not (keywordp (car face))))\r
103 +      face\r
104 +    (list face)))\r
105 +\r
106  (defun notmuch-combine-face-text-property (start end face)\r
107    "Combine FACE into the 'face text property between START and END.\r
108  \r
109 @@ -309,11 +319,20 @@ and END.  Attributes specified by FACE take precedence over\r
110  existing attributes.  FACE must be a face name (a symbol or\r
111  string), a property list of face attributes, or a list of these."\r
112  \r
113 -  (let ((pos start))\r
114 +  ;; A face property can have three forms: a face name (a string or\r
115 +  ;; symbol), a property list, or a list of these two forms.  In the\r
116 +  ;; list case, the faces will be combined, with the earlier faces\r
117 +  ;; taking precedent.  Here we canonicalize everything to list form\r
118 +  ;; to make it easy to combine.\r
119 +  (let ((pos start)\r
120 +       (face-list (notmuch-face-ensure-list-form face)))\r
121      (while (< pos end)\r
122 -      (let ((cur (get-text-property pos 'face))\r
123 -           (next (next-single-property-change pos 'face nil end)))\r
124 -       (put-text-property pos next 'face (cons face cur))\r
125 +      (let* ((cur (get-text-property pos 'face))\r
126 +            (cur-list (notmuch-face-ensure-list-form cur))\r
127 +            (new (cond ((null cur-list) face)\r
128 +                       (t (append face-list cur-list))))\r
129 +            (next (next-single-property-change pos 'face nil end)))\r
130 +       (put-text-property pos next 'face new)\r
131         (setq pos next)))))\r
132  \r
133  (defun notmuch-logged-error (msg &optional extra)\r
134 -- \r
135 1.7.10.4\r
136 \r