From 324018b4d930ba244b3bb506f2030117b6a2d899 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 14 Jul 2012 23:43:20 +2000 Subject: [PATCH 1/1] [PATCH v2 1/7] emacs: Record thread search result object in a text property --- 09/3ffbe63e9152f43393e66952af9af00b19edd9 | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 09/3ffbe63e9152f43393e66952af9af00b19edd9 diff --git a/09/3ffbe63e9152f43393e66952af9af00b19edd9 b/09/3ffbe63e9152f43393e66952af9af00b19edd9 new file mode 100644 index 000000000..b9dd4f736 --- /dev/null +++ b/09/3ffbe63e9152f43393e66952af9af00b19edd9 @@ -0,0 +1,128 @@ +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 2C5B941ED7F + for ; Fri, 13 Jul 2012 20:43:46 -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 IK4Z-+9ZEN2U for ; + Fri, 13 Jul 2012 20:43:45 -0700 (PDT) +Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU + [18.9.25.13]) + by olra.theworths.org (Postfix) with ESMTP id 3A295421197 + for ; Fri, 13 Jul 2012 20:43:40 -0700 (PDT) +X-AuditID: 1209190d-b7fd56d000000933-f8-5000eaeb0098 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id C5.89.02355.BEAE0005; Fri, 13 Jul 2012 23:43:39 -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 q6E3hcg3014751; + Fri, 13 Jul 2012 23:43:38 -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 q6E3ha8w021323 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Fri, 13 Jul 2012 23:43:38 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1SptGa-0000Zv-KO; Fri, 13 Jul 2012 23:43:36 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v2 1/7] emacs: Record thread search result object in a text + property +Date: Fri, 13 Jul 2012 23:43:20 -0400 +Message-Id: <1342237406-32507-2-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1342237406-32507-1-git-send-email-amdragon@mit.edu> +References: <1342140319-19859-1-git-send-email-amdragon@mit.edu> + <1342237406-32507-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsUixG6novv6FUOAwcpL4har5/JYXL85k9mB + yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyuhZ/JCtYJVgxYxt11gbGGfydTFycEgImEg8 + PKrfxcgJZIpJXLi3ng3EFhLYxyjRcd6hi5ELyN7AKHFvTg8rhPOISaL//2tGCGcuo8T2DX9Y + QVrYBDQktu1fzghiiwhIS+y8OxsszizgKPF5/yKwscICIRIbW3eC2SwCqhIT505kArF5BRwk + Pr3qYoU4Q17i6f0+sBpOoN623tuMECeVS1z/toZpAiP/AkaGVYyyKblVurmJmTnFqcm6xcmJ + eXmpRbpGermZJXqpKaWbGEFhxCnJu4Px3UGlQ4wCHIxKPLyp/gwBQqyJZcWVuYcYJTmYlER5 + eYFBKMSXlJ9SmZFYnBFfVJqTWnyIUYKDWUmE17wNKMebklhZlVqUD5OS5mBREue9knLTX0gg + PbEkNTs1tSC1CCYrw8GhJMErDDJUsCg1PbUiLTOnBCHNxMEJMpwHaLg0SA1vcUFibnFmOkT+ + FKOilDjv5ZdACQGQREZpHlwvLM5fMYoDvSLMawPSzgNMEXDdr4AGMwENnvXznz/Q4JJEhJRU + A2P6pcaVmxxYEjbkCjbvD7XaF3S9YPnule8Y72+o9mOID73QfFjKv/PC6p3Jm9ee4vBwUKn5 + K6lhkHmCWbsxSmvak6Mx2QI+y1/cPtS4OPxs8LG6pcnXp9g/cJ36kqF454qIXg+rhen/368O + O6rLNHeV6es9y210eua9Ly6Zpq3rt35O/oM/HRlKLMUZiYZazEXFiQCWg4NhzgIAAA== +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: Sat, 14 Jul 2012 03:43:46 -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