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 12DB3431FD0 for ; Sun, 1 Dec 2013 02:08:13 -0800 (PST) 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 RhPoRkrR3NQE for ; Sun, 1 Dec 2013 02:08:05 -0800 (PST) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 509BB431FAF for ; Sun, 1 Dec 2013 02:08:05 -0800 (PST) Received: by mail-wi0-f171.google.com with SMTP id ca18so3552693wib.16 for ; Sun, 01 Dec 2013 02:08:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zdf/5A4SfScuQ7KaCvHjj0o5xJXio+s4Z7Ht9mWOeNo=; b=UpzqM84dLsBXKgehGvy9XF1jeecQ/GeFNdrRrqi+ugdMuV9QVgtR7PA/MoTOqbVZM0 cOtkxk7cXH3KMcADDjnc+wSLImu4+N/rdZ7wZdSd+DPGC8Yhujap7xjletYJ4w0olbCC 9wC4/CdHIEOLaQRIUSBwagmaaVJbtQ+ZAz38cqmZ/7+fiRJu5n4wMqcgOP9RdOfWLyBx 9+pWU3Gxk9kLDd9cHVJFAOFKNOPJiJuCTxdsHMw1sFTA+Yjyt2sIepROeYy9feSvviIz iTjnEGqY1AdUmJosokSoxPUhf2783tN6ujwoldiNL5QwwnX3WdLjoe2e2Y+ZAUEoEsj3 Sk8A== X-Received: by 10.180.107.193 with SMTP id he1mr13655896wib.50.1385892152410; Sun, 01 Dec 2013 02:02:32 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id e10sm88736579wiy.7.2013.12.01.02.02.31 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 02:02:31 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH WIP v2 1/6] emacs: show: add a function to test for unread Date: Sun, 1 Dec 2013 10:02:22 +0000 Message-Id: <1385892147-16994-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1385892147-16994-1-git-send-email-markwalters1009@gmail.com> References: <1385892147-16994-1-git-send-email-markwalters1009@gmail.com> 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: Sun, 01 Dec 2013 10:08:13 -0000 This adds a function which tests for unread. A message is deemed unread if applying `notmuch-show-mark-read-tags' would change the message's tags. --- emacs/notmuch-show.el | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 784644c..a135e79 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1510,6 +1510,17 @@ current thread." "Are the headers of the current message visible?" (notmuch-show-get-prop :headers-visible)) +(defun notmuch-show-unread-p () + "Return t if current message is unread. + +Returns t unless applying `notmuch-show-mark-read-tags' would be +a no-op" + (when notmuch-show-mark-read-tags + (let* ((current-tags (notmuch-show-get-tags)) + (tag-changes (notmuch-tag-change-list notmuch-show-mark-read-tags)) + (new-tags (notmuch-update-tags current-tags tag-changes))) + (not (equal current-tags new-tags))))) + (put 'notmuch-show-mark-read 'notmuch-prefix-doc "Mark the current message as unread.") (defun notmuch-show-mark-read (&optional unread) -- 1.7.9.1