From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3319B431FB6 for ; Wed, 22 Feb 2012 10:46:14 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 ZkkXxzZBlZ3l for ; Wed, 22 Feb 2012 10:46:12 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7E902431FD2 for ; Wed, 22 Feb 2012 10:45:59 -0800 (PST) Received: by mail-wi0-f181.google.com with SMTP id hi8so270670wib.26 for ; Wed, 22 Feb 2012 10:45:59 -0800 (PST) Received-SPF: pass (google.com: domain of pieter@praet.org designates 10.180.24.202 as permitted sender) client-ip=10.180.24.202; Authentication-Results: mr.google.com; spf=pass (google.com: domain of pieter@praet.org designates 10.180.24.202 as permitted sender) smtp.mail=pieter@praet.org Received: from mr.google.com ([10.180.24.202]) by 10.180.24.202 with SMTP id w10mr37952116wif.9.1329936359244 (num_hops = 1); Wed, 22 Feb 2012 10:45:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.180.24.202 with SMTP id w10mr31404498wif.9.1329936359162; Wed, 22 Feb 2012 10:45:59 -0800 (PST) Received: from localhost ([109.131.181.26]) by mx.google.com with ESMTPS id hs6sm40609002wib.2.2012.02.22.10.45.58 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Feb 2012 10:45:58 -0800 (PST) From: Pieter Praet To: Notmuch Mail Subject: [PATCH v2 6/7] emacs: make `notmuch-show-toggle-visibility-messages' live up to its new name Date: Wed, 22 Feb 2012 19:43:33 +0100 Message-Id: <1329936214-30959-6-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <1327469139-1968-1-git-send-email-pieter@praet.org> References: <1327469139-1968-1-git-send-email-pieter@praet.org> X-Gm-Message-State: ALoCoQkaA5ifvHffQjlGAqknyHBr56wpptXbG+nSmxTH03vyQJ2OrsVNEN982g+AQzQYjTYfi6G8 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, 22 Feb 2012 18:46:14 -0000 * emacs/notmuch-show.el (notmuch-show-toggle-visibility-messages): Toggle visibility of all messages in current thread based on visibility of the current message, instead of setting visibility based on whether or not a prefix arg was supplied. Also move current buffer line to the 2nd window line so the current message is put properly into focus, whilst making the presence of previous messages in the thread obvious. Same functionality, less effort (reaching for 'C-u' is a pain)... --- emacs/notmuch-show.el | 20 ++++++++++++-------- test/emacs | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index e4d1f9c..82d4265 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1669,15 +1669,19 @@ (defun notmuch-show-toggle-visibility-message () (force-window-update)) (defun notmuch-show-toggle-visibility-messages () - "Set the visibility all of the messages in the current thread. -By default make all of the messages visible. With a prefix -argument, hide all of the messages." + "Toggle the visibility of all messages in the current thread. +If the current message is visible, hide all messages -- and vice versa." (interactive) - (save-excursion - (goto-char (point-min)) - (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties) - (not current-prefix-arg)) - until (not (notmuch-show-goto-message-next)))) + (let ((visible-p (notmuch-show-message-visible-p))) + (notmuch-show-mapc + (lambda () (notmuch-show-message-visible + (notmuch-show-get-message-properties) + (not visible-p))))) + + ;; Put the current message properly into focus, but don't + ;; obscure the presence of previous messages in the thread. + (recenter-top-bottom 1) + (force-window-update)) (defun notmuch-show-next-button () diff --git a/test/emacs b/test/emacs index 29fdec0..5c61743 100755 --- a/test/emacs +++ b/test/emacs @@ -410,14 +410,14 @@ test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden test_begin_subtest "notmuch-show: collapse all messages in thread" test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com") - (let ((current-prefix-arg t)) - (notmuch-show-toggle-visibility-messages) - (test-visible-output))' + (notmuch-show-toggle-visibility-messages) + (test-visible-output)' test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed test_begin_subtest "notmuch-show: uncollapse all messages in thread" test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com") (notmuch-show-toggle-visibility-messages) + (notmuch-show-toggle-visibility-messages) (test-visible-output)' test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed -- 1.7.8.1