notmuch-search-toggle-order and notmuch-tree
[notmuch-archives.git] / d6 / 3c6bc1cc868345fce8a066c87f4452ef394ae3
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 DB879431FAE\r
6         for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 13:52:51 -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 zu0nHU2Z6MkJ for <notmuch@notmuchmail.org>;\r
16         Thu,  5 Jul 2012 13:52:50 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
18         [18.7.68.36])\r
19         by olra.theworths.org (Postfix) with ESMTP id 018E1431FCB\r
20         for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 13:52:43 -0700 (PDT)\r
21 X-AuditID: 12074424-b7f2a6d0000008bf-2f-4ff5fe9bf12e\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id C6.5B.02239.B9EF5FF4; Thu,  5 Jul 2012 16:52:43 -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 q65KqgH8024132; \r
27         Thu, 5 Jul 2012 16:52:42 -0400\r
28 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q65KqbS5027237\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Thu, 5 Jul 2012 16:52:39 -0400 (EDT)\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1Smt2T-0004Xc-Iw; Thu, 05 Jul 2012 16:52:37 -0400\r
37 From: Austin Clements <amdragon@MIT.EDU>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v2 4/9] emacs: Move search-target logic to\r
40         `notmuch-search-show-result'\r
41 Date: Thu,  5 Jul 2012 16:52:22 -0400\r
42 Message-Id: <1341521547-15502-5-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.10\r
44 In-Reply-To: <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
45 References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
46         <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrDv731d/g6vLRS1Wz+WxuH5zJrPF\r
49         m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBl3J2zi7Fgv1zF9bZ2lgbG\r
50         bRJdjJwcEgImEmffb2CFsMUkLtxbz9bFyMUhJLCPUaLpwgomCGc9o8T5/42MIFVCAieZJFbf\r
51         DYdIzGWUWLpzOhtIgk1AQ2Lb/uVgRSIC0hI7784GG8ssECexZcp/sLiwQLjEsv0/wOpZBFQl\r
52         rl56A2RzcPAKOEh86I2FuEJe4un9PrASTgFHiQsTF0PtLZf4s+QfywRG/gWMDKsYZVNyq3Rz\r
53         EzNzilOTdYuTE/PyUot0zfVyM0v0UlNKNzGCQovdRWUHY/MhpUOMAhyMSjy8hrlf/IVYE8uK\r
54         K3MPMUpyMCmJ8jb+/uovxJeUn1KZkVicEV9UmpNafIhRgoNZSYS3NwMox5uSWFmVWpQPk5Lm\r
55         YFES572ectNfSCA9sSQ1OzW1ILUIJivDwaEkwfv0L1CjYFFqempFWmZOCUKaiYMTZDgP0PAX\r
56         IDW8xQWJucWZ6RD5U4yKUkCjQRICIImM0jy4Xljsv2IUB3pFmPcTSBUPMG3Adb8CGswENDhv\r
57         8SeQwSWJCCmpBkaNnufl5btMb66I6PR4vWLGjQuPHwo5p4XtrLox4+WjW2mHTHOn/UvjY3Wb\r
58         81XiSETYk/gtTsZ8NzmO5OQIOBolCQaFCnfwXtZWDpjyetkH8wUf7qnMnsbyJNO5usv2RZZ+\r
59         9+n7H2XWGu8/uVQ7qqXKMei1nOQtucuZxSyTNn+Nel+4cu78liIlluKMREMt5qLiRACyognh\r
60         2AIAAA==\r
61 Cc: tomi.ollila@iki.fi\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: Thu, 05 Jul 2012 20:52:52 -0000\r
75 \r
76 This is a simpler place to do this, since we can avoid any point\r
77 motion and hence any save-excursions in\r
78 `notmuch-search-process-filter', which in turn lets us put all of the\r
79 search-target logic outside of any save-excursions.\r
80 \r
81 `notmuch-search-show-{result,error}' are now responsible for their own\r
82 point motion.\r
83 \r
84 `notmuch-search-process-filter' could use some reindentation after\r
85 this, but we're about to rewrite it entirely, so we won't bother.\r
86 ---\r
87  emacs/notmuch.el |   41 ++++++++++++++++++++---------------------\r
88  1 file changed, 20 insertions(+), 21 deletions(-)\r
89 \r
90 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
91 index f952fa8..5bf01ca 100644\r
92 --- a/emacs/notmuch.el\r
93 +++ b/emacs/notmuch.el\r
94 @@ -730,29 +730,34 @@ non-authors is found, assume that all of the authors match."\r
95  (defun notmuch-search-show-result (thread-id date count authors subject tags)\r
96    ;; Ignore excluded matches\r
97    (unless (eq (aref count 1) ?0)\r
98 -    (let ((beg (point))\r
99 +    (let ((beg (point-max))\r
100           (tags-str (mapconcat 'identity tags " ")))\r
101 -      (dolist (spec notmuch-search-result-format)\r
102 -       (notmuch-search-insert-field (car spec) (cdr spec)\r
103 -                                    date count authors subject tags-str))\r
104 -      (insert "\n")\r
105 -      (notmuch-search-color-line beg (point) tags)\r
106 -      (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
107 -      (put-text-property beg (point) 'notmuch-search-authors authors)\r
108 -      (put-text-property beg (point) 'notmuch-search-subject subject))))\r
109 +      (save-excursion\r
110 +       (goto-char beg)\r
111 +       (dolist (spec notmuch-search-result-format)\r
112 +         (notmuch-search-insert-field (car spec) (cdr spec)\r
113 +                                      date count authors subject tags-str))\r
114 +       (insert "\n")\r
115 +       (notmuch-search-color-line beg (point) tags)\r
116 +       (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
117 +       (put-text-property beg (point) 'notmuch-search-authors authors)\r
118 +       (put-text-property beg (point) 'notmuch-search-subject subject))\r
119 +      (when (string= thread-id notmuch-search-target-thread)\r
120 +       (setq notmuch-search-target-thread "found")\r
121 +       (goto-char beg)))))\r
122  \r
123  (defun notmuch-search-show-error (string &rest objects)\r
124 -  (insert "Error: Unexpected output from notmuch search:\n")\r
125 -  (insert (apply #'format string objects))\r
126 -  (insert "\n"))\r
127 +  (save-excursion\r
128 +    (goto-char (point-max))\r
129 +    (insert "Error: Unexpected output from notmuch search:\n")\r
130 +    (insert (apply #'format string objects))\r
131 +    (insert "\n")))\r
132  \r
133  (defun notmuch-search-process-filter (proc string)\r
134    "Process and filter the output of \"notmuch search\""\r
135 -  (let ((buffer (process-buffer proc))\r
136 -       (found-target nil))\r
137 +  (let ((buffer (process-buffer proc)))\r
138      (if (buffer-live-p buffer)\r
139         (with-current-buffer buffer\r
140 -         (save-excursion\r
141             (let ((line 0)\r
142                   (more t)\r
143                   (inhibit-read-only t)\r
144 @@ -769,13 +774,9 @@ non-authors is found, assume that all of the authors match."\r
145                            (subject (match-string 5 string))\r
146                            (tags (match-string 6 string))\r
147                            (tag-list (if tags (save-match-data (split-string tags)))))\r
148 -                     (goto-char (point-max))\r
149                       (if (/= (match-beginning 1) line)\r
150                           (notmuch-search-show-error\r
151                            (substring string line (match-beginning 1))))\r
152 -                     (when (string= thread-id notmuch-search-target-thread)\r
153 -                       (set 'found-target (point))\r
154 -                       (set 'notmuch-search-target-thread "found"))\r
155                       (notmuch-search-show-result thread-id date count authors subject tag-list)\r
156                       (set 'line (match-end 0)))\r
157                   (set 'more nil)\r
158 @@ -784,8 +785,6 @@ non-authors is found, assume that all of the authors match."\r
159                   (if (< line (length string))\r
160                       (setq notmuch-search-process-filter-data (substring string line)))\r
161                   ))))\r
162 -         (if found-target\r
163 -             (goto-char found-target)))\r
164        (delete-process proc))))\r
165  \r
166  (defun notmuch-search-tag-all (&optional tag-changes)\r
167 -- \r
168 1.7.10\r
169 \r