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 1F1C9431FCB for ; Thu, 30 Oct 2014 13:35:45 -0700 (PDT) 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 tIXotaarvcBT for ; Thu, 30 Oct 2014 13:35:39 -0700 (PDT) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id DBA77431FC2 for ; Thu, 30 Oct 2014 13:35:38 -0700 (PDT) Received: by mail-wg0-f48.google.com with SMTP id m15so5127382wgh.21 for ; Thu, 30 Oct 2014 13:35:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=bW0PymZt6Mtyw5J9fLDd5anGiM1YHgaWpHo/znUmWWw=; b=jfvryi7Qr8gZTRnznmJKbIIwf12CDIluBxN0Hlb1W8A364So9tOFvDmR7DKUkcbVb1 OWCXyGsCGEv9bZphuD61+JzyJX56UV49IJtzWAJ2hLh45wfUP1X3GeFISfz8InINbWlv iCC5dI0HpX7s2dZc6LZcldsbZoUKHU1/2HzgTs7BJak0TYcSvWvie29PTOl9ej0wLZPZ VEmg7Agj/tIpzBV4Se1bLvp91SrQsRsumh+siabVAIiAI5DiwIagTl+ABe0g/iv7XQI9 z1ufolLdK6+97a1Po6e1jBTabQ3SwGk5wi83UNG6PovLsEm922wO4doDhUs0Fuu6xm6b KpqQ== X-Gm-Message-State: ALoCoQkBcJlozK5vIu4CmmCYXYClCOqPah1d/AfH01hzT2K+BKTRstBHfUu8Pyy+BoZmYEB60c+M X-Received: by 10.194.192.73 with SMTP id he9mr5240852wjc.125.1414701337475; Thu, 30 Oct 2014 13:35:37 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c36d-48.dhcp.inet.fi. [88.195.109.48]) by mx.google.com with ESMTPSA id ws2sm9871831wjc.32.2014.10.30.13.35.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Oct 2014 13:35:36 -0700 (PDT) From: Jani Nikula To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v1] emacs: Improved header display. In-Reply-To: <1414692196-12550-1-git-send-email-dme@dme.org> References: <1414692196-12550-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.18.2+152~g6e84b62 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Thu, 30 Oct 2014 22:35:34 +0200 Message-ID: <874mul8fe1.fsf@nikula.org> 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: Thu, 30 Oct 2014 20:35:45 -0000 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 --- 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