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 21761431FC9
\r
6 for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 00:01:14 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id yZvfCLMXopdh for <notmuch@notmuchmail.org>;
\r
17 Fri, 31 Oct 2014 00:01:06 -0700 (PDT)
\r
18 Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com
\r
19 [74.125.82.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
20 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
21 69C72431FC2 for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 00:01:06 -0700
\r
23 Received: by mail-wg0-f50.google.com with SMTP id z12so5777796wgg.23
\r
24 for <notmuch@notmuchmail.org>; Fri, 31 Oct 2014 00:01:02 -0700 (PDT)
\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
26 d=1e100.net; s=20130820;
\r
27 h=x-gm-message-state:to:subject:in-reply-to:references:user-agent
\r
28 :from:date:message-id:mime-version:content-type;
\r
29 bh=YKyBdwCkqVFbwz9RANAMLYFjUhNBx3Ei4YfzhB1p9jQ=;
\r
30 b=HZpm+iUR3i2BLXW60YoQwU0LHWjF6HJ5CGERvfQRFrUws4F7ZZGULwHUFw9yySpvsT
\r
31 rBm1o0FgB3fc6G3ZM2pLlXOrpBgYLiJ25/9g0DoV6Hu3HHxTZjZIG/ncNenu7g1W2QYI
\r
32 lvW9/3DK5Qv2Uh64QQrq6LLVfzyHpoMuCcwsEjSrar+vAta12LR7Ekd+0KHCIQDOIi9R
\r
33 uRtWD4sOXCYL/pt7DtxhJpocUir772QDBeVed1bPUtQ105PFV5aOYpVcZdATie6d9Ppp
\r
34 zqqvta1VT4m8Ho3hT7lWTMU5RcsyD/SjckzGYTl7W6Qc+CM4aFVxPKqDLCffO83eDY3U
\r
37 ALoCoQledRWN3Inqmfr1Qyf34wGqVU1D99hjPYqHU7YFp/VbaOKEJwoakNrnyHt0fSKLjkWQ+fqo
\r
38 X-Received: by 10.195.13.114 with SMTP id ex18mr780235wjd.111.1414738861766;
\r
39 Fri, 31 Oct 2014 00:01:01 -0700 (PDT)
\r
40 Received: from disaster-area.hh.sledj.net
\r
41 ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])
\r
42 by mx.google.com with ESMTPSA id
\r
43 vm6sm11057399wjc.16.2014.10.31.00.01.00 for <multiple recipients>
\r
44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
45 Fri, 31 Oct 2014 00:01:00 -0700 (PDT)
\r
46 Received: from localhost (30000@localhost [local]);
\r
47 by localhost (OpenSMTPD) with ESMTPA id e4eaf20c;
\r
48 Fri, 31 Oct 2014 07:00:59 +0000 (UTC)
\r
49 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
\r
50 Subject: Re: [PATCH v1] emacs: Improved header display.
\r
51 In-Reply-To: <874mul8fe1.fsf@nikula.org>
\r
52 References: <1414692196-12550-1-git-send-email-dme@dme.org>
\r
53 <874mul8fe1.fsf@nikula.org>
\r
54 User-Agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1
\r
55 (x86_64-apple-darwin14.0.0)
\r
56 From: David Edmondson <dme@dme.org>
\r
57 Date: Fri, 31 Oct 2014 07:00:59 +0000
\r
58 Message-ID: <m2bnos67v8.fsf@heart-of-gold.hh.sledj.net>
\r
60 Content-Type: text/plain
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Fri, 31 Oct 2014 07:01:14 -0000
\r
75 On Thu, Oct 30 2014, Jani Nikula wrote:
\r
76 > On Thu, 30 Oct 2014, David Edmondson <dme@dme.org> wrote:
\r
77 >> Truncate the displayed headers to the window width. Show an ellipsis
\r
78 >> if the displayed header is truncated. Add a binding 'T' to toggle the
\r
79 >> truncation of headers. Add the not-displayed section of the header as
\r
80 >> a tooltip to the displayed section.
\r
82 > Thanks for your efforts, David - I hate it that I'm going to sound
\r
83 > ungrateful since I asked for something like this. But not quite like
\r
86 > I think more header lines than just one should be displayed untruncated
\r
87 > by default. I think it's okay to show, say, five lines of To: or Cc: and
\r
88 > that'll probably cover most emails without truncation. And when the
\r
89 > header does get truncated, I'd really like to see the indication more
\r
90 > predominantly displayed than just ellipsis.
\r
92 > I'm thinking of something like this, similar to notmuch-wash:
\r
95 > To: user@example.com, user@example.com, user@example.com,
\r
96 > user@example.com, user@example.com, user@example.com, user@example.com,
\r
97 > user@example.com, user@example.com, user@example.com, user@example.com,
\r
98 > user@example.com, user@example.com, user@example.com, user@example.com,
\r
99 > [ 42 more header lines. Click/Enter to show. ]
\r
100 > Cc: user@example.com
\r
103 Hmm. That seems pretty ugly to me :-)
\r
105 As you mentioned in #notmuch, the implementation below is also not quite
\r
106 correct - it assumes that it is splitting addresses but is also used on
\r
107 the non-address headers. There are also some oddities when the header
\r
108 lines of collapsed messages are compressed.
\r
110 If anyone else is particularly interested then I may come back to it,
\r
111 but otherwise will leave it alone.
\r
118 >> emacs/notmuch-show.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++++---
\r
119 >> 1 file changed, 51 insertions(+), 3 deletions(-)
\r
121 >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
122 >> index a997482..523cef5 100644
\r
123 >> --- a/emacs/notmuch-show.el
\r
124 >> +++ b/emacs/notmuch-show.el
\r
125 >> @@ -443,9 +443,56 @@ message at DEPTH in the current thread."
\r
127 >> (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
\r
129 >> +(defun notmuch-truncate-nicely (addresses target-length)
\r
130 >> + ;; If it fits, everything is easy.
\r
131 >> + (if (< (length addresses) target-length)
\r
132 >> + (cons addresses nil)
\r
133 >> + (let* ((visible-length (- target-length (length "...")))
\r
134 >> + (visible (substring addresses 0 visible-length))
\r
135 >> + (invisible (substring addresses visible-length)))
\r
136 >> + ;; Try to terminate the visible string at a good break point.
\r
137 >> + (when (string-match "\\(.+\\),\\([^,]*\\)" visible)
\r
138 >> + ;; Order is important (second clause is destructive on
\r
140 >> + (setq invisible (concat (match-string 2 visible) invisible)
\r
141 >> + visible (match-string 1 visible)))
\r
142 >> + ;; `invisible' can end up with a leading space or
\r
143 >> + ;; comma-space, because the list of addresses is
\r
144 >> + ;; seperated with ", ", but we split on ",".
\r
145 >> + (setq invisible (replace-regexp-in-string "^[, ]*\\(.*\\)$" "\\1" invisible))
\r
146 >> + (cons visible invisible))))
\r
148 >> +(defun notmuch-show-toggle-header-truncation ()
\r
150 >> + (let ((invisibility-spec-member (cons 'notmuch-show-mode t)))
\r
151 >> + (if (member invisibility-spec-member buffer-invisibility-spec)
\r
152 >> + (remove-from-invisibility-spec invisibility-spec-member)
\r
153 >> + (add-to-invisibility-spec invisibility-spec-member)))
\r
154 >> + ;; Required to have the change in visibility take effect.
\r
155 >> + (force-window-update))
\r
157 >> (defun notmuch-show-insert-header (header header-value)
\r
158 >> "Insert a single header."
\r
159 >> - (insert header ": " (notmuch-sanitize header-value) "\n"))
\r
160 >> + (let* ((header-value (notmuch-sanitize header-value))
\r
161 >> + (header-colon (concat header ": "))
\r
162 >> + (available-width (- (window-width) (length header-colon)))
\r
163 >> + (v-i (notmuch-truncate-nicely header-value available-width)))
\r
165 >> + (insert header-colon)
\r
166 >> + (let ((visible (car v-i))
\r
167 >> + (invisible (cdr v-i)))
\r
168 >> + (when invisible
\r
169 >> + (setq visible (propertize visible 'help-echo (concat "..." invisible))))
\r
170 >> + (insert visible)
\r
171 >> + (when invisible
\r
173 >> + (let ((start (point))
\r
175 >> + (insert invisible)
\r
176 >> + (setq overlay (make-overlay start (point)))
\r
177 >> + (overlay-put overlay 'invisible 'notmuch-show-mode)
\r
178 >> + (overlay-put overlay 'isearch-open-invisible #'delete-overlay))))
\r
179 >> + (insert "\n")))
\r
181 >> (defun notmuch-show-insert-headers (headers)
\r
182 >> "Insert the headers of the current message."
\r
183 >> @@ -1328,6 +1375,7 @@ reset based on the original query."
\r
184 >> (define-key map "$" 'notmuch-show-toggle-process-crypto)
\r
185 >> (define-key map "<" 'notmuch-show-toggle-thread-indentation)
\r
186 >> (define-key map "t" 'toggle-truncate-lines)
\r
187 >> + (define-key map "T" 'notmuch-show-toggle-header-truncation)
\r
188 >> (define-key map "." 'notmuch-show-part-map)
\r
190 >> "Keymap for \"notmuch show\" buffers.")
\r
191 >> @@ -1367,8 +1415,8 @@ All currently available key bindings:
\r
192 >> (use-local-map notmuch-show-mode-map)
\r
193 >> (setq major-mode 'notmuch-show-mode
\r
194 >> mode-name "notmuch-show")
\r
195 >> - (setq buffer-read-only t
\r
196 >> - truncate-lines t))
\r
197 >> + (add-to-invisibility-spec (cons 'notmuch-show-mode t))
\r
198 >> + (setq buffer-read-only t))
\r
200 >> (defun notmuch-tree-from-show-current-query ()
\r
201 >> "Call notmuch tree with the current query"
\r
205 >> _______________________________________________
\r
206 >> notmuch mailing list
\r
207 >> notmuch@notmuchmail.org
\r
208 >> http://notmuchmail.org/mailman/listinfo/notmuch
\r