Commit 383272e0 383272e0d513559fbda73ebc9a485718e4184018 by Sergey Poznyakoff

Fix whatnow edit command

In whatnow shell, edit [program [parameters]] now calls program
with supplied parameters plus the name of the file to edit.

* mh/mh.h (mh_whatnow_env) <reedit>: New member.
* mh/mh_whatnow.c (edit): Rewrite.
* mh/whatnow.c (main): Properly handle argv[1]
* NEWS: Update.
1 parent 82c5c521
...@@ -149,6 +149,14 @@ Added support for priority and regex functions. ...@@ -149,6 +149,14 @@ Added support for priority and regex functions.
149 149
150 Debugging considerably improved. 150 Debugging considerably improved.
151 151
152 * MH suite
153
154 ** Added support for Local-Mailbox profile setting
155
156 ** Fix whatnow edit command
157
158 ** Fix bug in comp, forw, and repl: Draft-Folder setting was ignored
159
152 160
153 Version 3.2 - 2017-03-11 161 Version 3.2 - 2017-03-11
154 162
......
...@@ -216,6 +216,7 @@ struct mh_whatnow_env /* whatnow shell environment */ ...@@ -216,6 +216,7 @@ struct mh_whatnow_env /* whatnow shell environment */
216 mu_list_t anno_list; /* List of messages (mu_message_t) to annotate */ 216 mu_list_t anno_list; /* List of messages (mu_message_t) to annotate */
217 mu_mailbox_t mbox; 217 mu_mailbox_t mbox;
218 int nowhatnowproc; 218 int nowhatnowproc;
219 int reedit:1; /* Set if the editor was already invoked */
219 }; 220 };
220 221
221 #define DISP_QUIT 0 222 #define DISP_QUIT 0
......
...@@ -380,13 +380,52 @@ display (struct mh_whatnow_env *wh, int argc, char **argv, int *status) ...@@ -380,13 +380,52 @@ display (struct mh_whatnow_env *wh, int argc, char **argv, int *status)
380 380
381 /* Edit action */ 381 /* Edit action */
382 static int 382 static int
383 edit (struct mh_whatnow_env *wh, int argc, char **argv, int *status) 383 edit (struct mh_whatnow_env *wh, int argc, char **argv, int *whs)
384 { 384 {
385 char *name; 385 char const *ed;
386 int i, rc, status;
387 char **xargv;
388
389 if (wh->reedit)
390 {
391 if (argc > 1)
392 ed = argv[1];
393 else
394 {
395 char *name;
396 char const *newed;
397 mu_asprintf (&name, "%s-next", wh->editor);
398 newed = mh_global_profile_get (name, NULL);
399 free (name);
400 if (newed)
401 ed = newed;
402 }
403 }
404 else if (argc > 1)
405 ed = argv[1];
406 else
407 ed = wh->editor;
408
409 xargv = mu_calloc (argc+2, sizeof (*xargv));
410 xargv[0] = (char *)ed;
411 for (i = 1; i + 1 < argc; i++)
412 xargv[i] = argv[i+1];
413 xargv[i++] = wh->file;
414 xargv[i] = NULL;
415
416 rc = mu_spawnvp (xargv[0], xargv, &status);
417 free (xargv);
418
419 if (rc || check_exit_status (ed, status))
420 {
421 if (wh->file)
422 mu_error (_("problems with edit--%s preserved"), wh->file);
423 else
424 mu_error (_("problems with edit"));
425 }
386 426
387 mu_asprintf (&name, "%s-next", wh->editor); 427 wh->editor = ed;
388 invoke (name, wh->editor, argc, argv, wh->file, NULL); 428 wh->reedit = 1;
389 free (name);
390 429
391 return 0; 430 return 0;
392 } 431 }
......
...@@ -57,7 +57,7 @@ main (int argc, char **argv) ...@@ -57,7 +57,7 @@ main (int argc, char **argv)
57 mh_whatnow_env_from_environ_late (&wh_env); 57 mh_whatnow_env_from_environ_late (&wh_env);
58 58
59 if (argc) 59 if (argc)
60 wh_env.draftfile = argv[0]; 60 wh_env.file = argv[0];
61 else if (draftfolder) 61 else if (draftfolder)
62 { 62 {
63 if (mh_draft_message (draftfolder, draftmessage, &wh_env.file)) 63 if (mh_draft_message (draftfolder, draftmessage, &wh_env.file))
......