compressing header lines - quick prototype
authorDavid Edmondson <dme@dme.org>
Wed, 18 Jan 2012 14:36:43 +0000 (14:36 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:35 +0000 (09:42 -0800)
a5/38740229de99d28a1e16834d9b1cc9dc70ba99 [new file with mode: 0644]

diff --git a/a5/38740229de99d28a1e16834d9b1cc9dc70ba99 b/a5/38740229de99d28a1e16834d9b1cc9dc70ba99
new file mode 100644 (file)
index 0000000..b7cb2af
--- /dev/null
@@ -0,0 +1,161 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 871C8431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:36:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id YBbxtD72qMS8 for <notmuch@notmuchmail.org>;\r
+       Wed, 18 Jan 2012 06:36:52 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id E0928431FAF\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:36:51 -0800 (PST)\r
+Received: by wibhr12 with SMTP id hr12so4470550wib.26\r
+       for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 06:36:50 -0800 (PST)\r
+Received: by 10.180.87.100 with SMTP id w4mr10921192wiz.13.1326897410568;\r
+       Wed, 18 Jan 2012 06:36:50 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+       (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+       by mx.google.com with ESMTPS id g12sm55719796wiw.10.2012.01.18.06.36.48\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Wed, 18 Jan 2012 06:36:49 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+       id 29620A1ADA; Wed, 18 Jan 2012 14:36:47 +0000 (GMT)\r
+To: notmuch <notmuch@notmuchmail.org>\r
+Subject: compressing header lines - quick prototype\r
+User-Agent: Notmuch/0.11+64~g42e8f66 (http://notmuchmail.org) Emacs/24.0.92.1\r
+       (x86_64-pc-linux-gnu)\r
+From: David Edmondson <dme@dme.org>\r
+Date: Wed, 18 Jan 2012 14:36:43 +0000\r
+Message-ID: <cun8vl5m610.fsf@hotblack-desiato.hh.sledj.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="==-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 18 Jan 2012 14:36:52 -0000\r
+\r
+--==-=-=\r
+Content-Type: multipart/mixed; boundary="=-=-="\r
+\r
+--=-=-=\r
+Content-Type: text/plain\r
+\r
+Here's something that I was playing with this morning. It's not\r
+finished, but has some nasty corners, so I'd like to solicit opinion on\r
+whether it's worth finishing.\r
+\r
+When faced with a long thread where most of the messages are closed, it\r
+might be convenient to hide large stretches of closed headers. This code\r
+attempts to do that.\r
+\r
+You can run `dme/notmuch-show-compress-headers' manually in a\r
+`notmuch-show-mode' buffer or (for the terminally brave) attach the same\r
+function to `notmuch-show-hook'.\r
+\r
+There are still problems with the nested invisibility specs and the\r
+current `notmuch-show-advance-and-archive' and friends get confused, but\r
+it should be enough for you to get the idea.\r
+\r
+After using it for a bit I came to the conclusion that it's not worth\r
+pursuing, but figured that I'd post it to get feedback from others.\r
+\r
+\r
+--=-=-=\r
+Content-Type: application/emacs-lisp\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+(defvar dme/notmuch-compress-header-count 10\r
+  "How long should a collapsed header sequence be before compression?")\r
+\r
+(define-button-type 'dme/notmuch-show-compress-headers-button-type\r
+  'help-echo "mount-1, RET: Show hidden header lines"b\r
+  'action 'dme/notmuch-show-compress-headers-action)\r
+\r
+(defun dme/notmuch-show-compress-headers-action (button)\r
+  (let ((overlay (button-get button 'overlay))\r
+       (buffer-read-only nil))\r
+    (remove-from-invisibility-spec (overlay-get overlay 'invisible))\r
+    (delete-region (button-start button) (button-end button))\r
+    (delete-overlay overlay)))\r
+\r
+(defun dme/notmuch-show-compress-headers ()\r
+  "Compress a sequence of `dme/notmuch-compress-header-count'\r
+collapsed header lines into a button that can be opened.\r
+\r
+Note that once opened it cannot be closed.\r
+\r
+The current `notmuch-show-advance-and-archive' and\r
+`notmuch-show-next-open-message' are very confused by the buttons\r
+created here - take care.\r
+\r
+Attach this to `notmuch-show-hook'."\r
+  (save-excursion\r
+    (goto-char (point-min))\r
+    (let ((count 0)\r
+         start)\r
+      (while (not (=3D (point-max) (notmuch-show-message-bottom)))\r
+       (if (notmuch-show-message-visible-p)\r
+           ;; See if there were enough non-visible to make it worth\r
+           ;; hiding them.\r
+           (if (> count dme/notmuch-compress-header-count)\r
+               (let ((invis-spec (make-symbol "notmuch-headerline-compression-region"))\r
+                     (buffer-read-only nil)\r
+                     overlay)\r
+                 ;; Never elide the first line.\r
+                 (if (eq start (point-min))\r
+                     (setq start (save-excursion\r
+                                   (goto-char (point-min))\r
+                                   (notmuch-show-goto-message-next)\r
+                                   (point))))\r
+\r
+                 (setq overlay (make-overlay start (point)))\r
+                 (overlay-put overlay 'invisible invis-spec)\r
+                 (add-to-invisibility-spec invis-spec)\r
+\r
+                 (insert-button "...more header lines...\n"\r
+                                'overlay overlay\r
+                                :type 'dme/notmuch-show-compress-headers-button-type)\r
+\r
+                 (setq count 0\r
+                       start nil)))\r
+         ;; Increment the count of non-visible headers and remember the\r
+         ;; starting point.\r
+         (setq count (1+ count))\r
+         (unless start\r
+           (setq start (point))))\r
+       (notmuch-show-goto-message-next)))))\r
+\r
+--=-=-=--\r
+\r
+--==-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.11 (GNU/Linux)\r
+\r
+iEYEARECAAYFAk8W2PsACgkQaezQq/BJZRYFdwCcCNEf6Gt0FFmA+8vUg6jWYH/N\r
+FhwAn3yOBDVPvGdThuXLaJfUuTCLBdSi\r
+=3srl\r
+-----END PGP SIGNATURE-----\r
+--==-=-=--\r