aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2012-07-21 13:37:05 -0400
committerGravatar David Bremner <bremner@debian.org>2012-07-24 09:04:27 -0300
commitae30f33093ebca63f8a18fff7054ac147898af94 (patch)
treebc7e80d8eb119bfe5c7100d5964edd012c420fef /emacs
parentbcdfff4f3a7a373851f08b22b56c58a25370b1fe (diff)
emacs: Record thread search result object in a text property
This also provides utility functions for working with this text property that get its value, find its start, and find its end.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/notmuch.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fabb7c0d..ef189273 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