[Patch v6 04/14] lib: refactor folder term update after filename removal
[notmuch-archives.git] / 50 / 1ea27f195e33ce31a7dc865237a15566dcd927
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 D756D431FCF\r
6         for <notmuch@notmuchmail.org>; Sat, 21 Jul 2012 10:37:21 -0700 (PDT)\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 sufbTuIu9s1l for <notmuch@notmuchmail.org>;\r
16         Sat, 21 Jul 2012 10:37:21 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU\r
18         [18.7.68.34])\r
19         by olra.theworths.org (Postfix) with ESMTP id E4BD3431FC2\r
20         for <notmuch@notmuchmail.org>; Sat, 21 Jul 2012 10:37:19 -0700 (PDT)\r
21 X-AuditID: 12074422-b7f1f6d00000090b-96-500ae8ceb017\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 9F.D1.02315.EC8EA005; Sat, 21 Jul 2012 13:37:18 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6LHbHif029418; \r
27         Sat, 21 Jul 2012 13:37:17 -0400\r
28 Received: from drake.dyndns.org\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6LHbFEw008011\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sat, 21 Jul 2012 13:37:16 -0400 (EDT)\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1SsdcB-0001Ze-6w; Sat, 21 Jul 2012 13:37:15 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v4 1/8] emacs: Record thread search result object in a text\r
41         property\r
42 Date: Sat, 21 Jul 2012 13:37:05 -0400\r
43 Message-Id: <1342892232-5659-2-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1342892232-5659-1-git-send-email-amdragon@mit.edu>\r
46 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
47         <1342892232-5659-1-git-send-email-amdragon@mit.edu>\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrHvuBVeAwffT0hZ79nlZrJ7LY3H9\r
50         5kxmB2aPu6e5PHbOusvu8WzVLeYA5igum5TUnMyy1CJ9uwSujJ7FD9kKVglWzNh2jbWBcSZf\r
51         FyMnh4SAicTfm83MELaYxIV769m6GLk4hAT2MUo83DifCcLZwCjxauNJZgjnEZNEf/t3Fghn\r
52         LqPEj6uLmUD62QQ0JLbtX84IYosISEvsvDubFcRmFkiT+N7+FiwuLBAicXrrLDYQm0VAVaJj\r
53         wjqw3bwC9hIHni9jh7hDXuLp/T6wGk4BB4lHZw+wgNhCAmUSizsOM05g5F/AyLCKUTYlt0o3\r
54         NzEzpzg1Wbc4OTEvL7VI11QvN7NELzWldBMjKLTYXZR2MP48qHSIUYCDUYmH12MWZ4AQa2JZ\r
55         cWXuIUZJDiYlUd6++1wBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4N50GyvGmJFZWpRblw6Sk\r
56         OViUxHmvpdz0FxJITyxJzU5NLUgtgsnKcHAoSfC6A2NISLAoNT21Ii0zpwQhzcTBCTKcB2i4\r
57         GEgNb3FBYm5xZjpE/hSjopQ4rx1IQgAkkVGaB9cLi/1XjOJArwjzfnsOVMUDTBtw3a+ABjMB\r
58         DZbOAhtckoiQkmpgrPscs+7f2nuHWH5uWLFxRWbBQfOSX3PO1VUv4cpaanzxyvpNv8tZ+n9f\r
59         LI+2qOtYHz3zjLWl3pJ/MYX/9zC4WxZlF1RmKT/6rCQ86+6Tf6tN0+el1dtsiTvf9zLHtqvg\r
60         zfXgvhz3ub/8811/rpBzYIo3iD208P6enw2sM9eqF7cLpae4nFrmrsRSnJFoqMVcVJwIAPu6\r
61         8YvYAgAA\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Sat, 21 Jul 2012 17:37:22 -0000\r
75 \r
76 This also provides utility functions for working with this text\r
77 property that get its value, find its start, and find its end.\r
78 ---\r
79  emacs/notmuch.el |   27 +++++++++++++++++++++++++++\r
80  1 file changed, 27 insertions(+)\r
81 \r
82 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
83 index fabb7c0..ef18927 100644\r
84 --- a/emacs/notmuch.el\r
85 +++ b/emacs/notmuch.el\r
86 @@ -401,6 +401,32 @@ Complete list of currently available key bindings:\r
87         mode-name "notmuch-search")\r
88    (setq buffer-read-only t))\r
89  \r
90 +(defun notmuch-search-get-result (&optional pos)\r
91 +  "Return the result object for the thread at POS (or point).\r
92 +\r
93 +If there is no thread at POS (or point), returns nil."\r
94 +  (get-text-property (or pos (point)) 'notmuch-search-result))\r
95 +\r
96 +(defun notmuch-search-result-beginning (&optional pos)\r
97 +  "Return the point at the beginning of the thread at POS (or point).\r
98 +\r
99 +If there is no thread at POS (or point), returns nil."\r
100 +  (when (notmuch-search-get-result pos)\r
101 +    ;; We pass 1+point because previous-single-property-change starts\r
102 +    ;; searching one before the position we give it.\r
103 +    (previous-single-property-change (1+ (or pos (point)))\r
104 +                                    'notmuch-search-result nil (point-min))))\r
105 +\r
106 +(defun notmuch-search-result-end (&optional pos)\r
107 +  "Return the point at the end of the thread at POS (or point).\r
108 +\r
109 +The returned point will be just after the newline character that\r
110 +ends the result line.  If there is no thread at POS (or point),\r
111 +returns nil"\r
112 +  (when (notmuch-search-get-result pos)\r
113 +    (next-single-property-change (or pos (point)) 'notmuch-search-result\r
114 +                                nil (point-max))))\r
115 +\r
116  (defun notmuch-search-properties-in-region (property beg end)\r
117    (save-excursion\r
118      (let ((output nil)\r
119 @@ -736,6 +762,7 @@ non-authors is found, assume that all of the authors match."\r
120           (notmuch-search-insert-field (car spec) (cdr spec) result))\r
121         (insert "\n")\r
122         (notmuch-search-color-line beg (point) (plist-get result :tags))\r
123 +       (put-text-property beg (point) 'notmuch-search-result result)\r
124         (put-text-property beg (point) 'notmuch-search-thread-id\r
125                            (concat "thread:" (plist-get result :thread)))\r
126         (put-text-property beg (point) 'notmuch-search-authors\r
127 -- \r
128 1.7.10\r
129 \r