Commit 766dd82f 766dd82f18c41f4fbf403e6627cb9a37a8b8a69f by Sergey Poznyakoff

Re-use last invoked editor in MH whatnow

This fixes a bug introduced in d30e5a07

* mh/mh.h (mh_whatnow_env) <last_ed>: New member
* mh/mh_whatnow.c (_whatnow): Initialize reedit and last_ed members
Free last_ed before returning
(edit): Prefer wh->last_ed over wh->editor
1 parent e7a22c42
......@@ -210,13 +210,14 @@ struct mh_whatnow_env /* whatnow shell environment */
char *file; /* The file being processed */
char *msg; /* File name of the original message (if any) */
char *draftfile; /* File to preserve the draft into */
const char *editor;
const char *editor; /* Default editor */
char *prompt;
char *anno_field; /* Annotate field to be used */
mu_list_t anno_list; /* List of messages (mu_message_t) to annotate */
mu_mailbox_t mbox;
int nowhatnowproc;
int reedit:1; /* Set if the editor was already invoked */
char *last_ed; /* Last used editor */
};
#define DISP_QUIT 0
......
......@@ -323,6 +323,9 @@ _whatnow (struct mh_whatnow_env *wh, struct action_tab *tab)
size_t size = 0;
struct mu_wordsplit ws;
int wsflags = MU_WRDSF_DEFFLAGS|MU_WRDSF_COMMENT;
wh->reedit = 0;
wh->last_ed = NULL;
do
{
......@@ -360,6 +363,8 @@ _whatnow (struct mh_whatnow_env *wh, struct action_tab *tab)
while (rc == 0);
if (wsflags & MU_WRDSF_REUSE)
mu_wordsplit_free (&ws);
free (wh->last_ed);
wh->last_ed = NULL;
free (line);
return status;
}
......@@ -382,8 +387,9 @@ display (struct mh_whatnow_env *wh, int argc, char **argv, int *status)
static int
edit (struct mh_whatnow_env *wh, int argc, char **argv, int *whs)
{
char const *ed = wh->editor;
char const *ed = wh->last_ed ? wh->last_ed : wh->editor;
int i, rc, status;
char *p;
if (wh->reedit)
{
......@@ -455,8 +461,10 @@ edit (struct mh_whatnow_env *wh, int argc, char **argv, int *whs)
else
mu_error (_("problems with edit"));
}
wh->editor = ed;
p = mu_strdup (ed);
free (wh->last_ed);
wh->last_ed = p;
wh->reedit = 1;
return 0;
......