unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH 5/7] emacs: Replace other search text properties with result property
Date: Thu, 12 Jul 2012 20:45:17 -0400	[thread overview]
Message-ID: <1342140319-19859-6-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1342140319-19859-1-git-send-email-amdragon@mit.edu>

Since the result object contains everything that the other text
properties recorded, we can remove the other text properties and
simply look in the plist of the appropriate result object.
---
 emacs/notmuch.el |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 3f72427..a5cf0dc 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -452,16 +452,18 @@ current result."
 (defun notmuch-search-properties-in-region (property beg end)
   (let (output)
     (notmuch-search-do-results beg end pos
-      (push (get-text-property pos property) output))
+      (push (plist-get (notmuch-search-get-result pos) property) output))
     output))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
-  (get-text-property (point) 'notmuch-search-thread-id))
+  (let ((thread (plist-get (notmuch-search-get-result) :thread)))
+    (when thread (concat "thread:" thread))))
 
 (defun notmuch-search-find-thread-id-region (beg end)
   "Return a list of threads for the current region"
-  (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end))
+  (mapcar (lambda (thread) (concat "thread:" thread))
+	  (notmuch-search-properties-in-region :thread beg end)))
 
 (defun notmuch-search-find-thread-id-region-search (beg end)
   "Return a search string for threads for the current region"
@@ -469,19 +471,19 @@ current result."
 
 (defun notmuch-search-find-authors ()
   "Return the authors for the current thread"
-  (get-text-property (point) 'notmuch-search-authors))
+  (plist-get (notmuch-search-get-result) :authors))
 
 (defun notmuch-search-find-authors-region (beg end)
   "Return a list of authors for the current region"
-  (notmuch-search-properties-in-region 'notmuch-search-authors beg end))
+  (notmuch-search-properties-in-region :authors beg end))
 
 (defun notmuch-search-find-subject ()
   "Return the subject for the current thread"
-  (get-text-property (point) 'notmuch-search-subject))
+  (plist-get (notmuch-search-get-result) :subject))
 
 (defun notmuch-search-find-subject-region (beg end)
   "Return a list of authors for the current region"
-  (notmuch-search-properties-in-region 'notmuch-search-subject beg end))
+  (notmuch-search-properties-in-region :subject beg end))
 
 (defun notmuch-search-show-thread ()
   "Display the currently selected thread."
@@ -769,13 +771,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
-			   (plist-get result :authors))
-	(put-text-property beg (point) 'notmuch-search-subject
-			   (plist-get result :subject)))
+	(put-text-property beg (point) 'notmuch-search-result result))
       (when (string= (plist-get result :thread) notmuch-search-target-thread)
 	(setq notmuch-search-target-thread "found")
 	(goto-char beg)))))
-- 
1.7.10

  parent reply	other threads:[~2012-07-13  0:45 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13  0:45 [PATCH 0/7] emacs: JSON-based search cleanups Austin Clements
2012-07-13  0:45 ` [PATCH 1/7] emacs: Record thread search result object in a text property Austin Clements
2012-07-13  0:45 ` [PATCH 2/7] emacs: Use text properties instead of overlays for tag coloring Austin Clements
2012-07-13 17:59   ` Mark Walters
2012-07-13 18:43     ` Austin Clements
2012-07-13  0:45 ` [PATCH 3/7] emacs: Update tags by rewriting the search result line in place Austin Clements
2012-07-13 17:57   ` Mark Walters
2012-07-13 18:33     ` Austin Clements
2012-07-13  0:45 ` [PATCH 4/7] emacs: Use result text properties for search result iteration Austin Clements
2012-07-13  0:45 ` Austin Clements [this message]
2012-07-13  0:45 ` [PATCH 6/7] emacs: Allow custom tags formatting Austin Clements
2012-07-13  0:45 ` [PATCH 7/7] emacs: Fix navigation of multi-line search result formats Austin Clements
2012-07-13 17:21   ` Mark Walters
2012-07-13 17:53     ` Austin Clements
2012-07-13 18:02       ` Mark Walters
2012-07-13 18:12 ` [PATCH 0/7] emacs: JSON-based search cleanups Mark Walters
2012-07-14  3:28   ` Austin Clements
2012-07-14  3:43 ` [PATCH v2 " Austin Clements
2012-07-14  3:43   ` [PATCH v2 1/7] emacs: Record thread search result object in a text property Austin Clements
2012-07-14  3:43   ` [PATCH v2 2/7] emacs: Use text properties instead of overlays for tag coloring Austin Clements
2012-07-14  3:43   ` [PATCH v2 3/7] emacs: Update tags by rewriting the search result line in place Austin Clements
2012-07-14  3:43   ` [PATCH v2 4/7] emacs: Use result text properties for search result iteration Austin Clements
2012-07-14 19:31     ` Jameson Graef Rollins
2012-07-14 19:35       ` Jameson Graef Rollins
2012-07-14 19:50       ` Austin Clements
2012-07-14 20:01         ` Austin Clements
2012-07-14 21:13         ` Jameson Graef Rollins
2012-07-14 21:51           ` Austin Clements
2012-07-14 23:02             ` Jameson Graef Rollins
2012-07-14 21:15     ` Mark Walters
2012-07-14  3:43   ` [PATCH v2 5/7] emacs: Replace other search text properties with result property Austin Clements
2012-07-14  3:43   ` [PATCH v2 6/7] emacs: Allow custom tags formatting Austin Clements
2012-07-14  3:43   ` [PATCH v2 7/7] emacs: Fix navigation of multi-line search result formats Austin Clements
2012-07-14 19:06   ` [PATCH v2 0/7] emacs: JSON-based search cleanups Jameson Graef Rollins
2012-07-14 23:02 ` [PATCH v3 0/8] " Austin Clements
2012-07-14 23:02   ` [PATCH v3 1/8] emacs: Record thread search result object in a text property Austin Clements
2012-07-14 23:02   ` [PATCH v3 2/8] emacs: Use text properties instead of overlays for tag coloring Austin Clements
2012-07-14 23:02   ` [PATCH v3 3/8] emacs: Update tags by rewriting the search result line in place Austin Clements
2012-07-14 23:02   ` [PATCH v3 4/8] emacs: Use result text properties for search result iteration Austin Clements
2012-07-14 23:02   ` [PATCH v3 5/8] emacs: Replace other search text properties with result property Austin Clements
2012-07-14 23:02   ` [PATCH v3 6/8] emacs: Allow custom tags formatting Austin Clements
2012-07-14 23:02   ` [PATCH v3 7/8] emacs: Fix navigation of multi-line search result formats Austin Clements
2012-07-14 23:02   ` [PATCH v3 8/8] News for search cleanups Austin Clements
2012-07-15  8:34   ` [PATCH v3 0/8] emacs: JSON-based " Mark Walters
2012-07-15 21:14     ` Jameson Graef Rollins
2012-07-15 16:27   ` Mark Walters
2012-07-15 18:00     ` Austin Clements
2012-07-15 18:14       ` Mark Walters
2012-07-21 17:55 ` [PATCH v4] " Austin Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342140319-19859-6-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).