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