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 DED64431FAE for ; Wed, 2 Dec 2009 03:00:08 -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 06zMPaBY8vLU for ; Wed, 2 Dec 2009 03:00:08 -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 87611431FBC for ; Wed, 2 Dec 2009 03:00:08 -0800 (PST) Received: by bwz24 with SMTP id 24so58174bwz.30 for ; Wed, 02 Dec 2009 03:00: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:in-reply-to:references; bh=0AcfGDF0GFZRvMFHx+Tn5LmvY9dZr6hOkIKkwuFeXNI=; b=pvGRi30RFhv+Dk0IQb5kN7VnlZk2cNqPyo6LVal62jPNGBC+DJJubJxUxxErLlctCA Mrm+rPiIHVIkcWfcfDsxumsMSEgdP4VnYVC5Q0WXKUbHvQudLPA7bkLEWASez9B9yYLG QV1OPoL92IlnRmGQ64Nn7hKEeMlzEAs3C8dOM= 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=kHkCUeDJ2X/jH0/dnsf7SLeHrhV7xJ1AAmAGMWyiIcIbyLqMOWwFmEfNsvC9f1sLum ZZDEKcUnySEG2eJxPkRPaHnuOm+A2MtRFG02tVbwTmBPBoXzpv6Xz0vxmtEcnTbXnHEz 9Zc5J0HxGLKO9F2RB8F7mtUrYCzS5I2o/avRg= Received: by 10.204.151.194 with SMTP id d2mr3831764bkw.85.1259751606703; Wed, 02 Dec 2009 03:00:06 -0800 (PST) Received: from localhost.localdomain (vawpc43.ethz.ch [129.132.59.11]) by mx.google.com with ESMTPS id 21sm1280205fkx.25.2009.12.02.03.00.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 02 Dec 2009 03:00:05 -0800 (PST) Sender: Jed Brown From: Jed Brown To: cworth@cworth.org Date: Wed, 2 Dec 2009 12:00:35 +0100 Message-Id: <1259751635-7496-1-git-send-email-jed@59A2.org> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <87vdgp4p5e.fsf@59A2.org> References: <87vdgp4p5e.fsf@59A2.org> Cc: notmuch@notmuchmail.org Subject: [notmuch] [PATCH] Make search filters handle disjunctive queries. 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: Wed, 02 Dec 2009 11:00:09 -0000 notmuch-search-filter now accepts an arbitrary query and will group if necessary so that we get tag:inbox AND (gravy OR biscuits) instead of the former tag:inbox AND gravy OR biscuits Signed-off-by: Jed Brown --- notmuch.el | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/notmuch.el b/notmuch.el index 2509651..0bf82f5 100644 --- a/notmuch.el +++ b/notmuch.el @@ -995,6 +995,8 @@ thread from that buffer can be show when done with this one)." (defvar notmuch-search-oldest-first t "Show the oldest mail first in the search-mode") +(defvar notmuch-search-disjunctive-regexp "\\<[oO][rR]\\>") + (defun notmuch-search-scroll-up () "Move forward through search results by one window's worth." (interactive) @@ -1327,7 +1329,8 @@ search." Runs a new search matching only messages that match both the current search results AND the additional query string provided." (interactive "sFilter search: ") - (notmuch-search (concat notmuch-search-query-string " and " query) notmuch-search-oldest-first)) + (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query) (concat "( " query " )") query))) + (notmuch-search (concat notmuch-search-query-string " and " grouped-query) notmuch-search-oldest-first))) (defun notmuch-search-filter-by-tag (tag) "Filter the current search results based on a single tag. -- 1.6.5.3