From 4c9d587d8311f92059d8c7fa2096805008d4c471 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 13 Jul 2012 20:45:13 +2000 Subject: [PATCH] [PATCH 1/7] emacs: Record thread search result object in a text property --- d2/aa38eca48c88fc808be96fae07e395b84b979a | 127 ++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 d2/aa38eca48c88fc808be96fae07e395b84b979a diff --git a/d2/aa38eca48c88fc808be96fae07e395b84b979a b/d2/aa38eca48c88fc808be96fae07e395b84b979a new file mode 100644 index 000000000..7b72c4376 --- /dev/null +++ b/d2/aa38eca48c88fc808be96fae07e395b84b979a @@ -0,0 +1,127 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id C5F3541ED72 + for ; Thu, 12 Jul 2012 17:45:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Qr2hUaOtYxnZ for ; + Thu, 12 Jul 2012 17:45:28 -0700 (PDT) +Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU + [18.7.68.36]) + by olra.theworths.org (Postfix) with ESMTP id 78BC7421196 + for ; Thu, 12 Jul 2012 17:45:26 -0700 (PDT) +X-AuditID: 12074424-b7f2a6d0000008bf-bf-4fff6fa54e2a +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id 8C.38.02239.5AF6FFF4; Thu, 12 Jul 2012 20:45:25 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q6D0jPLR010244; + Thu, 12 Jul 2012 20:45:25 -0400 +Received: from drake.dyndns.org + (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com + [209.6.116.242]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6D0jNYI010662 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 12 Jul 2012 20:45:25 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1SpU0Z-0005Ru-F9; Thu, 12 Jul 2012 20:45:23 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 1/7] emacs: Record thread search result object in a text + property +Date: Thu, 12 Jul 2012 20:45:13 -0400 +Message-Id: <1342140319-19859-2-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1342140319-19859-1-git-send-email-amdragon@mit.edu> +References: <1342140319-19859-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6nors0/7+/wd6XNhbXb85kdmD0eLbq + FnMAYxSXTUpqTmZZapG+XQJXRs/ih2wFqwQrZmy7xtrAOJOvi5GTQ0LARGL5jAZWCFtM4sK9 + 9WxdjFwcQgL7GCVat91hhnA2MEqsvv6PGaRKSOARk8S5/eoQibmMEnOO3GcBSbAJaEhs27+c + EcQWEZCW2Hl3NtBYDg5mATWJP10qIGFhgUCJF5vWgpWwCKhKnDi3lAnE5hVwkPj57S4jxBXy + Ek/v97GB2JwCjhIbvlxghdjrINF4bCbzBEb+BYwMqxhlU3KrdHMTM3OKU5N1i5MT8/JSi3TN + 9XIzS/RSU0o3MYKDxkVlB2PzIaVDjAIcjEo8vL9i//sLsSaWFVfmHmKU5GBSEuV1yQYK8SXl + p1RmJBZnxBeV5qQWH2KU4GBWEuFdZw+U401JrKxKLcqHSUlzsCiJ815PuekvJJCeWJKanZpa + kFoEk5Xh4FCS4D2XB9QoWJSanlqRlplTgpBm4uAEGc4DNHwbSA1vcUFibnFmOkT+FKOilDhv + C0hCACSRUZoH1wuL6leM4kCvCPPuBKniASYEuO5XQIOZgAbP+vkPZHBJIkJKqoGRX/mlQfjV + Jab7druu+H/xhHLlNhm7UxuPPKgMOtoWHhBtHmB5o9O2qlKtSerELKMZE9rLl5zW3loR8djN + g61pqpHI5IV+LutLZc+/0FTtvnt3eYBvzIc6CytFtUs5B/srZjBPr5T89ISPd/7DLb7Lz1gz + rPjw5tAUr4Lrip4fjLW5DxpeMfyqxFKckWioxVxUnAgAn0pzOcUCAAA= +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 13 Jul 2012 00:45:29 -0000 + +This also provides utility functions for working with this text +property that get its value, find its start, and find its end. +--- + emacs/notmuch.el | 27 +++++++++++++++++++++++++++ + 1 file changed, 27 insertions(+) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index fabb7c0..ef18927 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -401,6 +401,32 @@ Complete list of currently available key bindings: + mode-name "notmuch-search") + (setq buffer-read-only t)) + ++(defun notmuch-search-get-result (&optional pos) ++ "Return the result object for the thread at POS (or point). ++ ++If there is no thread at POS (or point), returns nil." ++ (get-text-property (or pos (point)) 'notmuch-search-result)) ++ ++(defun notmuch-search-result-beginning (&optional pos) ++ "Return the point at the beginning of the thread at POS (or point). ++ ++If there is no thread at POS (or point), returns nil." ++ (when (notmuch-search-get-result pos) ++ ;; We pass 1+point because previous-single-property-change starts ++ ;; searching one before the position we give it. ++ (previous-single-property-change (1+ (or pos (point))) ++ 'notmuch-search-result nil (point-min)))) ++ ++(defun notmuch-search-result-end (&optional pos) ++ "Return the point at the end of the thread at POS (or point). ++ ++The returned point will be just after the newline character that ++ends the result line. If there is no thread at POS (or point), ++returns nil" ++ (when (notmuch-search-get-result pos) ++ (next-single-property-change (or pos (point)) 'notmuch-search-result ++ nil (point-max)))) ++ + (defun notmuch-search-properties-in-region (property beg end) + (save-excursion + (let ((output nil) +@@ -736,6 +762,7 @@ non-authors is found, assume that all of the authors match." + (notmuch-search-insert-field (car spec) (cdr spec) result)) + (insert "\n") + (notmuch-search-color-line beg (point) (plist-get result :tags)) ++ (put-text-property beg (point) 'notmuch-search-result result) + (put-text-property beg (point) 'notmuch-search-thread-id + (concat "thread:" (plist-get result :thread))) + (put-text-property beg (point) 'notmuch-search-authors +-- +1.7.10 + -- 2.26.2