From: Ken Hornstein Date: Sat, 9 Nov 2013 15:39:48 +0000 (-0500) Subject: Add support for -changecur and -nochangecur to mhlist(1). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/24fb3aa13c05253e65730e1587def692a598c607?ds=inline;hp=--cc Add support for -changecur and -nochangecur to mhlist(1). --- 24fb3aa13c05253e65730e1587def692a598c607 diff --git a/docs/pending-release-notes b/docs/pending-release-notes index b04f610c..8295c33e 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -57,6 +57,7 @@ NEW FEATURES connection with the -initialtls switch. - Messages can now be selected using a relative offset from some other message, or from the start or end of a sequence. See mh-sequences(5). +- The -changecur and -nochangecur switches have been added to mhlist(1). ----------------- OBSOLETE FEATURES diff --git a/man/mhlist.man b/man/mhlist.man index bd8f0802..46b75636 100644 --- a/man/mhlist.man +++ b/man/mhlist.man @@ -25,6 +25,7 @@ mhlist \- list information about MIME messages .RB [ \-wcache .IR policy ] .RB [ \-check " | " \-nocheck ] +.RB [ \-changecur " | " \-nochangecur ] .RB [ \-verbose " | " \-noverbose ] .RB [ \-version ] .RB [ \-help ] @@ -184,8 +185,11 @@ integrity of the content. .RB ` \-realsize ' .RB ` \-rcache\ ask ' .RB ` \-wcache\ ask ' +.RB ` \-changecur ' .RB ` \-noverbose ' .fi .SH CONTEXT If a folder is given, it will become the current folder. The last -message selected will become the current message. +message selected will become the current message, unless the +.B \-nochangecur +option is specified. diff --git a/test/mhlist/test-mhlist b/test/mhlist/test-mhlist index cb793670..ad0fb4bb 100755 --- a/test/mhlist/test-mhlist +++ b/test/mhlist/test-mhlist @@ -172,6 +172,13 @@ run_test 'mhlist last -part 2 -noheader -check -nocheck' \ 1 multipart/related 180 2 text/plain 36' +# +# Set the cur sequence to 1 to test default behavior of changecur after +# this test. +# + +mark 1 -sequence cur -add -zero + # check -verbose run_test 'mhlist 11 -verbose -noheader' \ ' 11 multipart/mixed 936 @@ -189,5 +196,18 @@ run_test 'mhlist 11 -verbose -noheader' \ 4 text/plain 36 charset="iso-8859-1"' +# +# Check default changecur behavior +# + +run_test 'mark -sequence cur -list' 'cur: 11' + +# +# Now test -nochangecur +# + +mhlist -nochangecur 1 >/dev/null + +run_test 'mark -sequence cur -list' 'cur: 11' exit $failed diff --git a/uip/mhlist.c b/uip/mhlist.c index c63cf888..f6208ddb 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -32,6 +32,8 @@ X("type content", 0, TYPESW) \ X("rcache policy", 0, RCACHESW) \ X("wcache policy", 0, WCACHESW) \ + X("changecur", 0, CHGSW) \ + X("nochangecur", 0, NCHGSW) \ X("version", 0, VERSIONSW) \ X("help", 0, HELPSW) \ X("debug", -5, DEBUGSW) \ @@ -96,7 +98,7 @@ static void pipeser (int); int main (int argc, char **argv) { - int sizesw = 1, headsw = 1; + int sizesw = 1, headsw = 1, chgflag = 1; int msgnum, *icachesw; char *cp, *file = NULL, *folder = NULL; char *maildir, buf[100], **argp; @@ -203,6 +205,13 @@ do_cache: file = *cp == '-' ? cp : path (cp, TFILE); continue; + case CHGSW: + chgflag++; + continue; + case NCHGSW: + chgflag = 0; + continue; + case VERBSW: verbosw = 1; continue; @@ -341,7 +350,8 @@ do_cache: /* If reading from a folder, do some updating */ if (mp) { context_replace (pfolder, folder);/* update current folder */ - seq_setcur (mp, mp->hghsel); /* update current message */ + if (chgflag) + seq_setcur (mp, mp->hghsel); /* update current message */ seq_save (mp); /* synchronize sequences */ context_save (); /* save the context file */ }