unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>
To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2] emacs: Add more processing of displayed headers.
Date: Fri, 12 Oct 2012 15:11:11 -0400	[thread overview]
Message-ID: <87sj9ja4kw.fsf@betacantrips.com> (raw)
In-Reply-To: <1328542748-19530-2-git-send-email-dme@dme.org>

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 <dme@dme.org> 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

  parent reply	other threads:[~2012-10-12 19:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20  9:43 [PATCH 1/3] emacs: Tidy `notmuch-show-insert-part-header' David Edmondson
2012-01-20  9:43 ` [PATCH 2/3] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-01-20 20:20   ` Jameson Graef Rollins
2012-01-22 21:38   ` Jameson Graef Rollins
2012-01-23  8:16     ` David Edmondson
2012-01-23  8:52       ` Jameson Graef Rollins
2012-01-23  9:12         ` David Edmondson
2012-01-23 10:33           ` [PATCH 1/3 v2] " David Edmondson
2012-01-23 10:33             ` [PATCH 2/3 v2] emacs: Optionally hide some part headers David Edmondson
2012-01-23 10:33             ` [PATCH 3/3 v2] emacs: Don't insert a part header if it's the first part and text/* David Edmondson
2012-01-23 11:32             ` [PATCH 1/3 v2] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-01-20  9:43 ` [PATCH 3/3] emacs: Optionally hide some part headers David Edmondson
2012-01-24 12:53 ` optional hiding of some part headers v3 David Edmondson
2012-01-24 12:53   ` [PATCH 1/3] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-01-24 18:46     ` Jameson Graef Rollins
2012-01-24 19:25       ` David Edmondson
2012-01-24 19:52         ` Jameson Graef Rollins
2012-01-25  6:15           ` David Edmondson
2012-01-24 19:33     ` Tomi Ollila
2012-01-24 12:53   ` [PATCH 2/3] emacs: Optionally hide some part headers David Edmondson
2012-01-24 19:34     ` Tomi Ollila
2012-01-24 12:53   ` [PATCH 3/3] emacs: Don't insert a part header if it's the first part and text/* David Edmondson
2012-01-24 19:46     ` Tomi Ollila
2012-02-06 15:39 ` [PATCH v3 0/3] part header code tidying and options David Edmondson
2012-02-06 15:39   ` [PATCH v2] emacs: Add more processing of displayed headers David Edmondson
2012-02-14 12:30     ` David Bremner
2012-02-14 13:28       ` David Edmondson
2012-10-12 19:11     ` Ethan Glasser-Camp [this message]
2012-02-06 15:39   ` [PATCH v3 1/3] emacs: Don't return the button from `notmuch-show-insert-part-header' David Edmondson
2012-02-06 15:39   ` [PATCH v3 2/3] emacs: Optionally hide some part headers David Edmondson
2012-02-12  9:21     ` Mark Walters
2012-02-06 15:39   ` [PATCH v3 3/3] emacs: Don't insert a part header if it's the first part and text/* David Edmondson
2012-02-12  9:24     ` Mark Walters
2012-02-12  9:39       ` Mark Walters
  -- strict thread matches above, loose matches on Subject: below --
2012-01-26  8:17 [PATCH 0/2] re-enable line wrapping and add some header bling David Edmondson
2012-02-06 13:16 ` [PATCH v2] Wrap and indent headers in show mode David Edmondson
2012-02-06 13:16   ` [PATCH v2] emacs: Add more processing of displayed headers David Edmondson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sj9ja4kw.fsf@betacantrips.com \
    --to=ethan.glasser.camp@gmail.com \
    --cc=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).