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 DC872431FAE for ; Thu, 15 Mar 2012 11:28:19 -0700 (PDT) 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 LR3fzRkPyQSg for ; Thu, 15 Mar 2012 11:28:19 -0700 (PDT) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 14EFF431FAF for ; Thu, 15 Mar 2012 11:28:18 -0700 (PDT) Received: by werm13 with SMTP id m13so3512908wer.26 for ; Thu, 15 Mar 2012 11:28:16 -0700 (PDT) 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; bh=ZEPP1+niIQ4CJ44ok4YueUD5ZDfMP4iyucZnDm7AhDU=; b=AHBnfzTIH89Nkxinx5pzg/NhTXLvirY2FEPOVculQvS0LqIN36msUBx8Hod7YQKVx5 xrX/Hh5lJNdC+TPDt8BL/BCis0t1qYirGpgP585fvPruz+EB0Mi+Ti+QCK1xCKLiyWwx MFqLW2Bjv/8RvMAKKChqbMSQNyVIP8lPlLg2Gd0G6Yh5LdQu48BhjveMosmCIYpjE8zU ZZfYYwzw5pbaeGHNb6e2fRpnu4IfGMWZJktoX4FzlPhOLPFJFmCpmtvTjx4uh4EV8+ix ri21n2w97LMHGwoylTLuvMWA2pZHBlK0EOzQkTic44Zmim8xORyioiGGE+SruzU1kdtT nWZw== Received: by 10.180.8.164 with SMTP id s4mr18094797wia.6.1331836096383; Thu, 15 Mar 2012 11:28:16 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id gg2sm11262494wib.7.2012.03.15.11.28.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Mar 2012 11:28:15 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH] emacs-show: open excluded matches if no other matches Date: Thu, 15 Mar 2012 18:28:10 +0000 Message-Id: <1331836090-30560-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 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: Thu, 15 Mar 2012 18:28:20 -0000 Currently emacs show does not open matching but excluded messages. This is normally the desired behaviour but is probably not ideal if only excluded messages match. This patch opens all the matching (necessarily excluded) messages in this case and goes to the first one. --- emacs/notmuch-show.el | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 4a60631..bd4ba0f 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1608,6 +1608,11 @@ to show, nil otherwise." (notmuch-show-message-adjust)) (goto-char (point-max))))) +(defun notmuch-show-open-if-matched () + "Open a message if it is matched (whether or not excluded)." + (let ((props (notmuch-show-get-message-properties))) + (notmuch-show-message-visible props (plist-get props :match)))) + (defun notmuch-show-goto-first-wanted-message () "Move to the first open message and mark it read" (goto-char (point-min)) @@ -1615,9 +1620,14 @@ to show, nil otherwise." (notmuch-show-mark-read) (notmuch-show-next-open-message)) (when (eobp) + ;; There are no matched non-excluded messages so open all matched + ;; (necessarily excluded) messages and go to the first. + (notmuch-show-mapc 'notmuch-show-open-if-matched) + (force-window-update) (goto-char (point-min)) - (unless (notmuch-show-get-prop :match) - (notmuch-show-next-matching-message)))) + (if (notmuch-show-message-visible-p) + (notmuch-show-mark-read) + (notmuch-show-next-open-message)))) (defun notmuch-show-previous-open-message () "Show the previous open message." -- 1.7.9.1