** 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 *);
/*
.RB [ \-use " | " \-nouse ]
.RB [ \-editor
.IR editor ]
-.RB [ \-noedit ]
.RB [ \-whatnowproc
.IR program ]
.RB [ \-version ]
.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
.RB [ \-annotate " | " \-noannotate ]
.RB [ \-editor
.IR editor ]
-.RB [ \-noedit ]
.RB [ \-whatnowproc
.IR program ]
.RB [ \-version ]
.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
.IR formfile ]
.RB [ \-editor
.IR editor ]
-.RB [ \-noedit ]
.RB [ \-whatnowproc
.IR program ]
.RB [ \-build ]
.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.
.RB [ \-mime " | " \-nomime ]
.RB [ \-editor
.IR editor ]
-.RB [ \-noedit ]
.RB [ \-whatnowproc
.IR program ]
.RB [ \-build ]
.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
.B whatnow
.RB [ \-editor
.IR editor ]
-.RB [ \-noedit ]
.RB [ \-prompt
.IR string ]
.RI [ file ]
.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:
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 }
};
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;
case EDITRSW:
if (!(ed = *argp++) || *ed == '-')
adios(NULL, "missing argument to %s", argp[-2]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
continue;
case WHATSW:
}
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;
}
{ "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 }
};
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;
if (!(ed = *argp++) || *ed == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
continue;
case WHATSW:
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;
}
{ "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
{
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;
if (!(ed = *argp++) || *ed == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
continue;
case WHATSW:
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;
{ "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 }
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];
if (!(ed = *argp++) || *ed == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
continue;
case WHATSW:
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;
}
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 }
};
** 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 *);
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];
if (!(ed = *argp++) || *ed == '-')
adios(NULL, "missing argument to %s",
argp[-2]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
continue;
case PRMPTSW:
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 (;;) {
if (*++argp)
ed = *argp++;
if (editfile(&ed, argp, drft, NOUSE, NULL,
- msgnam, NULL, 1) == NOTOK)
+ msgnam, NULL) == NOTOK)
done(1);
break;
** 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];
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) {
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 &&
#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)
** 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;
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);