[notmuch] [PATCH 2/3] notmuch.el: Add collapse all and expand all to notmuch-show
[notmuch-archives.git] / 4a / 161f92ad16b5d4742819f155b280adea0ccaa5
1 Return-Path: <kanru@anar.kanru.info>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 7BA7E431FBD\r
6         for <notmuch@notmuchmail.org>; Mon, 30 Nov 2009 22:18:27 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id hqs0cgh-UDPs for <notmuch@notmuchmail.org>;\r
11         Mon, 30 Nov 2009 22:18:26 -0800 (PST)\r
12 Received: from msr12.hinet.net (msr12.hinet.net [168.95.4.112])\r
13         by olra.theworths.org (Postfix) with ESMTP id 137BF431FBC\r
14         for <notmuch@notmuchmail.org>; Mon, 30 Nov 2009 22:18:25 -0800 (PST)\r
15 Received: from anar.kanru.info ([203.74.21.24])\r
16         by msr12.hinet.net (8.9.3/8.9.3) with ESMTP id OAA00265\r
17         for <notmuch@notmuchmail.org>; Tue, 1 Dec 2009 14:18:22 +0800 (CST)\r
18 Received: from kanru (uid 1000) (envelope-from kanru@anar.kanru.info) id 1da0\r
19         by anar.kanru.info (DragonFly Mail Agent)\r
20         Tue, 01 Dec 2009 14:18:04 +0800\r
21 From: Kan-Ru Chen <kanru@kanru.info>\r
22 To: notmuch@notmuchmail.org\r
23 Date: Tue,  1 Dec 2009 14:17:32 +0800\r
24 Message-Id: <1259648253-31034-2-git-send-email-kanru@kanru.info>\r
25 X-Mailer: git-send-email 1.6.5.3\r
26 In-Reply-To: <1259648033-30653-1-git-send-email-kanru@kanru.info>\r
27 References: <1259648033-30653-1-git-send-email-kanru@kanru.info>\r
28 Subject: [notmuch] [PATCH 2/3] notmuch.el: Add collapse all and expand all\r
29         to notmuch-show\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.12\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34         <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
36         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Tue, 01 Dec 2009 06:18:27 -0000\r
43 \r
44 These two functions behave like gmail's collapse all and expand all\r
45 commands. notmuch-show-collapse-all is bound to 'B' but\r
46 notmuch-show-expand-all has no keybindig because I thought it is not often\r
47 used.\r
48 \r
49 Signed-off-by: Kan-Ru Chen <kanru@kanru.info>\r
50 ---\r
51  notmuch.el |   25 +++++++++++++++++++++++++\r
52  1 files changed, 25 insertions(+), 0 deletions(-)\r
53 \r
54 diff --git a/notmuch.el b/notmuch.el\r
55 index 2526020..5b8513c 100644\r
56 --- a/notmuch.el\r
57 +++ b/notmuch.el\r
58 @@ -63,6 +63,7 @@\r
59      (define-key map "a" 'notmuch-show-archive-thread)\r
60      (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)\r
61      (define-key map "b" 'notmuch-show-toggle-current-body)\r
62 +    (define-key map "B" 'notmuch-show-collapse-all)\r
63      (define-key map "f" 'notmuch-show-forward-current)\r
64      (define-key map "h" 'notmuch-show-toggle-current-header)\r
65      (define-key map "m" 'message-mail)\r
66 @@ -582,6 +583,30 @@ which this thread was originally shown."\r
67      (push-button))\r
68    )\r
69  \r
70 +(defun notmuch-show-collapse-all ()\r
71 +  (interactive)\r
72 +  (save-excursion\r
73 +    (beginning-of-buffer)\r
74 +    (while (not (notmuch-show-last-message-p))\r
75 +      (unless (button-at (point))\r
76 +        (notmuch-show-next-button))\r
77 +      (let ((invis-spec (button-get (button-at (point)) 'invisibility-spec)))\r
78 +        (add-to-invisibility-spec invis-spec))\r
79 +      (notmuch-show-next-open-message)\r
80 +      )))\r
81 +\r
82 +(defun notmuch-show-expand-all ()\r
83 +  (interactive)\r
84 +  (save-excursion\r
85 +    (beginning-of-buffer)\r
86 +    (while (not (notmuch-show-last-message-p))\r
87 +      (unless (button-at (point))\r
88 +        (notmuch-show-next-button))\r
89 +      (let ((invis-spec (button-get (button-at (point)) 'invisibility-spec)))\r
90 +        (remove-from-invisibility-spec invis-spec))\r
91 +      (notmuch-show-next-message)\r
92 +      )))\r
93 +\r
94  (define-button-type 'notmuch-button-invisibility-toggle-type 'action 'notmuch-toggle-invisible-action 'follow-link t)\r
95  (define-button-type 'notmuch-button-citation-toggle-type 'help-echo "mouse-1, RET: Show citation"\r
96    :supertype 'notmuch-button-invisibility-toggle-type)\r
97 -- \r
98 1.6.5.3\r
99 \r