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 617CC431FAE for ; Fri, 9 Nov 2012 10:58:51 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, 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 wDtvGqpIRnNR for ; Fri, 9 Nov 2012 10:58:49 -0800 (PST) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 8BEE0431FDB for ; Fri, 9 Nov 2012 10:58:30 -0800 (PST) Received: by mail-wg0-f45.google.com with SMTP id dq12so2288423wgb.2 for ; Fri, 09 Nov 2012 10:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=u5ZMK8YMUY9tgKTvHW4BxuxSCRUop4jbSDlXwc001Jw=; b=vlKUq1tMuqheogDZ2k6jkKKMakfaMzi6cjzNWPIkkzYN//vAIN27zwHCD+8dBiC4zy e+eETPhBT1RnmywDF4rvC0K9THBle6V6XM8ZJ9xaq4Lf+AA+tssdlieigKUdz0mknvJA i6j2ldS72PceOe37L9YsPNazcXNearSGuPO7FMPHeWxeCSpifStce8zuO+i9uQGPbJqn z9LDVirFb7gt6AFdwCvquINdezOWEy/mdEq6JgaomWSt9HAavCzue+d1pZQU7vdbecAU TGuE+QWVSW1E56911xupGJLKWLhjuvorxI1fM3d4B5SqhNOuTHuC2fX4ycc7fNhJhA1e kO5Q== Received: by 10.180.84.202 with SMTP id b10mr4153807wiz.13.1352487510158; Fri, 09 Nov 2012 10:58:30 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id bn7sm3764993wib.8.2012.11.09.10.58.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Nov 2012 10:58:29 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH 3/3] emacs: make emacs use message-ids for tagging Date: Fri, 9 Nov 2012 18:58:11 +0000 Message-Id: <1352487491-31512-4-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com> References: <1352487491-31512-1-git-send-email-markwalters1009@gmail.com> 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: Fri, 09 Nov 2012 18:58:51 -0000 This makes emacs use the new --output=with-ids in search mode and use this for tagging. This fixes the race condition in tagging from search mode so mark the tests fixed. --- emacs/notmuch.el | 22 ++++++++++++++++++++-- test/emacs | 2 -- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index f9454d8..49a57b2 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -492,6 +492,21 @@ If BARE is set then do not prefix with \"thread:\"" "Return a search string for threads for the current region" (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")) +(defun notmuch-search-find-msg-ids-region (beg end &optional only-matching) + "Return a list of msg-ids for the current region" + (let ((msg-ids)) + (mapc (lambda (msg-id) (setq msg-ids (append msg-id msg-ids))) + (append (notmuch-search-properties-in-region :matching_msg_ids beg end) + (unless only-matching + (notmuch-search-properties-in-region :nonmatching_msg_ids beg end)))) + msg-ids)) + +(defun notmuch-search-find-msg-ids-region-search (beg end &optional only-matching) + "Return a search string for msg-ids in threads for the current region" + (mapconcat (lambda (id) (notmuch-id-to-query id)) + (notmuch-search-find-msg-ids-region beg end only-matching) + " or ")) + (defun notmuch-search-find-authors () "Return the authors for the current thread" (plist-get (notmuch-search-get-result) :authors)) @@ -566,7 +581,7 @@ and will also appear in a buffer named \"*Notmuch errors*\"." (defun notmuch-search-tag-region (beg end &optional tag-changes) "Change tags for threads in the given region." - (let ((search-string (notmuch-search-find-thread-id-region-search beg end))) + (let ((search-string (notmuch-search-find-msg-ids-region-search beg end))) (setq tag-changes (funcall 'notmuch-tag search-string tag-changes)) (notmuch-search-foreach-result beg end (lambda (pos) @@ -842,7 +857,9 @@ non-authors is found, assume that all of the authors match." See `notmuch-tag' for information on the format of TAG-CHANGES." (interactive) - (apply 'notmuch-tag notmuch-search-query-string tag-changes)) + (apply 'notmuch-tag (notmuch-search-find-msg-ids-region-search + (point-min) (point-max) t) + tag-changes)) (defun notmuch-search-buffer-title (query) "Returns the title for a buffer with notmuch search results." @@ -939,6 +956,7 @@ Other optional parameters are used as follows: "notmuch-search" buffer notmuch-command "search" "--format=json" + "--output=with-ids" (if oldest-first "--sort=oldest-first" "--sort=newest-first") diff --git a/test/emacs b/test/emacs index 6246177..4102198 100755 --- a/test/emacs +++ b/test/emacs @@ -123,7 +123,6 @@ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)" test_begin_subtest "Tag all matching messages from search view" -test_subtest_known_broken notmuch tag +test-tag-race from:cworth test_emacs "(notmuch-search \"tag:test-tag-race\") (notmuch-test-wait)" @@ -135,7 +134,6 @@ notmuch tag -test-tag-race '*' notmuch tag -test-tag-race-2 '*' test_begin_subtest "Change tags from search view: another message arriving after thread lookup" -test_subtest_known_broken typsos_id="878we4qdqf.fsf@yoom.home.cworth.org" typsos_thread=$(notmuch search --output=threads id:$typsos_id) test_emacs "(notmuch-search \"$typsos_thread\") -- 1.7.9.1