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 9EE65429E3D for ; Wed, 25 May 2011 15:10:30 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.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 h8Iumt2vjYr7 for ; Wed, 25 May 2011 15:10:29 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 137B4429E44 for ; Wed, 25 May 2011 15:10:24 -0700 (PDT) Received: by mail-fx0-f53.google.com with SMTP id 8so217139fxm.26 for ; Wed, 25 May 2011 15:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=7PGK3epIXMCCuCcfGgt9UJZt88pE4ZDA1Fb6TWufGFc=; b=B1AUaDAQsEp+pFw6r+d9IICIFnyBdxwNccwRE+NuZMqkIe1rl96nL9juVbfGoiSxe/ Hf9hGTlrdKpiJwU8bskUcUg2/+3uZfMJXhrp3758R5VMDDAr+biYDP7FwNaJ6xoQpOAP XtLnx+WEiCZZIuAZolSvq/H57Jv3xQx6Pto5k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=UXNf/7Jf0NOldeqzYEN7guJlI4E2vmsglajVrgGc/ZXJvYlcqO+m9VmNTtac/suBkr lmTuzNxwVcX+2PQr0uRalJV0GopblRUA9vrxgXV6wT7pxOLBiicKQ2Zw14TRX9GfCene ms8wY9p4BWFa3v5H/ovFHohbvam/dYiLqPhE4= Received: by 10.223.57.5 with SMTP id a5mr106251fah.90.1306361424751; Wed, 25 May 2011 15:10:24 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id b25sm31705fab.4.2011.05.25.15.10.23 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 15:10:24 -0700 (PDT) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH 5/5] Simplify message and headers visibility code in notmuch-show view. Date: Thu, 26 May 2011 02:10:16 +0400 Message-Id: <1306361416-5019-6-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1306361416-5019-1-git-send-email-dmitry.kurochkin@gmail.com> References: <1306361416-5019-1-git-send-email-dmitry.kurochkin@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: Wed, 25 May 2011 22:10:30 -0000 Before the change, headers and message visibility functions took extra care to correctly set `buffer-invisibility-spec'. This was needed because headers overlay `invisible' property had only headers' invisibility spec. So visibility of headers was determined only by the headers invisibility spec. The patch sets headers overlay `invisible' property a list with both the headers and the message invisibility spec. This makes headers invisible if either of them is added to the `buffer-invisibility-spec' and allows to simplify the code. --- emacs/notmuch-show.el | 18 +++++------------- 1 files changed, 5 insertions(+), 13 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index e1846bc..2f7154e 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -733,8 +733,9 @@ current buffer, if possible." ;; message. (put-text-property message-start message-end :notmuch-message-extent (cons message-start message-end)) - (let ((headers-overlay (make-overlay headers-start headers-end))) - (overlay-put headers-overlay 'invisible headers-invis-spec) + (let ((headers-overlay (make-overlay headers-start headers-end)) + (invis-specs (list headers-invis-spec message-invis-spec))) + (overlay-put headers-overlay 'invisible invis-specs) (overlay-put headers-overlay 'priority 10)) (overlay-put (make-overlay body-start body-end) 'invisible message-invis-spec) @@ -974,20 +975,11 @@ All currently available key bindings: (add-to-invisibility-spec spec)))) (defun notmuch-show-message-visible (props visible-p) - (if visible-p - ;; When making the message visible, the headers may or not be - ;; visible. So we check that property separately. - (let ((headers-visible (plist-get props :headers-visible))) - (notmuch-show-element-visible props headers-visible :headers-invis-spec) - (notmuch-show-element-visible props t :message-invis-spec)) - (notmuch-show-element-visible props nil :headers-invis-spec) - (notmuch-show-element-visible props nil :message-invis-spec)) - + (notmuch-show-element-visible props visible-p :message-invis-spec) (notmuch-show-set-prop :message-visible visible-p props)) (defun notmuch-show-headers-visible (props visible-p) - (if (plist-get props :message-visible) - (notmuch-show-element-visible props visible-p :headers-invis-spec)) + (notmuch-show-element-visible props visible-p :headers-invis-spec) (notmuch-show-set-prop :headers-visible visible-p props)) ;; Functions for setting and getting attributes of the current -- 1.7.5.1