--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id D2335431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 1 Mar 2012 14:29:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id InBP-QeCsMPo for <notmuch@notmuchmail.org>;\r
+ Thu, 1 Mar 2012 14:29:51 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id D4729431FDA\r
+ for <notmuch@notmuchmail.org>; Thu, 1 Mar 2012 14:29:48 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id m13so775491wer.26\r
+ for <notmuch@notmuchmail.org>; Thu, 01 Mar 2012 14:29:48 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
+ 10.180.82.227 as permitted sender) client-ip=10.180.82.227; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+ markwalters1009@gmail.com designates 10.180.82.227 as permitted\r
+ sender) smtp.mail=markwalters1009@gmail.com;\r
+ dkim=pass header.i=markwalters1009@gmail.com\r
+Received: from mr.google.com ([10.180.82.227])\r
+ by 10.180.82.227 with SMTP id l3mr15012262wiy.1.1330640988710 (num_hops\r
+ = 1); Thu, 01 Mar 2012 14:29:48 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=HXooxiQR2Gh1c1aSByOtrG10GZvrOkR/KUAglx4PYE4=;\r
+ b=1CbucXD5M2KNUvdNENFKsvLvopkanCHPQhKfhdJcbt1GIhXwAuiBey4N/iqugRgMnx\r
+ +8umxqL3lqjK1S8MvgsGWu2hLv/5LYt5R4TfxIFN7KVUXOpmbdMJHj/r5f2ZUCJjwDSk\r
+ Vrrd2NYPx3LMFXkDkba2QP9tb9FeRBLB6svbOiru2YBMjC2gRdFmnxOkXkG9pjyUvh6a\r
+ GQYo8XyCeNEL4I+Vf3mLeEVzbEA3nOrniHi2PetZyfPCngGICMcSlaZAjHPYP6HZKdh+\r
+ G2p3/Ybpgaa7gHwKhu9xtIvIUQCeKzlbpo9l626McA9ALhSny/oC0e9PeUX1VXvaZEUK\r
+ qs+g==\r
+Received: by 10.180.82.227 with SMTP id l3mr12054064wiy.1.1330640988659;\r
+ Thu, 01 Mar 2012 14:29:48 -0800 (PST)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223]) by mx.google.com with ESMTPS id\r
+ h19sm44658185wiw.9.2012.03.01.14.29.46 (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Thu, 01 Mar 2012 14:29:47 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v7 12/13] emacs: show: recognize the exclude flag.\r
+Date: Thu, 1 Mar 2012 22:30:44 +0000\r
+Message-Id: <1330641045-27416-13-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.2.3\r
+In-Reply-To: <1330641045-27416-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1330641045-27416-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 01 Mar 2012 22:29:53 -0000\r
+\r
+Show mode will recognize the exclude flag by not opening excluding\r
+messages by default, and will start at the first matching non-excluded\r
+message. If there are no matching non-excluded messages it will go to\r
+the first matching (necessarily excluded) message.\r
+---\r
+ emacs/notmuch-show.el | 36 +++++++++++++++++++++++++++---------\r
+ 1 files changed, 27 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 7c4c0be..4a60631 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -981,7 +981,8 @@ current buffer, if possible."\r
+ \r
+ ;; Message visibility depends on whether it matched the search\r
+ ;; criteria.\r
+- (notmuch-show-message-visible msg (plist-get msg :match))))\r
++ (notmuch-show-message-visible msg (and (plist-get msg :match)\r
++ (not (plist-get msg :excluded))))))\r
+ \r
+ (defun notmuch-show-toggle-process-crypto ()\r
+ "Toggle the processing of cryptographic MIME parts."\r
+@@ -1081,11 +1082,7 @@ function is used."\r
+ notmuch-show-parent-buffer parent-buffer\r
+ notmuch-show-query-context query-context)\r
+ (notmuch-show-build-buffer)\r
+-\r
+- ;; Move to the first open message and mark it read\r
+- (if (notmuch-show-message-visible-p)\r
+- (notmuch-show-mark-read)\r
+- (notmuch-show-next-open-message))))\r
++ (notmuch-show-goto-first-wanted-message)))\r
+ \r
+ (defun notmuch-show-build-buffer ()\r
+ (let ((inhibit-read-only t))\r
+@@ -1167,9 +1164,7 @@ reset based on the original query."\r
+ (notmuch-show-apply-state state)\r
+ ;; We're resetting state, so navigate to the first open message\r
+ ;; and mark it read, just like opening a new show buffer.\r
+- (if (notmuch-show-message-visible-p)\r
+- (notmuch-show-mark-read)\r
+- (notmuch-show-next-open-message)))))\r
++ (notmuch-show-goto-first-wanted-message))))\r
+ \r
+ (defvar notmuch-show-stash-map\r
+ (let ((map (make-sparse-keymap)))\r
+@@ -1601,6 +1596,29 @@ to show, nil otherwise."\r
+ (goto-char (point-max))))\r
+ r))\r
+ \r
++(defun notmuch-show-next-matching-message ()\r
++ "Show the next matching message."\r
++ (interactive)\r
++ (let (r)\r
++ (while (and (setq r (notmuch-show-goto-message-next))\r
++ (not (notmuch-show-get-prop :match))))\r
++ (if r\r
++ (progn\r
++ (notmuch-show-mark-read)\r
++ (notmuch-show-message-adjust))\r
++ (goto-char (point-max)))))\r
++\r
++(defun notmuch-show-goto-first-wanted-message ()\r
++ "Move to the first open message and mark it read"\r
++ (goto-char (point-min))\r
++ (if (notmuch-show-message-visible-p)\r
++ (notmuch-show-mark-read)\r
++ (notmuch-show-next-open-message))\r
++ (when (eobp)\r
++ (goto-char (point-min))\r
++ (unless (notmuch-show-get-prop :match)\r
++ (notmuch-show-next-matching-message))))\r
++\r
+ (defun notmuch-show-previous-open-message ()\r
+ "Show the previous open message."\r
+ (interactive)\r
+-- \r
+1.7.2.3\r
+\r