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 57E76429E54 for ; Tue, 28 Jun 2011 00:31:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 DVe3kOvsNGWy for ; Tue, 28 Jun 2011 00:31:52 -0700 (PDT) Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.216.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D3A82429E4E for ; Tue, 28 Jun 2011 00:31:51 -0700 (PDT) Received: by qyk29 with SMTP id 29so2024996qyk.5 for ; Tue, 28 Jun 2011 00:31:51 -0700 (PDT) Received: by 10.229.107.21 with SMTP id z21mr5352869qco.187.1309246311042; Tue, 28 Jun 2011 00:31:51 -0700 (PDT) Received: from localhost (nikula.org [92.243.24.172]) by mx.google.com with ESMTPS id l36sm4283398qck.31.2011.06.28.00.31.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Jun 2011 00:31:50 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches Date: Tue, 28 Jun 2011 07:31:31 +0000 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Tue, 28 Jun 2011 10:59:27 -0700 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: Tue, 28 Jun 2011 07:31:52 -0000 Add a pseudo saved search that matches all the mail that no other saved search matches. Add new customization option notmuch-saved-searches-nomatch to enable and name the pseudo saved search. --- emacs/notmuch-hello.el | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 84bce3a..b9c9b01 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -47,6 +47,12 @@ :type 'boolean :group 'notmuch) +(defcustom notmuch-saved-searches-nomatch nil + "Name of the pseudo saved search that no other saved search matches." + :type '(choice (const :tag "Off" nil) + string) + :group 'notmuch) + (defvar notmuch-hello-indent 4 "How much to indent non-headers.") @@ -363,6 +369,22 @@ Complete list of currently available key bindings: (not (member tag notmuch-hello-hide-tags))) (process-lines notmuch-command "search-tags"))))) +(defun notmuch-hello-saved-alist () + (if notmuch-saved-searches + (let ((saved-alist notmuch-saved-searches)) + (when notmuch-saved-searches-nomatch + ;; Append the no-match search. + (add-to-list 'saved-alist + (cons notmuch-saved-searches-nomatch + (mapconcat (lambda (arg) (concat "(not (" (cdr arg) "))")) notmuch-saved-searches " and ")) t)) + ;; Filter out empty saved searches if required. + (if notmuch-show-empty-saved-searches + saved-alist + (loop for elem in saved-alist + if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0) + collect elem))) + notmuch-saved-searches)) + ;;;###autoload (defun notmuch-hello (&optional no-display) "Run notmuch and display saved searches, known tags, etc." @@ -433,13 +455,7 @@ Complete list of currently available key bindings: (let ((found-target-pos nil) (final-target-pos nil)) - (let* ((saved-alist - ;; Filter out empty saved searches if required. - (if notmuch-show-empty-saved-searches - notmuch-saved-searches - (loop for elem in notmuch-saved-searches - if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0) - collect elem))) + (let* ((saved-alist (notmuch-hello-saved-alist)) (saved-widest (notmuch-hello-longest-label saved-alist)) (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generate-tag-alist))) (alltags-widest (notmuch-hello-longest-label alltags-alist)) -- 1.7.1