[PATCH v2 2/9] emacs: Separate search line parsing and display
authorAustin Clements <amdragon@MIT.EDU>
Thu, 5 Jul 2012 20:52:20 +0000 (16:52 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:01 +0000 (09:48 -0800)
76/f9a722ae4dd1e30d5da281fdb7c94cb33709bd [new file with mode: 0644]

diff --git a/76/f9a722ae4dd1e30d5da281fdb7c94cb33709bd b/76/f9a722ae4dd1e30d5da281fdb7c94cb33709bd
new file mode 100644 (file)
index 0000000..f33a049
--- /dev/null
@@ -0,0 +1,136 @@
+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 88B39431FC2\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 13:52:48 -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 4GDSbmNaQWib for <notmuch@notmuchmail.org>;\r
+       Thu,  5 Jul 2012 13:52:47 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
+       [18.7.68.37])\r
+       by olra.theworths.org (Postfix) with ESMTP id B824B431FC7\r
+       for <notmuch@notmuchmail.org>; Thu,  5 Jul 2012 13:52:43 -0700 (PDT)\r
+X-AuditID: 12074425-b7f9b6d0000008c4-88-4ff5fe9b6b2d\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 1E.07.02244.B9EF5FF4; Thu,  5 Jul 2012 16:52:43 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q65Kqgv1011303; \r
+       Thu, 5 Jul 2012 16:52:42 -0400\r
+Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q65KqbmT027235\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 5 Jul 2012 16:52:39 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Smt2T-0004XX-HV; Thu, 05 Jul 2012 16:52:37 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/9] emacs: Separate search line parsing and display\r
+Date: Thu,  5 Jul 2012 16:52:20 -0400\r
+Message-Id: <1341521547-15502-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
+References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
+       <1341521547-15502-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrTv731d/g6ZlIhar5/JYXL85k9ni\r
+       zcp5rA7MHjtn3WX3OPx1IYvHs1W3mAOYo7hsUlJzMstSi/TtErgyrv/YylawS7zi0PYjrA2M\r
+       L4W6GDk5JARMJHZcP8YOYYtJXLi3nq2LkYtDSGAfo8SlEx1MEM56Rolrc9YzQjgnmSQeHLnP\r
+       DuHMZZRo/tzEBtLPJqAhsW3/ckYQW0RAWmLn3dmsIDazQJzElin/weLCAu4S1+/1AcU5OFgE\r
+       VCUe7bcAMXkFHCR+bhKBuEJe4un9PrCJnAKOEhcmLgbrFBIol/iz5B/LBEb+BYwMqxhlU3Kr\r
+       dHMTM3OKU5N1i5MT8/JSi3Qt9HIzS/RSU0o3MYJCi91FdQfjhENKhxgFOBiVeHiNcr/4C7Em\r
+       lhVX5h5ilORgUhLlbfz91V+ILyk/pTIjsTgjvqg0J7X4EKMEB7OSCG9vBlCONyWxsiq1KB8m\r
+       Jc3BoiTOeyPlpr+QQHpiSWp2ampBahFMVoaDQ0mC9+lfoEbBotT01Iq0zJwShDQTByfIcB6g\r
+       4S9AaniLCxJzizPTIfKnGBWlxHmvgyQEQBIZpXlwvbDYf8UoDvSKMO8nkCoeYNqA634FNJgJ\r
+       aHDe4k8gg0sSEVJSDYyHDd24n+xVzdhZH9gisDl0oZmrvtaZx39+qydec/qxofTwIl+Xf0Hf\r
+       aw22yi3s5BeoYleLc54oKVDywF7qSfwm4WbtaXJbWVe+7RZedsJ8caxsn8SBcwvnftDuObr7\r
+       15mPzjb7rijrJf1WdZ8h9qdfVTFH1r/Edy/j3vXrq9ZKuM09d/3BhTlKLMUZiYZazEXFiQBK\r
+       402j2AIAAA==\r
+Cc: tomi.ollila@iki.fi\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: Thu, 05 Jul 2012 20:52:48 -0000\r
+\r
+Previously, much of the display of search lines was done in the same\r
+function that parsed the CLI's output.  Now the parsing function only\r
+parses, and notmuch-search-show-result fully inserts the search result\r
+in the search buffer.\r
+---\r
+ emacs/notmuch.el |   33 +++++++++++++++++----------------\r
+ 1 file changed, 17 insertions(+), 16 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 8ad0b68..746d0cb 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -727,11 +727,19 @@ non-authors is found, assume that all of the authors match."\r
+     ;; depends on the format of this\r
+     (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")")))))\r
\r
+-(defun notmuch-search-show-result (date count authors subject tags)\r
+-  (dolist (spec notmuch-search-result-format)\r
+-    (notmuch-search-insert-field (car spec) (cdr spec)\r
+-                               date count authors subject tags))\r
+-  (insert "\n"))\r
++(defun notmuch-search-show-result (thread-id date count authors subject tags)\r
++  ;; Ignore excluded matches\r
++  (unless (eq (aref count 1) ?0)\r
++    (let ((beg (point))\r
++        (tags-str (mapconcat 'identity tags " ")))\r
++      (dolist (spec notmuch-search-result-format)\r
++      (notmuch-search-insert-field (car spec) (cdr spec)\r
++                                   date count authors subject tags-str))\r
++      (insert "\n")\r
++      (notmuch-search-color-line beg (point) tags)\r
++      (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
++      (put-text-property beg (point) 'notmuch-search-authors authors)\r
++      (put-text-property beg (point) 'notmuch-search-subject subject))))\r
\r
+ (defun notmuch-search-process-filter (proc string)\r
+   "Process and filter the output of \"notmuch search\""\r
+@@ -759,17 +767,10 @@ non-authors is found, assume that all of the authors match."\r
+                     (goto-char (point-max))\r
+                     (if (/= (match-beginning 1) line)\r
+                         (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n")))\r
+-                    ;; We currently just throw away excluded matches.\r
+-                    (unless (eq (aref count 1) ?0)\r
+-                      (let ((beg (point)))\r
+-                        (notmuch-search-show-result date count authors subject tags)\r
+-                        (notmuch-search-color-line beg (point) tag-list)\r
+-                        (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
+-                        (put-text-property beg (point) 'notmuch-search-authors authors)\r
+-                        (put-text-property beg (point) 'notmuch-search-subject subject)\r
+-                        (when (string= thread-id notmuch-search-target-thread)\r
+-                          (set 'found-target beg)\r
+-                          (set 'notmuch-search-target-thread "found"))))\r
++                    (when (string= thread-id notmuch-search-target-thread)\r
++                      (set 'found-target (point))\r
++                      (set 'notmuch-search-target-thread "found"))\r
++                    (notmuch-search-show-result thread-id date count authors subject tag-list)\r
+                     (set 'line (match-end 0)))\r
+                 (set 'more nil)\r
+                 (while (and (< line (length string)) (= (elt string line) ?\n))\r
+-- \r
+1.7.10\r
+\r