diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2017-06-08 22:10:16 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2017-06-08 22:16:15 +0300 |
commit | 766dd82f18c41f4fbf403e6627cb9a37a8b8a69f (patch) | |
tree | 00a1fdebf6b094e07449c7c84ee1361614c55fbf | |
parent | e7a22c4230d150f591b25ac13350da494d1da4b3 (diff) | |
download | mailutils-766dd82f18c41f4fbf403e6627cb9a37a8b8a69f.tar.gz mailutils-766dd82f18c41f4fbf403e6627cb9a37a8b8a69f.tar.bz2 |
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
-rw-r--r-- | mh/mh.h | 3 | ||||
-rw-r--r-- | mh/mh_whatnow.c | 14 |
2 files changed, 13 insertions, 4 deletions
@@ -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 diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c index 71b6b221c..5dc15b553 100644 --- a/mh/mh_whatnow.c +++ b/mh/mh_whatnow.c @@ -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; |