From: markus schnalke Date: Mon, 30 Apr 2012 20:58:54 +0000 (+0200) Subject: Removed the -noeditor switches and made them replaceable by `-editor ""'. X-Git-Tag: mmh-thesis-end~71 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=75fca31a5b9d5c1a99c74ab14c94438d8852fba9;p=mmh Removed the -noeditor switches and made them replaceable by `-editor ""'. --- diff --git a/h/prototypes.h b/h/prototypes.h index d8231f5..20820b5 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -119,7 +119,7 @@ int strncasecmp(const char *s1, const char *s2, size_t n); ** prototypes for some routines in uip */ int distout(char *, char *, char *); -int what_now(char *, int, int, char *, char *, int, struct msgs *, +int what_now(char *, int, char *, char *, int, struct msgs *, char *, char *); /* diff --git a/man/comp.man1 b/man/comp.man1 index f9b59db..5ea88aa 100644 --- a/man/comp.man1 +++ b/man/comp.man1 @@ -15,7 +15,6 @@ comp \- compose a message .RB [ \-use " | " \-nouse ] .RB [ \-editor .IR editor ] -.RB [ \-noedit ] .RB [ \-whatnowproc .IR program ] .RB [ \-version ] @@ -25,9 +24,10 @@ comp \- compose a message .B Comp is used to create a new message to be mailed. It copies a message form to the draft being composed and then invokes an editor on -the draft (unless -.B \-noedit -is given, in which case the initial edit is suppressed). +the draft (unless the +.B \-edit +switch with an empty string argument is given, +in which case the initial edit is suppressed). .PP The default message form contains the following elements: .PP diff --git a/man/dist.man1 b/man/dist.man1 index aaaa612..df4173a 100644 --- a/man/dist.man1 +++ b/man/dist.man1 @@ -15,7 +15,6 @@ dist \- redistribute a message to additional addresses .RB [ \-annotate " | " \-noannotate ] .RB [ \-editor .IR editor ] -.RB [ \-noedit ] .RB [ \-whatnowproc .IR program ] .RB [ \-version ] @@ -84,9 +83,7 @@ See .BR comp (1) for a description of the .B \-editor -and -.B \-noedit -switches. Note that while in the editor, the message being resent +switch. Note that while in the editor, the message being resent is available through a link named \*(lq@\*(rq (assuming the default .IR whatnowproc ). In addition, the actual pathname of the message is diff --git a/man/forw.man1 b/man/forw.man1 index a970a3e..378ce70 100644 --- a/man/forw.man1 +++ b/man/forw.man1 @@ -15,7 +15,6 @@ forw \- forward messages .IR formfile ] .RB [ \-editor .IR editor ] -.RB [ \-noedit ] .RB [ \-whatnowproc .IR program ] .RB [ \-build ] @@ -89,9 +88,7 @@ See .BR comp (1) for a description of the .B \-editor -and -.B \-noedit -switches. +switch. .PP .B Forw generates an attachment header field for the messages to be forwarded. diff --git a/man/repl.man1 b/man/repl.man1 index f8f6eb1..6b7c485 100644 --- a/man/repl.man1 +++ b/man/repl.man1 @@ -25,7 +25,6 @@ all/to/cc/me] .RB [ \-mime " | " \-nomime ] .RB [ \-editor .IR editor ] -.RB [ \-noedit ] .RB [ \-whatnowproc .IR program ] .RB [ \-build ] @@ -178,9 +177,7 @@ See .BR comp (1) for a description of the .B \-editor -and -.B \-noedit -switches. Note that while in the editor, the message being replied +switch. Note that while in the editor, the message being replied to is available through a link named \*(lq@\*(rq (assuming the default .IR whatnowproc ). In addition, the actual pathname of the message is diff --git a/man/whatnow.man1 b/man/whatnow.man1 index ce6c9c2..42956c1 100644 --- a/man/whatnow.man1 +++ b/man/whatnow.man1 @@ -10,7 +10,6 @@ whatnow \- prompting front-end for sending messages .B whatnow .RB [ \-editor .IR editor ] -.RB [ \-noedit ] .RB [ \-prompt .IR string ] .RI [ file ] @@ -31,9 +30,10 @@ or .B repl after the initial edit. .PP -When started, the editor is started on the draft (unless -.B \-noedit -is given, in which case the initial edit is suppressed). Then, +When started, the editor is started on the draft (unless the +.B \-edit +switch with an empty string argument is given, +in which case the initial edit is suppressed). Then, .B whatnow repetitively prompts the user with \*(lqWhat now?\*(rq and awaits a response. The valid responses are: diff --git a/uip/comp.c b/uip/comp.c index cbe24d8..5c088a8 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -13,19 +13,17 @@ static struct swit switches[] = { #define EDITRSW 0 { "editor editor", 0 }, -#define NEDITSW 1 - { "noedit", 0 }, -#define FORMSW 2 +#define FORMSW 1 { "form formfile", 0 }, -#define USESW 3 +#define USESW 2 { "use", 0 }, -#define NUSESW 4 +#define NUSESW 3 { "nouse", 0 }, -#define WHATSW 5 +#define WHATSW 4 { "whatnowproc program", 0 }, -#define VERSIONSW 6 +#define VERSIONSW 5 { "version", 0 }, -#define HELPSW 7 +#define HELPSW 6 { "help", 0 }, { NULL, 0 } }; @@ -34,7 +32,7 @@ static struct swit switches[] = { int main(int argc, char **argv) { - int use = NOUSE, nedit = 0; + int use = NOUSE; int in, out; char *cp, *cwd, *maildir; char *ed = NULL, *form = NULL; @@ -75,10 +73,6 @@ main(int argc, char **argv) case EDITRSW: if (!(ed = *argp++) || *ed == '-') adios(NULL, "missing argument to %s", argp[-2]); - nedit = 0; - continue; - case NEDITSW: - nedit++; continue; case WHATSW: @@ -170,7 +164,7 @@ main(int argc, char **argv) } context_save(); - what_now(ed, nedit, use, drft, NULL, 0, NULLMP, NULL, cwd); + what_now(ed, use, drft, NULL, 0, NULLMP, NULL, cwd); done(1); return 1; } diff --git a/uip/dist.c b/uip/dist.c index b169352..57efc4e 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -17,15 +17,13 @@ static struct swit switches[] = { { "noannotate", 0 }, #define EDITRSW 2 { "editor editor", 0 }, -#define NEDITSW 3 - { "noedit", 0 }, -#define FORMSW 4 +#define FORMSW 3 { "form formfile", 0 }, -#define WHATSW 5 +#define WHATSW 4 { "whatnowproc program", 0 }, -#define VERSIONSW 6 +#define VERSIONSW 5 { "version", 0 }, -#define HELPSW 7 +#define HELPSW 6 { "help", 0 }, { NULL, 0 } }; @@ -34,7 +32,7 @@ static struct swit switches[] = { int main(int argc, char **argv) { - int anot = 0, nedit = 0; + int anot = 0; int in, out; char *cp, *cwd, *maildir, *msgnam; char *ed = NULL, *folder = NULL; @@ -82,10 +80,6 @@ main(int argc, char **argv) if (!(ed = *argp++) || *ed == '-') adios(NULL, "missing argument to %s", argp[-2]); - nedit = 0; - continue; - case NEDITSW: - nedit++; continue; case WHATSW: @@ -159,8 +153,7 @@ main(int argc, char **argv) seq_save(mp); /* synchronize sequences */ context_save(); - what_now(ed, nedit, NOUSE, drft, msgnam, 1, mp, - anot ? "Resent" : NULL, cwd); + what_now(ed, NOUSE, drft, msgnam, 1, mp, anot ? "Resent" : NULL, cwd); done(1); return 1; } diff --git a/uip/forw.c b/uip/forw.c index 4fbd45f..fe056f4 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -23,21 +23,19 @@ static struct swit switches[] = { { "noannotate", 0 }, #define EDITRSW 2 { "editor editor", 0 }, -#define NEDITSW 3 - { "noedit", 0 }, -#define FORMSW 4 +#define FORMSW 3 { "form formfile", 0 }, -#define DGSTSW 5 +#define DGSTSW 4 { "digest list", 0 }, -#define ISSUESW 6 +#define ISSUESW 5 { "issue number", 0 }, -#define VOLUMSW 7 +#define VOLUMSW 6 { "volume number", 0 }, -#define WHATSW 8 +#define WHATSW 7 { "whatnowproc program", 0 }, -#define VERSIONSW 9 +#define VERSIONSW 8 { "version", 0 }, -#define HELPSW 10 +#define HELPSW 9 { "help", 0 }, #ifdef MHE @@ -64,7 +62,7 @@ main(int argc, char **argv) { int msgp = 0, anot = 0; int issue = 0, volume = 0; - int nedit = 0, in; + int in; int out, msgnum; char *cp, *cwd, *maildir; char *digest = NULL, *ed = NULL; @@ -116,10 +114,6 @@ main(int argc, char **argv) if (!(ed = *argp++) || *ed == '-') adios(NULL, "missing argument to %s", argp[-2]); - nedit = 0; - continue; - case NEDITSW: - nedit++; continue; case WHATSW: @@ -258,7 +252,7 @@ main(int argc, char **argv) if (buildsw) done(0); - what_now(ed, nedit, NOUSE, drft, NULL, 0, mp, + what_now(ed, NOUSE, drft, NULL, 0, mp, anot ? "Forwarded" : NULL, cwd); done(1); return 1; diff --git a/uip/repl.c b/uip/repl.c index b0956fc..4523365 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -29,32 +29,30 @@ static struct swit switches[] = { { "nocc type", 0 }, #define EDITRSW 6 { "editor editor", 0 }, -#define NEDITSW 7 - { "noedit", 0 }, -#define FILTSW 8 +#define FILTSW 7 { "filter filterfile", 0 }, -#define NFILTSW 9 +#define NFILTSW 8 { "nofilter", 0 }, -#define FORMSW 10 +#define FORMSW 9 { "form formfile", 0 }, -#define MIMESW 11 +#define MIMESW 10 { "mime", 0 }, -#define NMIMESW 12 +#define NMIMESW 11 { "nomime", 0 }, -#define QURYSW 13 +#define QURYSW 12 { "query", 0 }, -#define NQURYSW 14 +#define NQURYSW 13 { "noquery", 0 }, -#define WHATSW 15 +#define WHATSW 14 { "whatnowproc program", 0 }, -#define VERSIONSW 16 +#define VERSIONSW 15 { "version", 0 }, -#define HELPSW 17 +#define HELPSW 16 { "help", 0 }, -#define FILESW 18 +#define FILESW 17 { "file file", 4 }, /* interface from msh */ #ifdef MHE -# define BILDSW 19 +# define BILDSW 18 { "build", 5 }, /* interface from mhe */ #endif { NULL, 0 } @@ -137,7 +135,6 @@ int main(int argc, char **argv) { int anot = 0; - int nedit = 0; char *cp, *cwd, *maildir, *file = NULL; char *folder = NULL, *msg = NULL; char *ed = NULL, drft[BUFSIZ], buf[BUFSIZ]; @@ -210,10 +207,6 @@ main(int argc, char **argv) if (!(ed = *argp++) || *ed == '-') adios(NULL, "missing argument to %s", argp[-2]); - nedit = 0; - continue; - case NEDITSW: - nedit++; continue; case WHATSW: @@ -358,8 +351,7 @@ main(int argc, char **argv) if (buildsw) done(0); - what_now(ed, nedit, NOUSE, drft, msg, 0, mp, anot ? "Replied" : NULL, - cwd); + what_now(ed, NOUSE, drft, msg, 0, mp, anot ? "Replied" : NULL, cwd); done(1); return 1; } diff --git a/uip/whatnow.c b/uip/whatnow.c index efdf02d..08e3be8 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -45,13 +45,11 @@ static struct swit whatnowswitches[] = { #define EDITRSW 0 { "editor editor", 0 }, -#define NEDITSW 1 - { "noedit", 0 }, -#define PRMPTSW 2 +#define PRMPTSW 1 { "prompt string", 4 }, -#define VERSIONSW 3 +#define VERSIONSW 2 { "version", 0 }, -#define HELPSW 4 +#define HELPSW 3 { "help", 0 }, { NULL, 0 } }; @@ -95,7 +93,7 @@ static char *myprompt = "\nWhat now? "; ** static prototypes */ static int editfile(char **, char **, char *, int, struct msgs *, - char *, char *, int); + char *, char *); static int sendfile(char **, char *); static int refile(char **, char *); static int removefile(char *); @@ -113,7 +111,7 @@ static int copyf(char *, char *); int main(int argc, char **argv) { - int nedit = 0, use = 0; + int use = 0; char *cp; char *ed = NULL, *drft = NULL, *msgnam = NULL; char buf[BUFSIZ], prompt[BUFSIZ]; @@ -168,10 +166,6 @@ main(int argc, char **argv) if (!(ed = *argp++) || *ed == '-') adios(NULL, "missing argument to %s", argp[-2]); - nedit = 0; - continue; - case NEDITSW: - nedit++; continue; case PRMPTSW: @@ -196,15 +190,16 @@ main(int argc, char **argv) if ((cp = getenv("mhuse")) && *cp) use = atoi(cp); - if (!ed && (!(ed = getenv("mheditor")) || !*ed)) { - ed = NULL; - nedit++; + if (!ed && !(ed = getenv("mheditor"))) { + ed = ""; /* Don't initially edit the draft */ } - /* start editing the draft, unless -noedit was given */ - if (!nedit && editfile(&ed, NULL, drft, use, NULL, msgnam, NULL, 1) - < 0) - done(1); + /* start editing the draft, unless editor is the empty string */ + if (*ed) { + if (editfile(&ed, NULL, drft, use, NULL, msgnam, NULL) <0) { + done(1); + } + } snprintf(prompt, sizeof(prompt), myprompt, invo_name); for (;;) { @@ -229,7 +224,7 @@ main(int argc, char **argv) if (*++argp) ed = *argp++; if (editfile(&ed, argp, drft, NOUSE, NULL, - msgnam, NULL, 1) == NOTOK) + msgnam, NULL) == NOTOK) done(1); break; @@ -574,13 +569,12 @@ popen_in_dir(const char *dir, const char *cmd, const char *type) ** EDIT */ -static int reedit = 0; /* have we been here before? */ static char *edsave = NULL; /* the editor we used previously */ static int editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, - char *altmsg, char *cwd, int save_editor) + char *altmsg, char *cwd) { int pid, status, vecp; char altpath[BUFSIZ], linkpath[BUFSIZ]; @@ -591,21 +585,22 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, int slinked = 0; #endif /* HAVE_LSTAT */ - /* Was there a previous edit session? */ - if (reedit) { - if (!*ed) { /* no explicit editor */ - *ed = edsave; /* so use the previous one */ + if (!*ed || !**ed) { + /* We have no explicit editor. */ + if (edsave) { + /* Use the previous editor ... */ + *ed = edsave; if (!(cp = mhbasename(*ed))) cp = *ed; - /* unless we've specified it via "editor-next" */ + /* but prefer one specified via "editor-next" */ cp = concat(cp, "-next", NULL); if ((cp = context_find(cp))) *ed = cp; + } else { + /* set initial editor */ + *ed = defaulteditor; } - } else if (!*ed) { - /* set initial editor */ - *ed = defaulteditor; } if (altmsg) { @@ -666,18 +661,17 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, default: if ((status = pidwait(pid, NOTOK))) { if (((status & 0xff00) != 0xff00) && - (!reedit || (status & 0x00ff))) { + (!edsave || (status & 0x00ff))) { if (!use && (status & 0xff00) && (rename(file, cp = m_backup(file)) != NOTOK)) { advise(NULL, "problems with edit--draft left in %s", cp); } else { advise(NULL, "problems with edit--%s preserved", file); } } - status = -2; /* maybe "reedit ? -2 : -1"? */ + status = -2; /* maybe "edsave ? -2 : -1"? */ break; } - reedit++; #ifdef HAVE_LSTAT if (altmsg && mp && !is_readonly(mp) && (slinked ? lstat (linkpath, &st) != NOTOK && @@ -698,9 +692,8 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, #endif /* HAVE_LSTAT */ } - /* normally, we remember which editor we used */ - if (save_editor) - edsave = getcpy(*ed); + /* remember which editor we used */ + edsave = getcpy(*ed); *ed = NULL; if (altmsg) diff --git a/uip/whatnowproc.c b/uip/whatnowproc.c index fbea941..f3c46f8 100644 --- a/uip/whatnowproc.c +++ b/uip/whatnowproc.c @@ -16,7 +16,7 @@ ** then execs the command. */ int -what_now(char *ed, int nedit, int use, char *file, char *altmsg, int dist, +what_now(char *ed, int use, char *file, char *altmsg, int dist, struct msgs *mp, char *text, char *cwd) { int found, k, msgnum, vecp; @@ -48,10 +48,12 @@ what_now(char *ed, int nedit, int use, char *file, char *altmsg, int dist, m_putenv("editalt", bp); snprintf(buffer, sizeof(buffer), "%d", dist); m_putenv("mhdist", buffer); - if (nedit) { - unputenv("mheditor"); + if (!ed) { + m_putenv("mheditor", defaulteditor); + } else if (*ed) { + m_putenv("mheditor", ed); } else { - m_putenv("mheditor", ed ? ed : defaulteditor); + unputenv("mheditor"); } snprintf(buffer, sizeof(buffer), "%d", use); m_putenv("mhuse", buffer);