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 21761431FC9 for ; Fri, 31 Oct 2014 00:01:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001] 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 yZvfCLMXopdh for ; Fri, 31 Oct 2014 00:01:06 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 69C72431FC2 for ; Fri, 31 Oct 2014 00:01:06 -0700 (PDT) Received: by mail-wg0-f50.google.com with SMTP id z12so5777796wgg.23 for ; Fri, 31 Oct 2014 00:01:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:in-reply-to:references:user-agent :from:date:message-id:mime-version:content-type; bh=YKyBdwCkqVFbwz9RANAMLYFjUhNBx3Ei4YfzhB1p9jQ=; b=HZpm+iUR3i2BLXW60YoQwU0LHWjF6HJ5CGERvfQRFrUws4F7ZZGULwHUFw9yySpvsT rBm1o0FgB3fc6G3ZM2pLlXOrpBgYLiJ25/9g0DoV6Hu3HHxTZjZIG/ncNenu7g1W2QYI lvW9/3DK5Qv2Uh64QQrq6LLVfzyHpoMuCcwsEjSrar+vAta12LR7Ekd+0KHCIQDOIi9R uRtWD4sOXCYL/pt7DtxhJpocUir772QDBeVed1bPUtQ105PFV5aOYpVcZdATie6d9Ppp zqqvta1VT4m8Ho3hT7lWTMU5RcsyD/SjckzGYTl7W6Qc+CM4aFVxPKqDLCffO83eDY3U sGIQ== X-Gm-Message-State: ALoCoQledRWN3Inqmfr1Qyf34wGqVU1D99hjPYqHU7YFp/VbaOKEJwoakNrnyHt0fSKLjkWQ+fqo X-Received: by 10.195.13.114 with SMTP id ex18mr780235wjd.111.1414738861766; Fri, 31 Oct 2014 00:01:01 -0700 (PDT) Received: from disaster-area.hh.sledj.net ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) by mx.google.com with ESMTPSA id vm6sm11057399wjc.16.2014.10.31.00.01.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Oct 2014 00:01:00 -0700 (PDT) Received: from localhost (30000@localhost [local]); by localhost (OpenSMTPD) with ESMTPA id e4eaf20c; Fri, 31 Oct 2014 07:00:59 +0000 (UTC) To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH v1] emacs: Improved header display. In-Reply-To: <874mul8fe1.fsf@nikula.org> References: <1414692196-12550-1-git-send-email-dme@dme.org> <874mul8fe1.fsf@nikula.org> User-Agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-apple-darwin14.0.0) From: David Edmondson Date: Fri, 31 Oct 2014 07:00:59 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain 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: Fri, 31 Oct 2014 07:01:14 -0000 On Thu, Oct 30 2014, Jani Nikula wrote: > On Thu, 30 Oct 2014, David Edmondson wrote: >> Truncate the displayed headers to the window width. Show an ellipsis >> if the displayed header is truncated. Add a binding 'T' to toggle the >> truncation of headers. Add the not-displayed section of the header as >> a tooltip to the displayed section. > > Thanks for your efforts, David - I hate it that I'm going to sound > ungrateful since I asked for something like this. But not quite like > this... > > I think more header lines than just one should be displayed untruncated > by default. I think it's okay to show, say, five lines of To: or Cc: and > that'll probably cover most emails without truncation. And when the > header does get truncated, I'd really like to see the indication more > predominantly displayed than just ellipsis. > > I'm thinking of something like this, similar to notmuch-wash: > > --- > To: user@example.com, user@example.com, user@example.com, > user@example.com, user@example.com, user@example.com, user@example.com, > user@example.com, user@example.com, user@example.com, user@example.com, > user@example.com, user@example.com, user@example.com, user@example.com, > [ 42 more header lines. Click/Enter to show. ] > Cc: user@example.com > --- Hmm. That seems pretty ugly to me :-) As you mentioned in #notmuch, the implementation below is also not quite correct - it assumes that it is splitting addresses but is also used on the non-address headers. There are also some oddities when the header lines of collapsed messages are compressed. If anyone else is particularly interested then I may come back to it, but otherwise will leave it alone. > BR, > Jani. > > >> --- >> emacs/notmuch-show.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++++--- >> 1 file changed, 51 insertions(+), 3 deletions(-) >> >> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el >> index a997482..523cef5 100644 >> --- a/emacs/notmuch-show.el >> +++ b/emacs/notmuch-show.el >> @@ -443,9 +443,56 @@ message at DEPTH in the current thread." >> ")\n") >> (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) >> >> +(defun notmuch-truncate-nicely (addresses target-length) >> + ;; If it fits, everything is easy. >> + (if (< (length addresses) target-length) >> + (cons addresses nil) >> + (let* ((visible-length (- target-length (length "..."))) >> + (visible (substring addresses 0 visible-length)) >> + (invisible (substring addresses visible-length))) >> + ;; Try to terminate the visible string at a good break point. >> + (when (string-match "\\(.+\\),\\([^,]*\\)" visible) >> + ;; Order is important (second clause is destructive on >> + ;; `visible'. >> + (setq invisible (concat (match-string 2 visible) invisible) >> + visible (match-string 1 visible))) >> + ;; `invisible' can end up with a leading space or >> + ;; comma-space, because the list of addresses is >> + ;; seperated with ", ", but we split on ",". >> + (setq invisible (replace-regexp-in-string "^[, ]*\\(.*\\)$" "\\1" invisible)) >> + (cons visible invisible)))) >> + >> +(defun notmuch-show-toggle-header-truncation () >> + (interactive) >> + (let ((invisibility-spec-member (cons 'notmuch-show-mode t))) >> + (if (member invisibility-spec-member buffer-invisibility-spec) >> + (remove-from-invisibility-spec invisibility-spec-member) >> + (add-to-invisibility-spec invisibility-spec-member))) >> + ;; Required to have the change in visibility take effect. >> + (force-window-update)) >> + >> (defun notmuch-show-insert-header (header header-value) >> "Insert a single header." >> - (insert header ": " (notmuch-sanitize header-value) "\n")) >> + (let* ((header-value (notmuch-sanitize header-value)) >> + (header-colon (concat header ": ")) >> + (available-width (- (window-width) (length header-colon))) >> + (v-i (notmuch-truncate-nicely header-value available-width))) >> + >> + (insert header-colon) >> + (let ((visible (car v-i)) >> + (invisible (cdr v-i))) >> + (when invisible >> + (setq visible (propertize visible 'help-echo (concat "..." invisible)))) >> + (insert visible) >> + (when invisible >> + (insert ", ") >> + (let ((start (point)) >> + overlay) >> + (insert invisible) >> + (setq overlay (make-overlay start (point))) >> + (overlay-put overlay 'invisible 'notmuch-show-mode) >> + (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))) >> + (insert "\n"))) >> >> (defun notmuch-show-insert-headers (headers) >> "Insert the headers of the current message." >> @@ -1328,6 +1375,7 @@ reset based on the original query." >> (define-key map "$" 'notmuch-show-toggle-process-crypto) >> (define-key map "<" 'notmuch-show-toggle-thread-indentation) >> (define-key map "t" 'toggle-truncate-lines) >> + (define-key map "T" 'notmuch-show-toggle-header-truncation) >> (define-key map "." 'notmuch-show-part-map) >> map) >> "Keymap for \"notmuch show\" buffers.") >> @@ -1367,8 +1415,8 @@ All currently available key bindings: >> (use-local-map notmuch-show-mode-map) >> (setq major-mode 'notmuch-show-mode >> mode-name "notmuch-show") >> - (setq buffer-read-only t >> - truncate-lines t)) >> + (add-to-invisibility-spec (cons 'notmuch-show-mode t)) >> + (setq buffer-read-only t)) >> >> (defun notmuch-tree-from-show-current-query () >> "Call notmuch tree with the current query" >> -- >> 2.1.1 >> >> _______________________________________________ >> notmuch mailing list >> notmuch@notmuchmail.org >> http://notmuchmail.org/mailman/listinfo/notmuch