From d665003ed05ae95d857f8a50c5078c19d9b5a566 Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Sat, 26 May 2018 00:20:44 +0200 Subject: [PATCH] print_headers(): do not compress subjects when displaying newmail etc. --- cmd-headers.c | 35 ++++++++++++++++++++--------------- folder.c | 12 +++++++++--- nailfuns.h | 9 +++++++-- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/cmd-headers.c b/cmd-headers.c index d05ab1cf..2cf45e69 100644 --- a/cmd-headers.c +++ b/cmd-headers.c @@ -51,12 +51,13 @@ static void _parse_from_(struct message *mp, char date[n_FROM_DATEBUF]); * a_cmd__putuc: print out a Unicode character or a substitute for it, return * 0 on error or wcwidth() (or 1) on success */ static void a_cmd_print_head(size_t yetprinted, size_t msgno, FILE *f, - bool_t threaded); + bool_t threaded, bool_t subject_thread_compress); static void a_cmd__hprf(size_t yetprinted, char const *fmt, size_t msgno, - FILE *f, bool_t threaded, char const *attrlist); + FILE *f, bool_t threaded, bool_t subject_thread_compress, + char const *attrlist); static char *a_cmd__subject(struct message *mp, bool_t threaded, - size_t yetprinted); + bool_t subject_thread_compress, size_t yetprinted); static int a_cmd__putindent(FILE *fp, struct message *mp, int maxwidth); static size_t a_cmd__putuc(int u, int c, FILE *fp); static int a_cmd__dispc(struct message *mp, char const *a); @@ -85,7 +86,8 @@ _parse_from_(struct message *mp, char date[n_FROM_DATEBUF]) /* TODO line pool */ } static void -a_cmd_print_head(size_t yetprinted, size_t msgno, FILE *f, bool_t threaded){ +a_cmd_print_head(size_t yetprinted, size_t msgno, FILE *f, bool_t threaded, + bool_t subject_thread_compress){ enum {attrlen = 14}; char attrlist[attrlen +1], *cp; char const *fmt; @@ -122,13 +124,14 @@ jattrok: : "%>%a%m %-18f %-16d %4l/%-5o %i%-s"); } - a_cmd__hprf(yetprinted, fmt, msgno, f, threaded, attrlist); + a_cmd__hprf(yetprinted, fmt, msgno, f, threaded, subject_thread_compress, + attrlist); NYD2_LEAVE; } static void a_cmd__hprf(size_t yetprinted, char const *fmt, size_t msgno, FILE *f, - bool_t threaded, char const *attrlist) + bool_t threaded, bool_t subject_thread_compress, char const *attrlist) { char buf[16], datebuf[n_FROM_DATEBUF], cbuf[8], *cp, *subjline; char const *datefmt, *date, *name, *fp n_COLOUR( COMMA *colo_tag ); @@ -504,7 +507,7 @@ jputcb: break; if (subjline == NULL) subjline = a_cmd__subject(mp, (threaded && (flags & _IFMT)), - yetprinted); + subject_thread_compress, yetprinted); if (subjline == (char*)-1) { n = fprintf(f, "%*s", n, n_empty); wleft = (n >= 0) ? wleft - n : 0; @@ -568,7 +571,8 @@ jputcb: } static char * -a_cmd__subject(struct message *mp, bool_t threaded, size_t yetprinted) +a_cmd__subject(struct message *mp, bool_t threaded, + bool_t subject_thread_compress, size_t yetprinted) { struct str in, out; char *rv, *ms; @@ -583,7 +587,7 @@ a_cmd__subject(struct message *mp, bool_t threaded, size_t yetprinted) mime_fromhdr(&in, &out, TD_ICONV | TD_ISPR); rv = ms = out.s; - if (!threaded || mp->m_level == 0) + if (!threaded || !subject_thread_compress || mp->m_level == 0) goto jleave; /* In a display thread - check whether this message uses the same @@ -934,14 +938,13 @@ jdot_unsort: } } ++flag; - a_cmd_print_head(0, mesg, n_stdout, 0); + a_cmd_print_head(0, mesg, n_stdout, FAL0, FAL0); srelax(); } if(needdot && ok_blook(showlast)) /* xxx will not show */ setdot(lastmq); srelax_rele(); n_COLOUR( n_colour_env_gut(); ) - } else { /* threaded */ g = 0; mq = threadroot; @@ -990,7 +993,7 @@ jdot_sort: } } a_cmd_print_head(flag, PTR2SIZE(mp - message + 1), n_stdout, - mb.mb_threaded); + mb.mb_threaded, TRU1); ++flag; srelax(); } @@ -1125,7 +1128,7 @@ c_from(void *vp) n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM, obuf, obuf != n_stdout); ) srelax_hold(); for (n = 0, ip = msgvec; *ip != 0; ++ip) { /* TODO join into _print_head() */ - a_cmd_print_head((size_t)n++, (size_t)*ip, obuf, mb.mb_threaded); + a_cmd_print_head((size_t)n++, (size_t)*ip, obuf, mb.mb_threaded, FAL0); srelax(); } srelax_rele(); @@ -1139,7 +1142,8 @@ jleave: } FL void -print_headers(size_t bottom, size_t topx, bool_t only_marked) +print_headers(size_t bottom, size_t topx, bool_t only_marked, + bool_t subject_thread_compress) { size_t printed; NYD_ENTER; @@ -1159,7 +1163,8 @@ print_headers(size_t bottom, size_t topx, bool_t only_marked) continue; } else if (!visible(mp)) continue; - a_cmd_print_head(printed++, bottom, n_stdout, FAL0); + a_cmd_print_head(printed++, bottom, n_stdout, FAL0, + subject_thread_compress); srelax(); } srelax_rele(); diff --git a/folder.c b/folder.c index 46520781..7accf9a1 100644 --- a/folder.c +++ b/folder.c @@ -662,8 +662,8 @@ newmailinfo(int omsgCount) mdot = getmdot(1); - if (ok_blook(header)) - print_headers(omsgCount + 1, msgCount, FAL0); + if(ok_blook(header)) + print_headers(omsgCount + 1, msgCount, FAL0, FAL0); NYD_LEAVE; return mdot; } @@ -706,7 +706,13 @@ print_header_summary(char const *Larg) } } else bot = 1, top = msgCount; - print_headers(bot, top, (Larg != NULL)); /* TODO should take iterator!! */ + + /* C99 */{ + bool_t isLarg; + + isLarg = (Larg != NULL); + print_headers(bot, top, isLarg, !isLarg); /* TODO should be iterator! */ + } jleave: NYD_LEAVE; } diff --git a/nailfuns.h b/nailfuns.h index 835b8170..42d5b1c9 100644 --- a/nailfuns.h +++ b/nailfuns.h @@ -518,8 +518,13 @@ FL int c_dotmove(void *v); FL int c_from(void *v); /* Print all message in between and including bottom and topx if they are - * visible and either only_marked is false or they are MMARKed */ -FL void print_headers(size_t bottom, size_t topx, bool_t only_marked); + * visible and either only_marked is false or they are MMARKed. + * TODO If subject_thread_compress is true then a subject will not be printed + * TODO if it equals the subject of the message "above"; as this only looks + * TODO in the thread neighbour and NOT in the "visible" neighbour, the caller + * TODO has to ensure the result will look sane; DROP + make it work (tm) */ +FL void print_headers(size_t bottom, size_t topx, bool_t only_marked, + bool_t subject_thread_compress); /* * cmd-message.c -- 2.11.4.GIT