Re: [PATCH] Add $weed_unfold option.

Rene Kita <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
On Thu, Feb 26, 2026 at 12:19:48PM +0800, Kevin J. McCarthy wrote:
> This option, when unset, modifies the display of email headers when
> $weed is enabled.
> 
> The default behavior is to unfold headers when $weed is set, and to
> leave them folded when $weed is unset (in effect, displaying them as
> they appear in the original email, subject to screen width wrapping).
> 
> When $weed_unfold is unset and $weed is set, the headers will be
> weeded, but will not be unfolded: displaying as they appear in the
> original email.
> 
> The option could be useful for those who 'unignore' long headers, such
> as from Spam Assassin, that are formatted to be more readable in the
> original email, but become unreadable when unfolded/refolded to screen
> width.

This left me a bit confused, but maybe it's just me. Just to clarify:
$weed_unfold unset is the new behaviour while setting $weed_unfold is
the old default? If so, wouldn't it make more sense to use $weed_fold?

Also, unfolding in that case means that a nicely formatted header, a
header that goes over multiple lines to be read by humans, is 'unfolded'
to be a single line header, right?

> ---
> This is in response to ticket #511.
> 
> I originally started on a version of this that made unfolding and
> weeding orthogonal.  However there were two problems with that approach:
> 
> 1. The implementation was much more invasive, requiring more state flags
> and commands and modifications all over the place.
> 
> 2. It ended up being confusing to control.  The current default behavior
>    of mutt is to unfold when $weed is toggled, but display as original
>    when $weed is toggled off.  When the options are orthogonal, keeping the
>    current behavior required toggling two flags: weed and unfold when
>    switching between those states.  It would have been confusing to
>    existing users and likely generated a lot of complaints.
> 
> Since this option is probably only interesting to a small number of
> users, I decided to instead just have a modifier state when $weed is
> set.
> 
>  init.h    | 11 +++++++++++
>  mutt.h    |  1 +
>  sendlib.c |  2 +-
>  3 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/init.h b/init.h
> index 84e62fb4..eb331a37 100644
> --- a/init.h
> +++ b/init.h
> @@ -4911,6 +4911,17 @@ struct option_t MuttVars[] = {
>    ** .pp
>    ** Also see $$copy_decode_weed, $$pipe_decode_weed, $$print_decode_weed.
>    */
> +  { "weed_unfold",   DT_BOOL, R_NONE, {.l=OPTWEEDUNFOLD}, {.l=1} },
> +  /*
> +  ** .pp
> +  ** When \fIset\fP, mutt will unfold (and then refold) headers when
> +  ** displaying messages with $$weed set.  When \fIunset\fP, headers
> +  ** will be displayed as they appear in the original email, but still
> +  ** subject to display width wrapping.
> +  ** .pp
> +  ** Note that when $$weed is unset, mutt always displays the headers
> +  ** as they appear in the original email.
> +  */
>    { "wrap",             DT_NUM,  R_PAGER_FLOW, {.p=&Wrap}, {.l=0} },
>    /*
>    ** .pp
> diff --git a/mutt.h b/mutt.h
> index 75a45999..36f92a31 100644
> --- a/mutt.h
> +++ b/mutt.h
> @@ -582,6 +582,7 @@ enum
>  #endif
>    OPTWAITKEY,
>    OPTWEED,
> +  OPTWEEDUNFOLD,
>    OPTWRAP,
>    OPTWRAPSEARCH,
>    OPTWRITEBCC,          /* write out a bcc header? */
> diff --git a/sendlib.c b/sendlib.c
> index a700d500..476865ac 100644
> --- a/sendlib.c
> +++ b/sendlib.c
> @@ -2183,7 +2183,7 @@ int mutt_write_one_header (FILE *fp, const char *tag, const char *value,
>    int pfxw = mutt_strwidth (pfx);
>    char *v = safe_strdup (value);
>  
> -  if (!(flags & CH_DISPLAY) || option (OPTWEED))
> +  if (!(flags & CH_DISPLAY) || (option (OPTWEED) && option (OPTWEEDUNFOLD)))
>      v = unfold_header (v);
>  
>    /* when not displaying, use sane wrap value */
> -- 
> 2.53.0
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.