> > I'm thinking about adding tab completion for file and directory names
 > > for whatnowproc.  Is that on anyone's to-do list??
 > 
 > Not on my list but it be great.

Okay then, "made it work for me" patch enclosed.  I'm outa time
for now.  I'll contribute one that uses an autoconf probe soon--I'm
assuming even troglodytes won't vote for a ./configure flag.

steve 
--

--- sbr/getans.c.orig   2007-04-29 17:34:04.000000000 -0500
+++ sbr/getans.c        2010-12-19 10:33:30.000000000 -0600
@@ -14,6 +14,9 @@
 #include <setjmp.h>
 #include <signal.h>
 
+#include <readline/readline.h>
+#include <readline/history.h>
+
 static char ansbuf[BUFSIZ];
 static jmp_buf sigenv;
 
@@ -54,6 +57,7 @@
            continue;
        }
        cpp = brkstring (ansbuf, " ", NULL);
+printf("brkstring said \"%s\"\n", *cpp);
        switch (smatch (*cpp, ansp)) {
            case AMBIGSW: 
                ambigsw (*cpp, ansp);
@@ -69,6 +73,39 @@
 }
 
 
+char **
+getans_via_readline (char *prompt, struct swit *ansp)
+{
+    SIGNAL_HANDLER istat = NULL;
+    char *ans, **cpp;
+
+    for (;;) {
+        ans = readline (prompt);
+        if (ans[0] == '?' || ans[0] == 0 ) {
+            printf ("Options are:\n");
+            print_sw (ALL, ansp, "");
+            free(ans);
+           continue;
+        }
+       strcpy (ansbuf,ans); /* not sure why--but it makes brkstring() work */
+        cpp = brkstring (ansbuf, " ", NULL);
+        switch (smatch (*cpp, ansp)) {
+            case AMBIGSW:
+                ambigsw (*cpp, ansp);
+                continue;
+            case UNKWNSW:
+                printf (" -%s unknown. Hit <CR> for help.\n", *cpp);
+                continue;
+            default:
+                SIGNAL (SIGINT, istat);
+                free(ans);
+                return cpp;
+        }
+        free(ans);
+    }
+
+}
+
 static RETSIGTYPE
 intrser (int i)
 {
--- uip/whatnowsbr.c.orig       2008-05-22 05:42:10.000000000 -0500
+++ uip/whatnowsbr.c    2010-12-19 10:34:28.000000000 -0600
@@ -243,7 +243,7 @@
 
     snprintf (prompt, sizeof(prompt), myprompt, invo_name);
     for (;;) {
-       if (!(argp = getans (prompt, aleqs))) {
+       if (!(argp = getans_via_readline (prompt, aleqs))) {
            unlink (LINK);
            done (1);
        }
_______________________________________________
Nmh-workers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/nmh-workers

Reply via email to