--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1785E431FC2\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 13:12:15 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id e6pOaAATsk7h for <notmuch@notmuchmail.org>;\r
+ Tue, 22 Apr 2014 13:12:11 -0700 (PDT)\r
+Received: from mail-we0-f175.google.com (mail-we0-f175.google.com\r
+ [74.125.82.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id CB391431FC0\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 13:12:08 -0700 (PDT)\r
+Received: by mail-we0-f175.google.com with SMTP id q58so5386031wes.6\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 13:12:07 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=sdOSw48NlKn58XcRkyvgYWg0Cvs0tiX6J93UPY4P8fQ=;\r
+ b=sQggZF54V2YGczbd+YPbtNcTEYZQn53xB57+sc/f8MkET+DrhnNRBR1+nlW2oWl4ly\r
+ wM07alRy7IdbKkysHowTIyXkp0DAlge0aL53O9A/X8rT7biZLQEepQ3HXKph/Lqk733Y\r
+ KpZXjawhckT5e6MsS5+NwfgoTjUFc6HRreF5DWZH1iNMa/yKr4Pdtj7bVzfqRT3BdK/z\r
+ LJMB6LrnOCW4lJR9L2gT3eSENiQyzUtisz71WEmD3hulr82kue6aZZFHpTlUgR2SpUGZ\r
+ IJ5p5v0sJXPQXN9lqmEJLVIjOHaS2ydWn2rbl6rySq3ygx6ofoAdrbNCtB8FFT2WwrPS\r
+ 4uCA==\r
+X-Received: by 10.180.78.225 with SMTP id e1mr20532843wix.17.1398197527525;\r
+ Tue, 22 Apr 2014 13:12:07 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by mx.google.com with ESMTPSA id\r
+ lj15sm24552802wic.13.2014.04.22.13.12.06 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Tue, 22 Apr 2014 13:12:07 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [WIP PATCH 2/4] emacs: search: add a marked thread variable and add\r
+ to relevant functions\r
+Date: Tue, 22 Apr 2014 21:11:48 +0100\r
+Message-Id: <1398197510-28224-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1398197510-28224-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1398197510-28224-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 22 Apr 2014 20:12:15 -0000\r
+\r
+Add a marked thread variable containing a list of thread ids of marked\r
+threads and make it be passed through all relevant functions. This\r
+ends up being quite large as there are quite a few callers.\r
+\r
+Alternatively we could overload beg rather than adding a thread-list\r
+variable. This would make a much smaller patch but might be more\r
+confusing.\r
+---\r
+ emacs/notmuch.el | 66 +++++++++++++++++++++++++++++++-----------------------\r
+ 1 file changed, 38 insertions(+), 28 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index cb7c006..7b06458 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -100,6 +100,11 @@ (defcustom notmuch-init-file (locate-user-emacs-file "notmuch-config")\r
+ (defvar notmuch-query-history nil\r
+ "Variable to store minibuffer history for notmuch queries")\r
+ \r
++(defvar notmuch-search-marked-threads nil\r
++ "Buffer local list of marked threads")\r
++(make-variable-buffer-local 'notmuch-search-marked-threads)\r
++(put 'notmuch-search-marked-threads 'permanent-local t)\r
++\r
+ (defun notmuch-foreach-mime-part (function mm-handle)\r
+ (cond ((stringp (car mm-handle))\r
+ (dolist (part (cdr mm-handle))\r
+@@ -375,7 +380,7 @@ (defun notmuch-search-result-end (&optional pos)\r
+ (next-single-property-change (or pos (point)) 'notmuch-search-result\r
+ nil (point-max))))\r
+ \r
+-(defun notmuch-search-foreach-result (beg end function)\r
++(defun notmuch-search-foreach-result (beg end thread-list function)\r
+ "Invoke FUNCTION for each result between BEG and END.\r
+ \r
+ FUNCTION should take no arguments. It will be applied at the\r
+@@ -400,9 +405,9 @@ (defun notmuch-search-foreach-result (beg end function)\r
+ ;; the indentation of callers doesn't get out of hand.\r
+ (put 'notmuch-search-foreach-result 'lisp-indent-function 2)\r
+ \r
+-(defun notmuch-search-properties-in-region (property beg end)\r
++(defun notmuch-search-properties-in-region (property beg end &optional thread-list)\r
+ (let (output)\r
+- (notmuch-search-foreach-result beg end\r
++ (notmuch-search-foreach-result beg end thread-list\r
+ (lambda ()\r
+ (push (plist-get (notmuch-search-get-result) property) output)))\r
+ output))\r
+@@ -421,13 +426,13 @@ (defun notmuch-search-find-stable-query ()\r
+ matched and unmatched messages in the current thread."\r
+ (plist-get (notmuch-search-get-result) :query))\r
+ \r
+-(defun notmuch-search-find-stable-query-region (beg end &optional only-matched)\r
++(defun notmuch-search-find-stable-query-region (beg end &optional only-matched thread-list)\r
+ "Return the stable query for the current region.\r
+ \r
+ If ONLY-MATCHED is non-nil, include only matched messages. If it\r
+ is nil, include both matched and unmatched messages."\r
+ (let ((query-list nil) (all (not only-matched)))\r
+- (dolist (queries (notmuch-search-properties-in-region :query beg end))\r
++ (dolist (queries (notmuch-search-properties-in-region :query beg end thread-list))\r
+ (when (first queries)\r
+ (push (first queries) query-list))\r
+ (when (and all (second queries))\r
+@@ -438,17 +443,17 @@ (defun notmuch-search-find-authors ()\r
+ "Return the authors for the current thread"\r
+ (plist-get (notmuch-search-get-result) :authors))\r
+ \r
+-(defun notmuch-search-find-authors-region (beg end)\r
++(defun notmuch-search-find-authors-region (beg end &optional thread-list)\r
+ "Return a list of authors for the current region"\r
+- (notmuch-search-properties-in-region :authors beg end))\r
++ (notmuch-search-properties-in-region :authors beg end thread-list))\r
+ \r
+ (defun notmuch-search-find-subject ()\r
+ "Return the subject for the current thread"\r
+ (plist-get (notmuch-search-get-result) :subject))\r
+ \r
+-(defun notmuch-search-find-subject-region (beg end)\r
++(defun notmuch-search-find-subject-region (beg end &optional thread-list)\r
+ "Return a list of authors for the current region"\r
+- (notmuch-search-properties-in-region :subject beg end))\r
++ (notmuch-search-properties-in-region :subject beg end thread-list))\r
+ \r
+ (defun notmuch-search-show-thread (&optional elide-toggle)\r
+ "Display the currently selected thread."\r
+@@ -497,9 +502,9 @@ (defun notmuch-search-set-tags (tags &optional pos)\r
+ (defun notmuch-search-get-tags (&optional pos)\r
+ (plist-get (notmuch-search-get-result pos) :tags))\r
+ \r
+-(defun notmuch-search-get-tags-region (beg end)\r
++(defun notmuch-search-get-tags-region (beg end &optional thread-list)\r
+ (let (output)\r
+- (notmuch-search-foreach-result beg end\r
++ (notmuch-search-foreach-result beg end thread-list\r
+ (lambda ()\r
+ (setq output (append output (notmuch-search-get-tags)))))\r
+ output))\r
+@@ -507,24 +512,29 @@ (defun notmuch-search-get-tags-region (beg end)\r
+ (defun notmuch-search-interactive-region ()\r
+ "Return the bounds of the current interactive region.\r
+ \r
+-This returns (BEG END), where BEG and END are the bounds of the\r
+-region if the region is active, or both `point' otherwise."\r
++This returns (BEG END THREAD-LIST), where BEG and END are the\r
++bounds of the region if the region is active, or both `point'\r
++otherwise and THREAD-LIST is a list of the marked threads (if\r
++any)."\r
+ (if (region-active-p)\r
+- (list (region-beginning) (region-end))\r
+- (list (point) (point))))\r
++ (list (region-beginning) (region-end) notmuch-search-marked-threads)\r
++ (list (point) (point) notmuch-search-marked-threads)))\r
+ \r
+ (defun notmuch-search-interactive-tag-changes (&optional initial-input)\r
+- "Prompt for tag changes for the current thread or region.\r
++ "Prompt for tag changes for the current thread, marked threads or region.\r
+ \r
+-Returns (TAG-CHANGES REGION-BEGIN REGION-END)."\r
++Returns (TAG-CHANGES REGION-BEGIN REGION-END THREAD-LIST)."\r
+ (let* ((region (notmuch-search-interactive-region))\r
+ (beg (first region)) (end (second region))\r
+- (prompt (if (= beg end) "Tag thread" "Tag region")))\r
++ (thread-list (third region))\r
++ (prompt (if thread-list\r
++ "Tag marked threads"\r
++ (if (= beg end) "Tag thread" "Tag region"))))\r
+ (cons (notmuch-read-tag-changes\r
+- (notmuch-search-get-tags-region beg end) prompt initial-input)\r
++ (notmuch-search-get-tags-region beg end thread-list) prompt initial-input)\r
+ region)))\r
+ \r
+-(defun notmuch-search-tag (tag-changes &optional beg end only-matched)\r
++(defun notmuch-search-tag (tag-changes &optional beg end only-matched thread-list)\r
+ "Change tags for the currently selected thread or region.\r
+ \r
+ See `notmuch-tag' for information on the format of TAG-CHANGES.\r
+@@ -537,30 +547,30 @@ (defun notmuch-search-tag (tag-changes &optional beg end only-matched)\r
+ (interactive (notmuch-search-interactive-tag-changes))\r
+ (unless (and beg end) (setq beg (point) end (point)))\r
+ (let ((search-string (notmuch-search-find-stable-query-region\r
+- beg end only-matched)))\r
++ beg end only-matched thread-list)))\r
+ (notmuch-tag search-string tag-changes)\r
+- (notmuch-search-foreach-result beg end\r
++ (notmuch-search-foreach-result beg end thread-list\r
+ (lambda ()\r
+ (notmuch-search-set-tags\r
+ (notmuch-update-tags (notmuch-search-get-tags) tag-changes))))))\r
+ \r
+-(defun notmuch-search-add-tag (tag-changes &optional beg end)\r
++(defun notmuch-search-add-tag (tag-changes &optional beg end thread-list)\r
+ "Change tags for the current thread or region (defaulting to add).\r
+ \r
+ Same as `notmuch-search-tag' but sets initial input to '+'."\r
+ (interactive (notmuch-search-interactive-tag-changes "+"))\r
+- (notmuch-search-tag tag-changes beg end))\r
++ (notmuch-search-tag tag-changes beg end nil thread-list))\r
+ \r
+-(defun notmuch-search-remove-tag (tag-changes &optional beg end)\r
++(defun notmuch-search-remove-tag (tag-changes &optional beg end thread-list)\r
+ "Change tags for the current thread or region (defaulting to remove).\r
+ \r
+ Same as `notmuch-search-tag' but sets initial input to '-'."\r
+ (interactive (notmuch-search-interactive-tag-changes "-"))\r
+- (notmuch-search-tag tag-changes beg end))\r
++ (notmuch-search-tag tag-changes beg end nil thread-list))\r
+ \r
+ (put 'notmuch-search-archive-thread 'notmuch-prefix-doc\r
+ "Un-archive the currently selected thread.")\r
+-(defun notmuch-search-archive-thread (&optional unarchive beg end)\r
++(defun notmuch-search-archive-thread (&optional unarchive beg end thread-list)\r
+ "Archive the currently selected thread or region.\r
+ \r
+ Archive each message in the currently selected thread by applying\r
+@@ -573,7 +583,7 @@ (defun notmuch-search-archive-thread (&optional unarchive beg end)\r
+ (interactive (cons current-prefix-arg (notmuch-search-interactive-region)))\r
+ (when notmuch-archive-tags\r
+ (notmuch-search-tag\r
+- (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end))\r
++ (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end thread-list))\r
+ (notmuch-search-next-thread))\r
+ \r
+ (defun notmuch-search-update-result (result &optional pos)\r
+-- \r
+1.7.10.4\r
+\r