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 EDB76429E3F for ; Sat, 14 Jul 2012 16:02:27 -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 X5q-oqlQG+CP for ; Sat, 14 Jul 2012 16:02:27 -0700 (PDT) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id A62E9431FBD for ; Sat, 14 Jul 2012 16:02:26 -0700 (PDT) X-AuditID: 1209190c-b7f806d000006b87-c4-5001fa82f798 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 42.FE.27527.28AF1005; Sat, 14 Jul 2012 19:02:26 -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 q6EN2PZw031811; Sat, 14 Jul 2012 19:02: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 q6EN2N6e008493 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 14 Jul 2012 19:02:24 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1SqBLz-0002G3-OA; Sat, 14 Jul 2012 19:02:23 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v3 1/8] emacs: Record thread search result object in a text property Date: Sat, 14 Jul 2012 19:02:13 -0400 Message-Id: <1342306940-7499-2-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1342306940-7499-1-git-send-email-amdragon@mit.edu> References: <1342140319-19859-1-git-send-email-amdragon@mit.edu> <1342306940-7499-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixG6notv0izHA4Mwnbos9+7wsVs/lsbh+ cyazA7PH3dNcHjtn3WX3eLbqFnMAcxSXTUpqTmZZapG+XQJXRs/ih2wFqwQrZmy7xtrAOJOv i5GTQ0LARGL5v7dsELaYxIV764FsLg4hgX2MEl+PrIFyNjBKzNwzmQnCecQkMeHFEUYIZy6j xM59XSwg/WwCGhLb9i9nBLFFBKQldt6dzQpiMwukSXxvfwsWFxYIkbgx9ws7iM0ioCrxZVk7 WA2vgL3EpsvvmCHukJd4er8P7CZOAQeJwxdOgNUICZRJ3HjynXUCI/8CRoZVjLIpuVW6uYmZ OcWpybrFyYl5ealFuoZ6uZkleqkppZsYQaHFKcmzg/HNQaVDjAIcjEo8vOn+DAFCrIllxZW5 hxglOZiURHlf/2QMEOJLyk+pzEgszogvKs1JLT7EKMHBrCTCK/EVKMebklhZlVqUD5OS5mBR Eue9nHLTX0ggPbEkNTs1tSC1CCYrw8GhJMFbCDJUsCg1PbUiLTOnBCHNxMEJMpwHaHg3SA1v cUFibnFmOkT+FKOilDhvL0hCACSRUZoH1wuL/VeM4kCvCPMuBaniAaYNuO5XQIOZgAbP+vnP H2hwSSJCSqqBMcNsjxPvkY1n7VW9GspVGy/abnTycszT2M/1dmFF8czr/hoHojZV7WOx3G3m Lsm4Jn3duY9ZF/7vrncPu5/yhGfGnYjNHpfqy3nX91yc7qrPfCaRoV8w7mmiZ0L1+28Zkr+Y tacntptvkBZr2GnGvKz4mubfST+ZjGv65RanCDcW/7puuZRXiaU4I9FQi7moOBEA8FaDLdgC AAA= 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 23:02:28 -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