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 D756D431FCF for ; Sat, 21 Jul 2012 10:37:21 -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 sufbTuIu9s1l for ; Sat, 21 Jul 2012 10:37:21 -0700 (PDT) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id E4BD3431FC2 for ; Sat, 21 Jul 2012 10:37:19 -0700 (PDT) X-AuditID: 12074422-b7f1f6d00000090b-96-500ae8ceb017 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id 9F.D1.02315.EC8EA005; Sat, 21 Jul 2012 13:37:18 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6LHbHif029418; Sat, 21 Jul 2012 13:37:17 -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 q6LHbFEw008011 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 21 Jul 2012 13:37:16 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1SsdcB-0001Ze-6w; Sat, 21 Jul 2012 13:37:15 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v4 1/8] emacs: Record thread search result object in a text property Date: Sat, 21 Jul 2012 13:37:05 -0400 Message-Id: <1342892232-5659-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1342892232-5659-1-git-send-email-amdragon@mit.edu> References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> <1342892232-5659-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrHvuBVeAwffT0hZ79nlZrJ7LY3H9 5kxmB2aPu6e5PHbOusvu8WzVLeYA5igum5TUnMyy1CJ9uwSujJ7FD9kKVglWzNh2jbWBcSZf FyMnh4SAicTfm83MELaYxIV769m6GLk4hAT2MUo83DifCcLZwCjxauNJZgjnEZNEf/t3Fghn LqPEj6uLmUD62QQ0JLbtX84IYosISEvsvDubFcRmFkiT+N7+FiwuLBAicXrrLDYQm0VAVaJj wjqw3bwC9hIHni9jh7hDXuLp/T6wGk4BB4lHZw+wgNhCAmUSizsOM05g5F/AyLCKUTYlt0o3 NzEzpzg1Wbc4OTEvL7VI11QvN7NELzWldBMjKLTYXZR2MP48qHSIUYCDUYmH12MWZ4AQa2JZ cWXuIUZJDiYlUd6++1wBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4N50GyvGmJFZWpRblw6Sk OViUxHmvpdz0FxJITyxJzU5NLUgtgsnKcHAoSfC6A2NISLAoNT21Ii0zpwQhzcTBCTKcB2i4 GEgNb3FBYm5xZjpE/hSjopQ4rx1IQgAkkVGaB9cLi/1XjOJArwjzfnsOVMUDTBtw3a+ABjMB DZbOAhtckoiQkmpgrPscs+7f2nuHWH5uWLFxRWbBQfOSX3PO1VUv4cpaanzxyvpNv8tZ+n9f LI+2qOtYHz3zjLWl3pJ/MYX/9zC4WxZlF1RmKT/6rCQ86+6Tf6tN0+el1dtsiTvf9zLHtqvg zfXgvhz3ub/8811/rpBzYIo3iD208P6enw2sM9eqF7cLpae4nFrmrsRSnJFoqMVcVJwIAPu6 8YvYAgAA 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, 21 Jul 2012 17:37:22 -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