From 84e645055a3736b53d9eace44f1d3513cf46b69c Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Sat, 13 Oct 2012 15:11:11 +2000 Subject: [PATCH] Re: [PATCH v2] emacs: Add more processing of displayed headers. --- 21/3450f23aa731c225f7cad48ab4ec5cb2258758 | 145 ++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 21/3450f23aa731c225f7cad48ab4ec5cb2258758 diff --git a/21/3450f23aa731c225f7cad48ab4ec5cb2258758 b/21/3450f23aa731c225f7cad48ab4ec5cb2258758 new file mode 100644 index 000000000..5bf7cb3f8 --- /dev/null +++ b/21/3450f23aa731c225f7cad48ab4ec5cb2258758 @@ -0,0 +1,145 @@ +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 04D23431FAF + for ; Fri, 12 Oct 2012 12:11:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 EboCTzC+IYpy for ; + Fri, 12 Oct 2012 12:11:19 -0700 (PDT) +Received: from mail-qa0-f46.google.com (mail-qa0-f46.google.com + [209.85.216.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0B73B431FAE + for ; Fri, 12 Oct 2012 12:11:19 -0700 (PDT) +Received: by mail-qa0-f46.google.com with SMTP id c26so119914qad.5 + for ; Fri, 12 Oct 2012 12:11:18 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=zM85p8sqM76LqthFEbl7VYW70ls6RWsaKz8w+UhZvr4=; + b=Sf2wH0NvIq6spO65oidsnl5PIKfauAQdlWo5KiO8G9qly3Wtw8qKTXKzkfd3nu6uvF + 5QKHfvoYGO3wVUOspLQKhy1M+l2buZmenoygbPIog0bIKxPOvSsJ0lh9x4LbwdV1H3Ga + koelEhiFCD8uLQr7yj4nElXETrSHZ/d5+ocWKvLmYIF4v0fikA5MQuR99bPvMZhB8Xtf + 8Yf0RvL+Tzs95d9WXEWK9K1kPM1852zdPq7qYvMQQ/HMh+rY8seIh7TnVgBWD/lxcOkt + Fwhz/ZH0bS5mhfsS6nxS4CJv3HqTlntDL5PzZedExt+842Cz/gwnnQnXRa/64+Egt4tu + lXGA== +Received: by 10.224.222.13 with SMTP id ie13mr8911903qab.69.1350069078538; + Fri, 12 Oct 2012 12:11:18 -0700 (PDT) +Received: from smtp.gmail.com (p70-80.acedsl.com. [66.114.70.80]) + by mx.google.com with ESMTPS id g4sm7946225qav.16.2012.10.12.12.11.16 + (version=TLSv1/SSLv3 cipher=OTHER); + Fri, 12 Oct 2012 12:11:16 -0700 (PDT) +From: Ethan Glasser-Camp +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH v2] emacs: Add more processing of displayed headers. +In-Reply-To: <1328542748-19530-2-git-send-email-dme@dme.org> +References: <1327052612-1040-1-git-send-email-dme@dme.org> + <1328542748-19530-1-git-send-email-dme@dme.org> + <1328542748-19530-2-git-send-email-dme@dme.org> +User-Agent: Notmuch/0.14+45~g6ea9330 (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Fri, 12 Oct 2012 15:11:11 -0400 +Message-ID: <87sj9ja4kw.fsf@betacantrips.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +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, 12 Oct 2012 19:11:20 -0000 + +Hi! Just going through the patch queue. + +This is definitely a nice effect, but I'm not sure of the approach. It +doesn't indent the message's tags, and it doesn't work when you resize the +window. (You can get some very ugly wrapping if you put your mind to +it.) + +Is there no better way to do this using visual-line-mode? I know that +the rest of notmuch uses hard filling, but that's no reason to make a +bad situation worse. It looks like you can put wrap-prefix text +properties all over, as done in the adaptive-wrap package: + +http://elpa.gnu.org/packages/adaptive-wrap-0.1.el + +Slightly more nit-picky comments below. + +David Edmondson writes: + +> -(defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers) +> +(defcustom notmuch-show-markup-headers-hook '(notmuch-show-colour-headers +> + notmuch-show-fill-headers +> + notmuch-show-indent-continuations) +> "A list of functions called to decorate the headers listed in +> -`notmuch-message-headers'.") +> +`notmuch-message-headers'." +> + :type 'hook +> + :options '(notmuch-show-colour-headers +> + notmuch-show-fill-headers +> + notmuch-show-indent-continuations) +> + :group 'notmuch-show) + +This hook is not normal because it takes an argument, and so should have +a name ending in -hooks or -functions. Also, since it's a defcustom now, +it should probably have a better explanation of how it works, that it +takes an argument, and what that argument means. + +It seems extremely dicey to me that you can put +notmuch-show-indent-continuations in this list before, or without, +notmuch-show-fill-headers. + +> +(defun notmuch-show-fill-headers (depth) +> + "Wrap the text of the current headers." +> + +> + ;; '-5' to allow for the indentation code. +> + (let ((fill-column (- (window-width) depth 5))) + +It took me a little while to figure out what this meant. How about, +"underfill by 5 so that inserting indentation doesn't cause more +wrapping"? Is it possible to be smart enough to let + +> +(defun notmuch-show-indent-continuations (depth) +> + "Indent any continuation lines." +> + (goto-char (point-min)) +> + (while (not (eobp)) +> + (if (not (looking-at "^[A-Za-z][-A-Za-z0-9]*:")) +> + ;; Four spaces tends to work well with 'To' and 'Cc' headers. +> + (insert " ")) +> + (forward-line))) + +I'm not crazy about this but I'm not sure I can say why exactly. Why +can't we just run indent-rigidly over the whole thing? + +The comment isn't terribly useful. Only those headers? "Tends to work +well"? + +> ;; Override `notmuch-message-headers' to force `From' to be +> ;; displayed. +> (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date"))) +> - (notmuch-show-insert-headers (plist-get message :headers))) +> + (notmuch-show-insert-headers (plist-get message :headers) 0)) + +This took me a long while to figure out, especially because it looks +like the depth is being passed normally to notmuch-show-insert-bodypart, +just below. A comment like "depth = 0 because we reindent below" would +have been really helpful. A good test message is +id:"87ocabvp0y.fsf@wsheee.2x.cz". + +Ethan -- 2.26.2