Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 84 / cfc587e6b11d4955f67d38e66759a16f789990
1 Return-Path: <markwalters1009@gmail.com>\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 21E23429E3A\r
6         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 00:15:54 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id 8yM9gpdloElk for <notmuch@notmuchmail.org>;\r
18         Sat, 15 Dec 2012 00:15:52 -0800 (PST)\r
19 Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com\r
20  [74.125.82.41])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  327F9429E4A    for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 00:15:50 -0800\r
23  (PST)\r
24 Received: by mail-wg0-f41.google.com with SMTP id ds1so801517wgb.2\r
25         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 00:15:49 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=wcKKcv6nYPXtSESbGspela0cMSy37tkWY6KK9LLvN2o=;\r
29         b=Nom3zNvqvoliQQQhOFXou82YKvJOGZ4crlvAekuhNmlyP1xxjad0of2ZuQBkSN3qCD\r
30         yRGHnlZ/zrLzUqsHdo3tMQLVs3nk2AfUbo/ZQnCB3gDpkEGZ0dM6e/wFlVJPQfOGrn/C\r
31         hSJd6ymXNU20+6ASGoMuLQCuH/EIGrcd39k5wTbtgo1IYLa0R46+fFJxEB0I8dJEgdkz\r
32         Yxvpo8YKyUHqakULiI4ol7zw/kNivJSyaEcjgy4YFzdibAmnrIFieA4UyUk9+nF/DLkk\r
33         zmeYKd5zJZB03QcPiwQI8nUMLVgydukPkb/vwDU1NF+oq6hj/LUl18C0VJtOT/K31EG9\r
34         /daQ==\r
35 Received: by 10.194.110.231 with SMTP id id7mr7572375wjb.6.1355559349044;\r
36         Sat, 15 Dec 2012 00:15:49 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id eo10sm1136734wib.9.2012.12.15.00.15.47\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 15 Dec 2012 00:15:48 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v3 3/5] emacs: show: add invisibility button action\r
44 Date: Sat, 15 Dec 2012 08:15:35 +0000\r
45 Message-Id: <1355559338-14313-4-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1355559338-14313-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1355559338-14313-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 15 Dec 2012 08:15:54 -0000\r
62 \r
63 This adds a button action to show hidden parts. In this version "t"\r
64 toggles the visibility of a part. In addition "RET" on a non-shown\r
65 part shows it.\r
66 \r
67 The button is used to hide parts when appropriate (eg text/html in\r
68 multipart/alternative).\r
69 ---\r
70  emacs/notmuch-show.el |   35 +++++++++++++++++++++++++++++++++--\r
71  1 files changed, 33 insertions(+), 2 deletions(-)\r
72 \r
73 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
74 index b65c339..b11d65d 100644\r
75 --- a/emacs/notmuch-show.el\r
76 +++ b/emacs/notmuch-show.el\r
77 @@ -554,6 +554,28 @@ message at DEPTH in the current thread."\r
78      (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
79        (mm-pipe-part handle))))\r
80  \r
81 +;; This is taken from notmuch-wash: maybe it should be unified?\r
82 +(defun notmuch-show-toggle-part-invisibility (&optional button)\r
83 +  (interactive)\r
84 +  (let* ((button (or button (button-at (point))))\r
85 +        (overlay (button-get button 'overlay))\r
86 +        (invis-spec (button-get button 'invisibility-spec))\r
87 +        (show (invisible-p invis-spec)))\r
88 +    (when overlay\r
89 +      (if show\r
90 +         (remove-from-invisibility-spec invis-spec)\r
91 +       (add-to-invisibility-spec invis-spec))\r
92 +      (let* ((new-start (button-start button))\r
93 +            (button-label (button-get button :base-label))\r
94 +            (old-point (point))\r
95 +            (inhibit-read-only t))\r
96 +       (goto-char new-start)\r
97 +       (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
98 +       (let ((old-end (button-end button)))\r
99 +         (move-overlay button new-start (point))\r
100 +         (delete-region (point) old-end))\r
101 +       (goto-char (min old-point (1- (button-end button))))))))\r
102 +\r
103  (defun notmuch-show-multipart/*-to-list (part)\r
104    (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
105           (plist-get part :content)))\r
106 @@ -862,7 +884,13 @@ message at DEPTH in the current thread."\r
107                                (cons invis-spec (overlay-get inner 'invisible)))))\r
108  \r
109         (button-put button 'invisibility-spec invis-spec)\r
110 -       (button-put button 'overlay overlay)))))\r
111 +       (button-put button 'overlay overlay))\r
112 +\r
113 +      ;; We toggle the button for hidden parts as that gets the\r
114 +      ;; button label right.\r
115 +      (save-excursion\r
116 +       (when hide\r
117 +         (notmuch-show-toggle-part-invisibility button))))))\r
118  \r
119  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
120    "Insert the body part PART at depth DEPTH in the current thread.\r
121 @@ -1991,7 +2019,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
122  \r
123  (defun notmuch-show-part-button-default (&optional button)\r
124    (interactive)\r
125 -  (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))\r
126 +  (let ((button (or button (button-at (point)))))\r
127 +    (if (button-get button 'invisibility-spec)\r
128 +       (notmuch-show-toggle-part-invisibility button)\r
129 +      (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))))\r
130  \r
131  (defun notmuch-show-part-button-save (&optional button)\r
132    (interactive)\r
133 -- \r
134 1.7.9.1\r
135 \r