[PATCH 5/7] emacs: Replace other search text properties with result property
authorAustin Clements <amdragon@MIT.EDU>
Fri, 13 Jul 2012 00:45:17 +0000 (20:45 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:14 +0000 (09:48 -0800)
9f/46f1c6424eb1be1196244e60782a26b232d0aa [new file with mode: 0644]

diff --git a/9f/46f1c6424eb1be1196244e60782a26b232d0aa b/9f/46f1c6424eb1be1196244e60782a26b232d0aa
new file mode 100644 (file)
index 0000000..0c89dd8
--- /dev/null
@@ -0,0 +1,148 @@
+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 5A0E141ED71\r
+       for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:37 -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 mzoeOtVCSWmF for <notmuch@notmuchmail.org>;\r
+       Thu, 12 Jul 2012 17:45:35 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 99E8741ED73\r
+       for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:30 -0700 (PDT)\r
+X-AuditID: 1209190e-b7fb56d0000008b2-f6-4fff6faa1f4d\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 91.51.02226.AAF6FFF4; Thu, 12 Jul 2012 20:45:30 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q6D0jU8B010246; \r
+       Thu, 12 Jul 2012 20:45:30 -0400\r
+Received: from drake.dyndns.org\r
+       (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [209.6.116.242]) (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 q6D0jSC7010704\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 12 Jul 2012 20:45:29 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SpU0e-0005S5-LG; Thu, 12 Jul 2012 20:45:28 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/7] emacs: Replace other search text properties with result\r
+       property\r
+Date: Thu, 12 Jul 2012 20:45:17 -0400\r
+Message-Id: <1342140319-19859-6-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
+References: <1342140319-19859-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6norsq/7+/wckGbovrN2cyOzB6PFt1\r
+       izmAMYrLJiU1J7MstUjfLoErY+XjR6wFryQr5my6wtzAeFG0i5GDQ0LAROLOFekuRk4gU0zi\r
+       wr31bCC2kMA+Rol3tyW7GLmA7A2MEoen9zBCOI+YJG7c6mGCcOYySlz838EI0sImoCGxbf9y\r
+       MFtEQFpi593ZrCAbmAXUJP50qYCEhQVCJdY+ugBWwiKgKnG+5QiYzSvgIPGlaQsTxBXyEk/v\r
+       94FdwSngKLHhywVWiIscJBqPzWSewMi/gJFhFaNsSm6Vbm5iZk5xarJucXJiXl5qka6xXm5m\r
+       iV5qSukmRlDIcEry7WD8elDpEKMAB6MSD+/v2P/+QqyJZcWVuYcYJTmYlER5XbKBQnxJ+SmV\r
+       GYnFGfFFpTmpxYcYJTiYlUR419kD5XhTEiurUovyYVLSHCxK4rxXUm76CwmkJ5akZqemFqQW\r
+       wWRlODiUJHg5gbEhJFiUmp5akZaZU4KQZuLgBBnOAzR8Wx7I8OKCxNzizHSI/ClGRSlx3gsg\r
+       CQGQREZpHlwvLKZfMYoDvSLMuxOkigeYDuC6XwENZgIaPOvnP5DBJYkIKakGxugThw9tP/Ey\r
+       Iun7/Sh1r+8rjtrMvMG7wCVf8doc17Vxrlk/Z7L2iMj4zGR7fVBtu873a447ujf+FlDQy2d6\r
+       F/J08qGPjBvrFri9FG/U/ezSsP6758NFeZbqSaoLftjET7TXyF0TGMu2V+b6bIkVWb8sdi2f\r
+       dc/i0/x3SXcOaCos8ck8dCB3ma4SS3FGoqEWc1FxIgAza16fxAIAAA==\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: Fri, 13 Jul 2012 00:45:37 -0000\r
+\r
+Since the result object contains everything that the other text\r
+properties recorded, we can remove the other text properties and\r
+simply look in the plist of the appropriate result object.\r
+---\r
+ emacs/notmuch.el |   24 ++++++++++--------------\r
+ 1 file changed, 10 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 3f72427..a5cf0dc 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -452,16 +452,18 @@ current result."\r
+ (defun notmuch-search-properties-in-region (property beg end)\r
+   (let (output)\r
+     (notmuch-search-do-results beg end pos\r
+-      (push (get-text-property pos property) output))\r
++      (push (plist-get (notmuch-search-get-result pos) property) output))\r
+     output))\r
\r
+ (defun notmuch-search-find-thread-id ()\r
+   "Return the thread for the current thread"\r
+-  (get-text-property (point) 'notmuch-search-thread-id))\r
++  (let ((thread (plist-get (notmuch-search-get-result) :thread)))\r
++    (when thread (concat "thread:" thread))))\r
\r
+ (defun notmuch-search-find-thread-id-region (beg end)\r
+   "Return a list of threads for the current region"\r
+-  (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end))\r
++  (mapcar (lambda (thread) (concat "thread:" thread))\r
++        (notmuch-search-properties-in-region :thread beg end)))\r
\r
+ (defun notmuch-search-find-thread-id-region-search (beg end)\r
+   "Return a search string for threads for the current region"\r
+@@ -469,19 +471,19 @@ current result."\r
\r
+ (defun notmuch-search-find-authors ()\r
+   "Return the authors for the current thread"\r
+-  (get-text-property (point) 'notmuch-search-authors))\r
++  (plist-get (notmuch-search-get-result) :authors))\r
\r
+ (defun notmuch-search-find-authors-region (beg end)\r
+   "Return a list of authors for the current region"\r
+-  (notmuch-search-properties-in-region 'notmuch-search-authors beg end))\r
++  (notmuch-search-properties-in-region :authors beg end))\r
\r
+ (defun notmuch-search-find-subject ()\r
+   "Return the subject for the current thread"\r
+-  (get-text-property (point) 'notmuch-search-subject))\r
++  (plist-get (notmuch-search-get-result) :subject))\r
\r
+ (defun notmuch-search-find-subject-region (beg end)\r
+   "Return a list of authors for the current region"\r
+-  (notmuch-search-properties-in-region 'notmuch-search-subject beg end))\r
++  (notmuch-search-properties-in-region :subject beg end))\r
\r
+ (defun notmuch-search-show-thread ()\r
+   "Display the currently selected thread."\r
+@@ -769,13 +771,7 @@ non-authors is found, assume that all of the authors match."\r
+         (notmuch-search-insert-field (car spec) (cdr spec) result))\r
+       (insert "\n")\r
+       (notmuch-search-color-line beg (point) (plist-get result :tags))\r
+-      (put-text-property beg (point) 'notmuch-search-result result)\r
+-      (put-text-property beg (point) 'notmuch-search-thread-id\r
+-                         (concat "thread:" (plist-get result :thread)))\r
+-      (put-text-property beg (point) 'notmuch-search-authors\r
+-                         (plist-get result :authors))\r
+-      (put-text-property beg (point) 'notmuch-search-subject\r
+-                         (plist-get result :subject)))\r
++      (put-text-property beg (point) 'notmuch-search-result result))\r
+       (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
+       (setq notmuch-search-target-thread "found")\r
+       (goto-char beg)))))\r
+-- \r
+1.7.10\r
+\r