]> diplodocus.org Git - nmh/blobdiff - uip/show.c
pending-release-notes: add mhshow's "-prefer", and mh-format's %(kibi/kilo)
[nmh] / uip / show.c
index 5a912f6bd1074057e2606a179af728825a5699d1..e5b71eff0a24a7246bfb0d58ca778b563a50fd00 100644 (file)
     X("nofmtproc", 0, NFMTPROCSW) \
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
+    /*                         \
+     * switches for mhlproc    \
+     */                                \
+    X("concat", -6, CONCATSW) \
+    X("noconcat", -8, NCONCATSW) \
 
 #define X(sw, minchars, id) id,
 DEFINE_SWITCH_ENUM(SHOW);
@@ -53,21 +58,15 @@ int
 main (int argc, char **argv)
 {
     int draftsw = 0, headersw = 1;
-    int nshow = 0, checkmime = 1, mime;
+    int nshow = 0, checkmime = 1, mime = 0;
     int isdf = 0, mode = SHOW, msgnum;
     char *cp, *maildir, *file = NULL, *folder = NULL, *proc, *program;
     char buf[BUFSIZ], **argp, **arguments;
     struct msgs *mp = NULL;
     struct msgs_array msgs = { 0, 0, NULL };
-    struct msgs_array vec = { 0, 0, NULL };
+    struct msgs_array vec = { 0, 0, NULL }, non_mhl_vec = { 0, 0, NULL };
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     if (!strcasecmp (invo_name, "next")) {
        mode = NEXT;
@@ -83,6 +82,13 @@ main (int argc, char **argv)
                case AMBIGSW: 
                    ambigsw (cp, switches);
                    done (1);
+
+               case CONCATSW:
+               case NCONCATSW:
+                   /* mhl can't handle these, so keep them separate. */
+                   app_msgarg(&non_mhl_vec, --cp);
+                   continue;
+
                case UNKWNSW: 
                case NPROGSW:
                case NFMTPROCSW:
@@ -255,12 +261,11 @@ go_to_it: ;
     /*
      * Decide which "proc" to use
      */
-    mime = 0;
     if (nshow) {
        proc = catproc;
     } else {
        /* check if any messages are non-text MIME messages */
-       if (checkmime) {
+       if (! mime  &&  checkmime) {
            if (!draftsw && !file) {
                /* loop through selected messages and check for MIME */
                for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
@@ -285,26 +290,41 @@ go_to_it: ;
     if (folder && !draftsw && !file)
        m_putenv ("mhfolder", folder);
 
-    if (strcmp (r1bindex (proc, '/'), "mhn") == 0) {
-       /* Add "-file" if showing file or draft, */
-       if (draftsw || file) {
-           app_msgarg(&vec, vec.msgs[vec.size - 1]);
-           vec.msgs[vec.size - 2] = "-file";
-       }
-       /* and add -show for backward compatibility */
-       app_msgarg(&vec, "-show");
-    } else if (strcmp (r1bindex (proc, '/'), "mhshow") == 0) {
-       /* If "mhshow", add "-file" if showing file or draft. */
-       if (draftsw || file) {
-           app_msgarg(&vec, vec.msgs[vec.size - 1]);
-           vec.msgs[vec.size - 2] = "-file";
-       }
-    } else if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
+    if (strcmp (r1bindex (proc, '/'), "mhl") == 0) {
        /* If "mhl", then run it internally */
        argsplit_insert(&vec, "mhl", &program);
        app_msgarg(&vec, NULL);
        mhl (vec.size, vec.msgs);
        done (0);
+    } else {
+       int i;
+       char **mp;
+
+       for (i = 0, mp = non_mhl_vec.msgs; i < non_mhl_vec.size; ++i, ++mp) {
+           if (draftsw || file) {
+               /* Insert the switch before the filename. */
+               app_msgarg(&vec, vec.msgs[vec.size - 1]);
+               vec.msgs[vec.size - 2] = *mp;
+           } else {
+               app_msgarg(&vec, *mp);
+           }
+       }
+
+       if (strcmp (r1bindex (proc, '/'), "mhn") == 0) {
+           /* Add "-file" if showing file or draft, */
+           if (draftsw || file) {
+               app_msgarg(&vec, vec.msgs[vec.size - 1]);
+               vec.msgs[vec.size - 2] = "-file";
+           }
+           /* and add -show for backward compatibility */
+           app_msgarg(&vec, "-show");
+       } else if (strcmp (r1bindex (proc, '/'), "mhshow") == 0) {
+           /* If "mhshow", add "-file" if showing file or draft. */
+           if (draftsw || file) {
+               app_msgarg(&vec, vec.msgs[vec.size - 1]);
+               vec.msgs[vec.size - 2] = "-file";
+           }
+       }
     }
 
     argsplit_insert(&vec, proc, &program);