[PATCH 1/7] emacs: Record thread search result object in a text property
authorAustin Clements <amdragon@MIT.EDU>
Fri, 13 Jul 2012 00:45:13 +0000 (20:45 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:14 +0000 (09:48 -0800)
d2/aa38eca48c88fc808be96fae07e395b84b979a [new file with mode: 0644]

diff --git a/d2/aa38eca48c88fc808be96fae07e395b84b979a b/d2/aa38eca48c88fc808be96fae07e395b84b979a
new file mode 100644 (file)
index 0000000..7b72c43
--- /dev/null
@@ -0,0 +1,127 @@
+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 C5F3541ED72\r
+       for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:28 -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 Qr2hUaOtYxnZ for <notmuch@notmuchmail.org>;\r
+       Thu, 12 Jul 2012 17:45:28 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+       [18.7.68.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id 78BC7421196\r
+       for <notmuch@notmuchmail.org>; Thu, 12 Jul 2012 17:45:26 -0700 (PDT)\r
+X-AuditID: 12074424-b7f2a6d0000008bf-bf-4fff6fa54e2a\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 8C.38.02239.5AF6FFF4; Thu, 12 Jul 2012 20:45:25 -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 q6D0jPLR010244; \r
+       Thu, 12 Jul 2012 20:45:25 -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 q6D0jNYI010662\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Thu, 12 Jul 2012 20:45:25 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SpU0Z-0005Ru-F9; Thu, 12 Jul 2012 20:45:23 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/7] emacs: Record thread search result object in a text\r
+       property\r
+Date: Thu, 12 Jul 2012 20:45:13 -0400\r
+Message-Id: <1342140319-19859-2-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+NgFtrEIsWRmVeSWpSXmKPExsUixG6nors0/7+/wd6XNhbXb85kdmD0eLbq\r
+       FnMAYxSXTUpqTmZZapG+XQJXRs/ih2wFqwQrZmy7xtrAOJOvi5GTQ0LARGL5jAZWCFtM4sK9\r
+       9WxdjFwcQgL7GCVat91hhnA2MEqsvv6PGaRKSOARk8S5/eoQibmMEnOO3GcBSbAJaEhs27+c\r
+       EcQWEZCW2Hl3NtBYDg5mATWJP10qIGFhgUCJF5vWgpWwCKhKnDi3lAnE5hVwkPj57S4jxBXy\r
+       Ek/v97GB2JwCjhIbvlxghdjrINF4bCbzBEb+BYwMqxhlU3KrdHMTM3OKU5N1i5MT8/JSi3TN\r
+       9XIzS/RSU0o3MYKDxkVlB2PzIaVDjAIcjEo8vL9i//sLsSaWFVfmHmKU5GBSEuV1yQYK8SXl\r
+       p1RmJBZnxBeV5qQWH2KU4GBWEuFdZw+U401JrKxKLcqHSUlzsCiJ815PuekvJJCeWJKanZpa\r
+       kFoEk5Xh4FCS4D2XB9QoWJSanlqRlplTgpBm4uAEGc4DNHwbSA1vcUFibnFmOkT+FKOilDhv\r
+       C0hCACSRUZoH1wuL6leM4kCvCPPuBKniASYEuO5XQIOZgAbP+vkPZHBJIkJKqoGRX/mlQfjV\r
+       Jab7druu+H/xhHLlNhm7UxuPPKgMOtoWHhBtHmB5o9O2qlKtSerELKMZE9rLl5zW3loR8djN\r
+       g61pqpHI5IV+LutLZc+/0FTtvnt3eYBvzIc6CytFtUs5B/srZjBPr5T89ISPd/7DLb7Lz1gz\r
+       rPjw5tAUr4Lrip4fjLW5DxpeMfyqxFKckWioxVxUnAgAn0pzOcUCAAA=\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:29 -0000\r
+\r
+This also provides utility functions for working with this text\r
+property that get its value, find its start, and find its end.\r
+---\r
+ emacs/notmuch.el |   27 +++++++++++++++++++++++++++\r
+ 1 file changed, 27 insertions(+)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index fabb7c0..ef18927 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -401,6 +401,32 @@ Complete list of currently available key bindings:\r
+       mode-name "notmuch-search")\r
+   (setq buffer-read-only t))\r
\r
++(defun notmuch-search-get-result (&optional pos)\r
++  "Return the result object for the thread at POS (or point).\r
++\r
++If there is no thread at POS (or point), returns nil."\r
++  (get-text-property (or pos (point)) 'notmuch-search-result))\r
++\r
++(defun notmuch-search-result-beginning (&optional pos)\r
++  "Return the point at the beginning of the thread at POS (or point).\r
++\r
++If there is no thread at POS (or point), returns nil."\r
++  (when (notmuch-search-get-result pos)\r
++    ;; We pass 1+point because previous-single-property-change starts\r
++    ;; searching one before the position we give it.\r
++    (previous-single-property-change (1+ (or pos (point)))\r
++                                   'notmuch-search-result nil (point-min))))\r
++\r
++(defun notmuch-search-result-end (&optional pos)\r
++  "Return the point at the end of the thread at POS (or point).\r
++\r
++The returned point will be just after the newline character that\r
++ends the result line.  If there is no thread at POS (or point),\r
++returns nil"\r
++  (when (notmuch-search-get-result pos)\r
++    (next-single-property-change (or pos (point)) 'notmuch-search-result\r
++                               nil (point-max))))\r
++\r
+ (defun notmuch-search-properties-in-region (property beg end)\r
+   (save-excursion\r
+     (let ((output nil)\r
+@@ -736,6 +762,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
+-- \r
+1.7.10\r
+\r