From: Paul Fox Date: Sun, 7 Jan 2018 18:12:02 +0000 (-0500) Subject: implement the long-neglected 'folder -noprint' X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ac2fd62f85758155fd220e6ea47282cc11ae6c24?ds=inline implement the long-neglected 'folder -noprint' --- diff --git a/man/folder.man b/man/folder.man index ad8fbeed..a4be417c 100644 --- a/man/folder.man +++ b/man/folder.man @@ -21,7 +21,7 @@ folder, folders \- set/list current nmh folder/message .RB [ \-list " | " \-nolist ] .RB [ \-push " | " \-pop ] .RB [ \-pack " | " \-nopack ] -.RB [ \-print ] +.RB [ \-print " | " \-noprint ] .RB [ \-verbose " | " \-noverbose ] .HP 5 .B folders @@ -57,7 +57,14 @@ argument is given, this corresponds to a \*(lqcd\*(rq operation in the shell; when no .I +folder argument is given, this corresponds roughly to a \*(lqpwd\*(rq -operation in the shell.) +operation in the shell.) If +.B \-noprint +is specified, a +.I +folder +and/or +.I msg +may still be specified to set the current folder and/or message, +but the folder summary will not be printed. .PP If the specified (or default) folder doesn't exist, .B folder @@ -75,12 +82,6 @@ Specifying will cause .B folder to print an error message and exit without creating a folder. -.\" -.\" note - this doesn't work at present -.\" If `\-noprint' is specified, -.\" a `+folder' and/or `msg' may still be specified -.\" to set the current folder and/or message, -.\" but the folder summary will not be printed. .SS "Multiple Folders" Specifying .B \-all @@ -249,8 +250,9 @@ to the \*(lqdirs\*(rq operation in the shell. The .BR \-pop , and .B \-list -switches all disable -.BR \-print . +switches disable the default +.B \-print +behavior. .SH FILES .TP 20 $HOME/.mh_profile @@ -297,12 +299,12 @@ msg \-noverbose .TP \-print -is the default if no +is the default if none of .BR -list , .BR \-push , or .B \-pop -is specified. +are specified. .TP \-list is the default if diff --git a/uip/folder.c b/uip/folder.c index a41e7fe6..8a794981 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -130,7 +130,7 @@ nonexistent_folder (int status) int main (int argc, char **argv) { - bool printsw = false; + int printsw = -1; bool listsw = false; bool pushsw = false; bool popsw = false; @@ -224,10 +224,10 @@ main (int argc, char **argv) continue; case PRNTSW: - printsw = true; + printsw = 1; continue; case NPRNTSW: - printsw = false; + printsw = 0; continue; case LISTSW: @@ -265,11 +265,13 @@ main (int argc, char **argv) nmhdir = concat (m_maildir (""), "/", NULL); /* - * If we aren't working with the folder stack - * (-push, -pop, -list) then the default is to print. + * If not directed via -print/-noprint, we print folder summary + * info unless if we're working with the folder stack (i.e., + * -push, -pop, or -list). */ - if (!pushsw && !popsw && !listsw) - printsw = true; + if (printsw == -1) { + printsw = !(pushsw || popsw || listsw); + } /* Pushing a folder onto the folder stack */ if (pushsw) { @@ -394,7 +396,8 @@ main (int argc, char **argv) /* * Print out folder information */ - print_folders(); + if (printsw) + print_folders(); context_save (); /* save the context file */ done (0);