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 BD173431FBC for ; Sun, 22 Nov 2009 12:12:07 -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 k6pCVMZsbV1Y for ; Sun, 22 Nov 2009 12:12:07 -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 E64D2431FAE for ; Sun, 22 Nov 2009 12:12:06 -0800 (PST) Received: by bwz24 with SMTP id 24so3485864bwz.30 for ; Sun, 22 Nov 2009 12:12:06 -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; bh=Zks5lvj6FulQ71zLxZ8ec62bCqVfNS8Wm0ku2SDDnbk=; b=OBoGgorNZMjmQA7CuheeH/UhCsYV739+jAW031mVOpLZj8trJIpgPOsdF6Oh+gEJlR NGnP8ZO2IzaNUwIZTBubr4b1oTWfh4LGxZatmoV2tcsaA+ur8EdJGlARr1/YY5HNqRfl eEreHLCdkUlS/I/rjCJUjC/8S5/YZjqoNXO+o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=iT2BDU8BI5ZaLFYl2U9FXj/CJ/YfaVT0Tj/H5zNRBDqq9a+nF+onHKjS9AuFscu8vU K2NtI4c+YHt9c4l4qSKT3faThDHmydROm7+jN1aFhnGWarOC3oL9td7uy907CY67mBCa /Plue/jRQk0pLfquU+0sBxdJxfO/Rvjjb4ZjQ= Received: by 10.204.13.207 with SMTP id d15mr2776921bka.157.1258920726066; Sun, 22 Nov 2009 12:12:06 -0800 (PST) Received: from localhost.localdomain (vawpc43.ethz.ch [129.132.59.11]) by mx.google.com with ESMTPS id 21sm4687387fkx.25.2009.11.22.12.12.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 22 Nov 2009 12:12:05 -0800 (PST) Sender: Jed Brown From: Jed Brown To: notmuch@notmuchmail.org Date: Sun, 22 Nov 2009 21:12:16 +0100 Message-Id: <1258920736-14205-1-git-send-email-jed@59A2.org> X-Mailer: git-send-email 1.6.5.3 Subject: [notmuch] [PATCH] 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: Sun, 22 Nov 2009 20:12:07 -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 a547415..b848e9a 100644 --- a/notmuch.el +++ b/notmuch.el @@ -764,6 +764,7 @@ thread from that buffer can be show when done with this one)." (define-key map (kbd "RET") '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) @@ -940,6 +941,29 @@ This function advances point to the next line when finished." (notmuch-search-remove-tag "inbox") (forward-line)) +(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