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 88882431FC0 for ; Thu, 26 Nov 2009 13:36:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 AveR7evhbl0p for ; Thu, 26 Nov 2009 13:36:18 -0800 (PST) Received: from mail-bw0-f224.google.com (mail-bw0-f224.google.com [209.85.218.224]) by olra.theworths.org (Postfix) with ESMTP id 5D35F431FAE for ; Thu, 26 Nov 2009 13:36:18 -0800 (PST) Received: by bwz24 with SMTP id 24so847011bwz.30 for ; Thu, 26 Nov 2009 13:36:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=oCvftKjZw1bsgGzpI8mjNWcx/O904TObO3Ha1UyPHCk=; b=UBYmXrv/hpXuzRHBDvs1skcfZB1CBWer1ukr/R5FP7MzB4YuqeyojGrS5sR1HC3I/d 8erNMdtet5gCINdja2GHhsXCg2pDDRrUsVAWEbPuUAzJuQoHnmo0j6te3kh0dU9jspXy nRFLyPpwpEgye2Z9OkE3NFcoTA1IJ1ZjcrjP0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=tefcvDKDnI6dX3FivROryEFoLadNaJjRdNd5r/7hK9BeORqhNsw5I12fEdfzpq4T7z 1UHG4HKGosh3dNkc6BMxOoFkcA3gqLRLfCkxBPfLj04nxcJf1XSbzgkGtEJWSzlklpk1 FTWn3P11g/I0A43NAj3YmUQHsKRUpaGmR719k= Received: by 10.204.153.27 with SMTP id i27mr234492bkw.155.1259271377642; Thu, 26 Nov 2009 13:36:17 -0800 (PST) Received: from localhost.localdomain (vawpc43.ethz.ch [129.132.59.11]) by mx.google.com with ESMTPS id p9sm1421100fkb.14.2009.11.26.13.36.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Nov 2009 13:36:16 -0800 (PST) Sender: Jed Brown From: Jed Brown To: cworth@cworth.org Date: Thu, 26 Nov 2009 22:36:49 +0100 Message-Id: <1259271410-15336-1-git-send-email-jed@59A2.org> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <87pr75q9va.fsf@yoom.home.cworth.org> References: <87pr75q9va.fsf@yoom.home.cworth.org> Cc: notmuch@notmuchmail.org Subject: [notmuch] [PATCH 1/2] New function notmuch-search-operate-all: operate on all messages in the current query. X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Thu, 26 Nov 2009 21:36:19 -0000 It is often convenient to change tags on several messages at once. This function applies any number of tag whitespace-delimited tag modifications to all messages matching the current query. I have bound this to `*'. Signed-off-by: Jed Brown --- notmuch.el | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/notmuch.el b/notmuch.el index d7c973c..6adac9e 100644 --- a/notmuch.el +++ b/notmuch.el @@ -801,6 +801,7 @@ thread from that buffer can be show when done with this one)." (define-key map [mouse-1] 'notmuch-search-show-thread) (define-key map "+" 'notmuch-search-add-tag) (define-key map "-" 'notmuch-search-remove-tag) + (define-key map "*" 'notmuch-search-operate-all) (define-key map "<" 'beginning-of-buffer) (define-key map ">" 'notmuch-search-goto-last-thread) (define-key map "=" 'notmuch-search-refresh-view) @@ -1001,6 +1002,29 @@ This function advances point to the next line when finished." (set 'more nil)))))) (delete-process proc)))) +(defun notmuch-search-operate-all (action) + "Operate on all messages matching the current query. Any +number of whitespace separated actions can be given. Each action +must have one of the two forms + + +tagname Add the tag `tagname' + -tagname Remove the tag `tagname' + +Each character of the tag name may consist of alphanumeric +characters as well as `_.+-'. +" + (interactive "sOperation (+add -drop): notmuch tag ") + (let ((action-split (split-string action " +"))) + ;; Perform some validation + (let ((words action-split)) + (when (null words) (error "No operation given")) + (while words + (unless (string-match-p "^[\+\-][_\+\-\\w]+$" (car words)) + (error "Action must be of the form `+thistag -that_tag'")) + (setq words (cdr words)))) + (apply 'notmuch-call-notmuch-process "tag" + (append action-split (list notmuch-search-query-string) nil)))) + (defun notmuch-search (query &optional oldest-first) "Run \"notmuch search\" with the given query string and display results." (interactive "sNotmuch search: ") -- 1.6.5.3