[PATCH 8/8] cli: optionally restore message properties from dump file
[notmuch-archives.git] / a5 / 38740229de99d28a1e16834d9b1cc9dc70ba99
1 Return-Path: <dme@dme.org>\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 871C8431FB6\r
6         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:36:52 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id YBbxtD72qMS8 for <notmuch@notmuchmail.org>;\r
16         Wed, 18 Jan 2012 06:36:52 -0800 (PST)\r
17 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
18         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id E0928431FAF\r
21         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:36:51 -0800 (PST)\r
22 Received: by wibhr12 with SMTP id hr12so4470550wib.26\r
23         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:36:50 -0800 (PST)\r
24 Received: by 10.180.87.100 with SMTP id w4mr10921192wiz.13.1326897410568;\r
25         Wed, 18 Jan 2012 06:36:50 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id g12sm55719796wiw.10.2012.01.18.06.36.48\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Wed, 18 Jan 2012 06:36:49 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id 29620A1ADA; Wed, 18 Jan 2012 14:36:47 +0000 (GMT)\r
33 To: notmuch <notmuch@notmuchmail.org>\r
34 Subject: compressing header lines - quick prototype\r
35 User-Agent: Notmuch/0.11+64~g42e8f66 (http://notmuchmail.org) Emacs/24.0.92.1\r
36         (x86_64-pc-linux-gnu)\r
37 From: David Edmondson <dme@dme.org>\r
38 Date: Wed, 18 Jan 2012 14:36:43 +0000\r
39 Message-ID: <cun8vl5m610.fsf@hotblack-desiato.hh.sledj.net>\r
40 MIME-Version: 1.0\r
41 Content-Type: multipart/signed; boundary="==-=-=";\r
42         micalg=pgp-sha1; protocol="application/pgp-signature"\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\r
46 List-Id: "Use and development of the notmuch mail system."\r
47         <notmuch.notmuchmail.org>\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
51 List-Post: <mailto:notmuch@notmuchmail.org>\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
55 X-List-Received-Date: Wed, 18 Jan 2012 14:36:52 -0000\r
56 \r
57 --==-=-=\r
58 Content-Type: multipart/mixed; boundary="=-=-="\r
59 \r
60 --=-=-=\r
61 Content-Type: text/plain\r
62 \r
63 Here's something that I was playing with this morning. It's not\r
64 finished, but has some nasty corners, so I'd like to solicit opinion on\r
65 whether it's worth finishing.\r
66 \r
67 When faced with a long thread where most of the messages are closed, it\r
68 might be convenient to hide large stretches of closed headers. This code\r
69 attempts to do that.\r
70 \r
71 You can run `dme/notmuch-show-compress-headers' manually in a\r
72 `notmuch-show-mode' buffer or (for the terminally brave) attach the same\r
73 function to `notmuch-show-hook'.\r
74 \r
75 There are still problems with the nested invisibility specs and the\r
76 current `notmuch-show-advance-and-archive' and friends get confused, but\r
77 it should be enough for you to get the idea.\r
78 \r
79 After using it for a bit I came to the conclusion that it's not worth\r
80 pursuing, but figured that I'd post it to get feedback from others.\r
81 \r
82 \r
83 --=-=-=\r
84 Content-Type: application/emacs-lisp\r
85 Content-Disposition: inline\r
86 Content-Transfer-Encoding: quoted-printable\r
87 \r
88 (defvar dme/notmuch-compress-header-count 10\r
89   "How long should a collapsed header sequence be before compression?")\r
90 \r
91 (define-button-type 'dme/notmuch-show-compress-headers-button-type\r
92   'help-echo "mount-1, RET: Show hidden header lines"b\r
93   'action 'dme/notmuch-show-compress-headers-action)\r
94 \r
95 (defun dme/notmuch-show-compress-headers-action (button)\r
96   (let ((overlay (button-get button 'overlay))\r
97         (buffer-read-only nil))\r
98     (remove-from-invisibility-spec (overlay-get overlay 'invisible))\r
99     (delete-region (button-start button) (button-end button))\r
100     (delete-overlay overlay)))\r
101 \r
102 (defun dme/notmuch-show-compress-headers ()\r
103   "Compress a sequence of `dme/notmuch-compress-header-count'\r
104 collapsed header lines into a button that can be opened.\r
105 \r
106 Note that once opened it cannot be closed.\r
107 \r
108 The current `notmuch-show-advance-and-archive' and\r
109 `notmuch-show-next-open-message' are very confused by the buttons\r
110 created here - take care.\r
111 \r
112 Attach this to `notmuch-show-hook'."\r
113   (save-excursion\r
114     (goto-char (point-min))\r
115     (let ((count 0)\r
116           start)\r
117       (while (not (=3D (point-max) (notmuch-show-message-bottom)))\r
118         (if (notmuch-show-message-visible-p)\r
119             ;; See if there were enough non-visible to make it worth\r
120             ;; hiding them.\r
121             (if (> count dme/notmuch-compress-header-count)\r
122                 (let ((invis-spec (make-symbol "notmuch-headerline-compression-region"))\r
123                       (buffer-read-only nil)\r
124                       overlay)\r
125                   ;; Never elide the first line.\r
126                   (if (eq start (point-min))\r
127                       (setq start (save-excursion\r
128                                     (goto-char (point-min))\r
129                                     (notmuch-show-goto-message-next)\r
130                                     (point))))\r
131 \r
132                   (setq overlay (make-overlay start (point)))\r
133                   (overlay-put overlay 'invisible invis-spec)\r
134                   (add-to-invisibility-spec invis-spec)\r
135 \r
136                   (insert-button "...more header lines...\n"\r
137                                  'overlay overlay\r
138                                  :type 'dme/notmuch-show-compress-headers-button-type)\r
139 \r
140                   (setq count 0\r
141                         start nil)))\r
142           ;; Increment the count of non-visible headers and remember the\r
143           ;; starting point.\r
144           (setq count (1+ count))\r
145           (unless start\r
146             (setq start (point))))\r
147         (notmuch-show-goto-message-next)))))\r
148 \r
149 --=-=-=--\r
150 \r
151 --==-=-=\r
152 Content-Type: application/pgp-signature\r
153 \r
154 -----BEGIN PGP SIGNATURE-----\r
155 Version: GnuPG v1.4.11 (GNU/Linux)\r
156 \r
157 iEYEARECAAYFAk8W2PsACgkQaezQq/BJZRYFdwCcCNEf6Gt0FFmA+8vUg6jWYH/N\r
158 FhwAn3yOBDVPvGdThuXLaJfUuTCLBdSi\r
159 =3srl\r
160 -----END PGP SIGNATURE-----\r
161 --==-=-=--\r