<<< Date Index >>>     <<< Thread Index >>>

Re: [Mutt] #408: [PATCH] more flag data in collapsed thread view



#408: [PATCH] more flag data in collapsed thread view
----------------------------------------------------------+-----------------
  Reporter:  James Devenish <devenish@â>                  |       Owner:  
mutt-dev
      Type:  enhancement                                  |      Status:  new   
  
  Priority:  trivial                                      |   Milestone:        
  
 Component:  mutt                                         |     Version:  
1.3.13i 
Resolution:                                               |    Keywords:        
  
----------------------------------------------------------+-----------------
Changes (by me):

  * type:  defect => enhancement


Old description:

> {{{
> Package: mutt
> Version: 1.3.13i
> Severity: wishlist
>
> -- Please type your report below this line
>
> It would be nice if hidden messages could have their flags propagated
> through
> to the thread leader message's flag display. Eg. if one invisible message
> in a
> thread has the ! flag set, this should be indicated in the flags
> displayed for
> the visible message. My implementation displays one set of characters if
> *all*
> messages have a particular attribute and another set if only one or some
> of the
> messages have a particular attribute. See the documentation patch for
> more
> details.
>
> I have modified and extended the _mutt_traverse_thread function to count
> the
> occurrence of attributes in a thread.
>
> The code below works for me, but needs cleaning up. I have intentionally
> left
> it messy so that it is as near as possible to the existing code. (ie. I
> haven't
> rewritten the whole lot in a neater way.)
>
> Index: mutt.h
> ===================================================================
> RCS file: /home/roessler/cvs/mutt/mutt.h,v
> retrieving revision 2.88
> diff -u -r2.88 mutt.h
> --- mutt.h      2000/12/31 11:24:19     2.88
> +++ mutt.h      2001/01/01 10:01:50
> @@ -158,6 +158,9 @@
>  #define M_THREAD_GET_HIDDEN    (1<<2)
>  #define M_THREAD_UNREAD                (1<<3)
>  #define M_THREAD_NEXT_UNREAD   (1<<4)
> +#define M_THREAD_GET_NEW       (1<<5)
> +#define M_THREAD_GET_OLD       (1<<6)
> +#define M_THREAD_GET_FLAGGED   (1<<7)
>
>  enum
>  {
> Index: hdrline.c
> ===================================================================
> RCS file: /home/roessler/cvs/mutt/hdrline.c,v
> retrieving revision 2.23
> diff -u -r2.23 hdrline.c
> --- hdrline.c   2000/10/17 15:10:51     2.23
> +++ hdrline.c   2001/01/01 10:01:51
> @@ -253,12 +268,18 @@
>    int optional = (flags & M_FORMAT_OPTIONAL);
>    int threads = ((Sort & SORT_MASK) == SORT_THREADS);
>    int is_index = (flags & M_FORMAT_INDEX);
> -#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 &&
> mutt_thread_contains_unread (ctx, hdr) == 1)
> -#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 &&
> mutt_thread_contains_unread (ctx, hdr) == 2)
> +  int selforchild;
> +  int temp;
> +/*#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1
> && mutt_thread_contains_unread (ctx, hdr) == 1)*/
> +/*#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1
> && mutt_thread_contains_unread (ctx, hdr) == 2)*/
> +#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 &&
> ( temp = _mutt_traverse_thread (ctx, hdr, M_THREAD_GET_NEW) ) )
> +#define THREAD_FLAGGED (threads && hdr->collapsed && hdr->num_hidden > 1
> && ( temp = _mutt_traverse_thread (ctx, hdr, M_THREAD_GET_FLAGGED) ) )
> +#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 &&
> ( temp = _mutt_traverse_thread (ctx, hdr, M_THREAD_GET_OLD) ) )
>    size_t len;
>
>    hdr = hfi->hdr;
>    ctx = hfi->ctx;
> +  selforchild = mutt_get_hidden(ctx, hdr) + 1/*self*/;
>
>    dest[0] = 0;
>    switch (op)
> @@ -630,12 +651,12 @@
>  #endif
>
>        snprintf (buf2, sizeof (buf2),
> -               "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' :
> +               "%c%c%c", (THREAD_NEW ? (((temp+!hdr->read)==selforchild)
> ? 'N' : 'n') : (THREAD_OLD ? (((temp+hdr->old)==selforchild) ? 'O' : 'o'
> ) :
>                 ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
>                 ? (hdr->replied ? 'r' : ' ') : (hdr->old ? 'O' : 'N')))),
>                 hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch),
>                 hdr->tagged ? '*' :
> -               (hdr->flagged ? '!' :
> +               (hdr->flagged ? '!' : THREAD_FLAGGED ? '.' :
>                  (Tochars && ((i = mutt_user_is_recipient (hdr)) <
> mutt_strlen (Tochars)) ? Tochars[i] : ' ')));
>        mutt_format_s (dest, destlen, prefix, buf2);
>        break;
> Index: init.h
> ===================================================================
> RCS file: /home/roessler/cvs/mutt/init.h,v
> retrieving revision 2.112
> diff -u -r2.112 init.h
> --- init.h      2000/12/21 09:19:41     2.112
> +++ init.h      2001/01/01 10:01:53
> @@ -808,7 +815,8 @@
>    ** .dt %Y .dd `x-label' field, if present, and (1) not at part of a
> thread tree,
>    **            (2) at the top of a thread, or (3) `x-label' is
> different from
>    **            preceding message's `x-label'.
> -  ** .dt %Z .dd message status flags
> +  ** .dt %Z .dd message status flags. Three flag positions are shown.
> \fIFor unthreaded
> +  **                           entries:\fP the first character indicates
> whether a message is replied to ('r'), new ('N'), old ('O'), or none of
> these (' '). The second character indicates if a message is to be deleted
> ('D') or else PGP flags. The third character indicates is a message is
> tagged ('*'), flagged ('!'), or else contains one of $$to_chars. \fIFor
> threaded entires:\fP the first character indicates whether all messages
> are new ('N') or only some ('n') or whether all entries are old ('O') or
> only some ('o'). The second character indicates whether the displayed
> message (ie. the thread leader) is to be deleted ('D') or else PGP flags.
> The third character indicates whether the displayed message is flagged
> ('!') or if some hidden message is flagged ('.') or else one of
> $$to_chars.
>    ** .dt %{fmt} .dd the date and time of the message is converted to
> sender's
>    **                time zone, and ``fmt'' is expanded by the library
> function
>    **                ``strftime''; a leading bang disables locales
> Index: thread.c
> ===================================================================
> RCS file: /home/roessler/cvs/mutt/thread.c,v
> retrieving revision 2.13
> diff -u -r2.13 thread.c
> --- thread.c    2000/05/10 17:16:43     2.13
> +++ thread.c    2001/01/01 10:02:08
> @@ -746,7 +746,7 @@
>  {
>    HEADER *roothdr = NULL, *top;
>    int final, reverse = (Sort & SORT_REVERSE), minmsgno;
> -  int num_hidden = 0, new = 0, old = 0;
> +  int num_hidden = 0, new = 0, old = 0, ping = 0; /* ping is the number
> of flagged messages in the thread */
>    int min_unread_msgno = INT_MAX, min_unread = cur->virtual;
>  #define CHECK_LIMIT (!ctx->pattern || cur->limited)
>
> @@ -766,15 +766,19 @@
>    if (!cur->read && CHECK_LIMIT)
>    {
>      if (cur->old)
> -      old = 2;
> +      old ++;
>      else
> -      new = 1;
> +      new ++;
>      if (cur->msgno < min_unread_msgno)
>      {
>        min_unread = cur->virtual;
>        min_unread_msgno = cur->msgno;
>      }
>    }
> +  if (cur->flagged && CHECK_LIMIT /*what is CHECK_LIMIT??*/)
> +  {
> +    ping ++;
> +  }
>
>    if (cur->virtual == -1 && CHECK_LIMIT)
>      num_hidden++;
> @@ -836,12 +840,16 @@
>      }
>

> +    if (cur->flagged && CHECK_LIMIT /*what is CHECK_LIMIT??*/)
> +    {
> +      ping ++;
> +    }
>      if (!cur->read && CHECK_LIMIT)
>      {
>        if (cur->old)
> -       old = 2;
> +       old ++;
>        else
> -       new = 1;
> +       new ++;
>        if (cur->msgno < min_unread_msgno)
>        {
>         min_unread = cur->virtual;
> @@ -879,6 +887,13 @@
>      return (final);
>    else if (flag & M_THREAD_UNREAD)
>      return ((old && new) ? new : (old ? old : new));
> +  else if (flag & M_THREAD_GET_FLAGGED)
> +    return ping;
> +  else if (flag & M_THREAD_GET_NEW)
> +    return new;
> +  else if (flag & M_THREAD_GET_OLD)
> +    return old;
> +    /*return ((old && new) ? new : (old ? old : new));*/
>    else if (flag & M_THREAD_GET_HIDDEN)
>      return (num_hidden+1);
>    else if (flag & M_THREAD_NEXT_UNREAD)
>
> -- Mutt Version Information
>
> Mutt 1.3.13i (2000-12-31)
> Copyright (C) 1996-2000 Michael R. Elkins and others.
> Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
> Mutt is free software, and you are welcome to redistribute it
> under certain conditions; type `mutt -vv' for details.
>
> System: SunOS 5.8 [using ncurses 5.0]
> Compile options:
> -DOMAIN
> +DEBUG
> -HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE
> +USE_FCNTL  -USE_FLOCK
> -USE_POP  -USE_IMAP  -USE_GSS  -USE_SSL  -USE_SASL
> +HAVE_REGCOMP  -USE_GNU_REGEX
> +HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET
> +HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM
> +HAVE_PGP  -BUFFY_SIZE -EXACT_ADDRESS  -SUN_ATTACHMENT
> +ENABLE_NLS  -LOCALES_HACK  +HAVE_WC_FUNCS  +HAVE_LANGINFO_CODESET
> +HAVE_LANGINFO_YESEXPR
> +HAVE_ICONV  +ICONV_NONTRANS  +HAVE_GETSID  -HAVE_GETADDRINFO
> ISPELL="/usr/local/bin/ispell"
> SENDMAIL="/usr/lib/sendmail"
> MAILPATH="/var/mail"
> SHAREDIR="/usr/local/share/mutt"
> SYSCONFDIR="/usr/local/etc"
> EXECSHELL="/bin/sh"
> -MIXMASTER
> To contact the developers, please mail to <mutt-dev@xxxxxxxx>.
> To report a bug, please use the flea(1) utility.
>

> >How-To-Repeat:
> >Fix:
> }}}

New description:

 {{{
 Package: mutt
 Version: 1.3.13i
 Severity: wishlist

 -- Please type your report below this line

 It would be nice if hidden messages could have their flags propagated
 through
 to the thread leader message's flag display. Eg. if one invisible message
 in a
 thread has the ! flag set, this should be indicated in the flags displayed
 for
 the visible message. My implementation displays one set of characters if
 *all*
 messages have a particular attribute and another set if only one or some
 of the
 messages have a particular attribute. See the documentation patch for more
 details.

 I have modified and extended the _mutt_traverse_thread function to count
 the
 occurrence of attributes in a thread.

 The code below works for me, but needs cleaning up. I have intentionally
 left
 it messy so that it is as near as possible to the existing code. (ie. I
 haven't
 rewritten the whole lot in a neater way.)

 Index: mutt.h
 ===================================================================
 RCS file: /home/roessler/cvs/mutt/mutt.h,v
 retrieving revision 2.88
 diff -u -r2.88 mutt.h
 --- mutt.h      2000/12/31 11:24:19     2.88
 +++ mutt.h      2001/01/01 10:01:50
 @@ -158,6 +158,9 @@
  #define M_THREAD_GET_HIDDEN    (1<<2)
  #define M_THREAD_UNREAD                (1<<3)
  #define M_THREAD_NEXT_UNREAD   (1<<4)
 +#define M_THREAD_GET_NEW       (1<<5)
 +#define M_THREAD_GET_OLD       (1<<6)
 +#define M_THREAD_GET_FLAGGED   (1<<7)

  enum
  {
 Index: hdrline.c
 ===================================================================
 RCS file: /home/roessler/cvs/mutt/hdrline.c,v
 retrieving revision 2.23
 diff -u -r2.23 hdrline.c
 --- hdrline.c   2000/10/17 15:10:51     2.23
 +++ hdrline.c   2001/01/01 10:01:51
 @@ -253,12 +268,18 @@
    int optional = (flags & M_FORMAT_OPTIONAL);
    int threads = ((Sort & SORT_MASK) == SORT_THREADS);
    int is_index = (flags & M_FORMAT_INDEX);
 -#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 &&
 mutt_thread_contains_unread (ctx, hdr) == 1)
 -#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 &&
 mutt_thread_contains_unread (ctx, hdr) == 2)
 +  int selforchild;
 +  int temp;
 +/*#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 &&
 mutt_thread_contains_unread (ctx, hdr) == 1)*/
 +/*#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 &&
 mutt_thread_contains_unread (ctx, hdr) == 2)*/
 +#define THREAD_NEW (threads && hdr->collapsed && hdr->num_hidden > 1 && (
 temp = _mutt_traverse_thread (ctx, hdr, M_THREAD_GET_NEW) ) )
 +#define THREAD_FLAGGED (threads && hdr->collapsed && hdr->num_hidden > 1
 && ( temp = _mutt_traverse_thread (ctx, hdr, M_THREAD_GET_FLAGGED) ) )
 +#define THREAD_OLD (threads && hdr->collapsed && hdr->num_hidden > 1 && (
 temp = _mutt_traverse_thread (ctx, hdr, M_THREAD_GET_OLD) ) )
    size_t len;

    hdr = hfi->hdr;
    ctx = hfi->ctx;
 +  selforchild = mutt_get_hidden(ctx, hdr) + 1/*self*/;

    dest[0] = 0;
    switch (op)
 @@ -630,12 +651,12 @@
  #endif

        snprintf (buf2, sizeof (buf2),
 -               "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' :
 +               "%c%c%c", (THREAD_NEW ? (((temp+!hdr->read)==selforchild)
 ? 'N' : 'n') : (THREAD_OLD ? (((temp+hdr->old)==selforchild) ? 'O' : 'o' )
 :
                 ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno))
                 ? (hdr->replied ? 'r' : ' ') : (hdr->old ? 'O' : 'N')))),
                 hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch),
                 hdr->tagged ? '*' :
 -               (hdr->flagged ? '!' :
 +               (hdr->flagged ? '!' : THREAD_FLAGGED ? '.' :
                  (Tochars && ((i = mutt_user_is_recipient (hdr)) <
 mutt_strlen (Tochars)) ? Tochars[i] : ' ')));
        mutt_format_s (dest, destlen, prefix, buf2);
        break;
 Index: init.h
 ===================================================================
 RCS file: /home/roessler/cvs/mutt/init.h,v
 retrieving revision 2.112
 diff -u -r2.112 init.h
 --- init.h      2000/12/21 09:19:41     2.112
 +++ init.h      2001/01/01 10:01:53
 @@ -808,7 +815,8 @@
    ** .dt %Y .dd `x-label' field, if present, and (1) not at part of a
 thread tree,
    **            (2) at the top of a thread, or (3) `x-label' is different
 from
    **            preceding message's `x-label'.
 -  ** .dt %Z .dd message status flags
 +  ** .dt %Z .dd message status flags. Three flag positions are shown.
 \fIFor unthreaded
 +  **                           entries:\fP the first character indicates
 whether a message is replied to ('r'), new ('N'), old ('O'), or none of
 these (' '). The second character indicates if a message is to be deleted
 ('D') or else PGP flags. The third character indicates is a message is
 tagged ('*'), flagged ('!'), or else contains one of $$to_chars. \fIFor
 threaded entires:\fP the first character indicates whether all messages
 are new ('N') or only some ('n') or whether all entries are old ('O') or
 only some ('o'). The second character indicates whether the displayed
 message (ie. the thread leader) is to be deleted ('D') or else PGP flags.
 The third character indicates whether the displayed message is flagged
 ('!') or if some hidden message is flagged ('.') or else one of
 $$to_chars.
    ** .dt %{fmt} .dd the date and time of the message is converted to
 sender's
    **                time zone, and ``fmt'' is expanded by the library
 function
    **                ``strftime''; a leading bang disables locales
 Index: thread.c
 ===================================================================
 RCS file: /home/roessler/cvs/mutt/thread.c,v
 retrieving revision 2.13
 diff -u -r2.13 thread.c
 --- thread.c    2000/05/10 17:16:43     2.13
 +++ thread.c    2001/01/01 10:02:08
 @@ -746,7 +746,7 @@
  {
    HEADER *roothdr = NULL, *top;
    int final, reverse = (Sort & SORT_REVERSE), minmsgno;
 -  int num_hidden = 0, new = 0, old = 0;
 +  int num_hidden = 0, new = 0, old = 0, ping = 0; /* ping is the number
 of flagged messages in the thread */
    int min_unread_msgno = INT_MAX, min_unread = cur->virtual;
  #define CHECK_LIMIT (!ctx->pattern || cur->limited)

 @@ -766,15 +766,19 @@
    if (!cur->read && CHECK_LIMIT)
    {
      if (cur->old)
 -      old = 2;
 +      old ++;
      else
 -      new = 1;
 +      new ++;
      if (cur->msgno < min_unread_msgno)
      {
        min_unread = cur->virtual;
        min_unread_msgno = cur->msgno;
      }
    }
 +  if (cur->flagged && CHECK_LIMIT /*what is CHECK_LIMIT??*/)
 +  {
 +    ping ++;
 +  }

    if (cur->virtual == -1 && CHECK_LIMIT)
      num_hidden++;
 @@ -836,12 +840,16 @@
      }


 +    if (cur->flagged && CHECK_LIMIT /*what is CHECK_LIMIT??*/)
 +    {
 +      ping ++;
 +    }
      if (!cur->read && CHECK_LIMIT)
      {
        if (cur->old)
 -       old = 2;
 +       old ++;
        else
 -       new = 1;
 +       new ++;
        if (cur->msgno < min_unread_msgno)
        {
         min_unread = cur->virtual;
 @@ -879,6 +887,13 @@
      return (final);
    else if (flag & M_THREAD_UNREAD)
      return ((old && new) ? new : (old ? old : new));
 +  else if (flag & M_THREAD_GET_FLAGGED)
 +    return ping;
 +  else if (flag & M_THREAD_GET_NEW)
 +    return new;
 +  else if (flag & M_THREAD_GET_OLD)
 +    return old;
 +    /*return ((old && new) ? new : (old ? old : new));*/
    else if (flag & M_THREAD_GET_HIDDEN)
      return (num_hidden+1);
    else if (flag & M_THREAD_NEXT_UNREAD)

 -- Mutt Version Information

 Mutt 1.3.13i (2000-12-31)
 Copyright (C) 1996-2000 Michael R. Elkins and others.
 Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
 Mutt is free software, and you are welcome to redistribute it
 under certain conditions; type `mutt -vv' for details.

 System: SunOS 5.8 [using ncurses 5.0]
 Compile options:
 -DOMAIN
 +DEBUG
 -HOMESPOOL  +USE_SETGID  +USE_DOTLOCK  +DL_STANDALONE
 +USE_FCNTL  -USE_FLOCK
 -USE_POP  -USE_IMAP  -USE_GSS  -USE_SSL  -USE_SASL
 +HAVE_REGCOMP  -USE_GNU_REGEX
 +HAVE_COLOR  +HAVE_START_COLOR  +HAVE_TYPEAHEAD  +HAVE_BKGDSET
 +HAVE_CURS_SET  +HAVE_META  +HAVE_RESIZETERM
 +HAVE_PGP  -BUFFY_SIZE -EXACT_ADDRESS  -SUN_ATTACHMENT
 +ENABLE_NLS  -LOCALES_HACK  +HAVE_WC_FUNCS  +HAVE_LANGINFO_CODESET
 +HAVE_LANGINFO_YESEXPR
 +HAVE_ICONV  +ICONV_NONTRANS  +HAVE_GETSID  -HAVE_GETADDRINFO
 ISPELL="/usr/local/bin/ispell"
 SENDMAIL="/usr/lib/sendmail"
 MAILPATH="/var/mail"
 SHAREDIR="/usr/local/share/mutt"
 SYSCONFDIR="/usr/local/etc"
 EXECSHELL="/bin/sh"
 -MIXMASTER
 To contact the developers, please mail to <mutt-dev@xxxxxxxx>.
 To report a bug, please use the flea(1) utility.


 >How-To-Repeat:
 >Fix:
 }}}

--

-- 
Ticket URL: <http://dev.mutt.org/trac/ticket/408#comment:1>
Mutt <http://www.mutt.org/>
The Mutt mail user agent