* On 27 Jan 2015, Yoshiki Vazquez Baeza wrote:
> Hello,
>
> This patch adds a new setting that you can configure to execute a
> command every time new mail is found in your current mailbox.
Hi Yoshiki -
Code-wise, this looks good. I would support adding this to mutt. I
have some in-progress work that intersects with this but I don't think
there's a blocking conflict. I'll post minor comments on this patch
as if it's completely independent, and send another message about the
intersection with my work. Please read both before doing anything. :)
> changeset: 6404:41baf119bb70
> tag: tip
> user: Yoshiki Vazquez Baeza
> date: Tue Jan 27 14:09:59 2015 -0700
> summary: Add setting to execute a command when receiving new mail
>
> diff -r ec93761e3e12 -r 41baf119bb70 curs_main.c
> --- a/curs_main.c Fri Jan 23 10:33:32 2015 -0800
> +++ b/curs_main.c Tue Jan 27 14:09:59 2015 -0700
> @@ -575,6 +575,12 @@
> mutt_message _("New mail in this mailbox.");
> if (option (OPTBEEPNEW))
> beep ();
> + if (NewCmd)
Please resubmit with NewCmd changed to NewMailCmd or something similar.
NewCmd is a little too ambiguous I think; the change will make the code
more self-explanatory.
> + {
> + char cmd[LONG_STRING];
> + menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewCmd));
> + mutt_system(cmd);
> + }
> } else if (check == M_FLAGS)
> mutt_message _("Mailbox was externally modified.");
>
> @@ -596,8 +602,17 @@
> menu->redraw |= REDRAW_STATUS;
> if (do_buffy_notify)
> {
> - if (mutt_buffy_notify () && option (OPTBEEPNEW))
> - beep ();
> + if (mutt_buffy_notify ())
> + {
> + if (option (OPTBEEPNEW))
> + beep ();
> + if (NewCmd)
> + {
> + char cmd[LONG_STRING];
> + menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewCmd));
> + mutt_system(cmd);
> + }
> + }
> }
> else
> do_buffy_notify = 1;
> diff -r ec93761e3e12 -r 41baf119bb70 globals.h
> --- a/globals.h Fri Jan 23 10:33:32 2015 -0800
> +++ b/globals.h Tue Jan 27 14:09:59 2015 -0700
> @@ -111,6 +111,7 @@
> WHERE char *PostponeEncryptAs;
> WHERE char *Prefix;
> WHERE char *PrintCmd;
> +WHERE char *NewCmd;
> WHERE char *QueryCmd;
> WHERE char *QueryFormat;
> WHERE char *Realname;
> diff -r ec93761e3e12 -r 41baf119bb70 init.h
> --- a/init.h Fri Jan 23 10:33:32 2015 -0800
> +++ b/init.h Tue Jan 27 14:09:59 2015 -0700
> @@ -290,6 +290,13 @@
> { "beep", DT_BOOL, R_NONE, OPTBEEP, 1 },
> /*
> ** .pp
> + ** If \fIset\fP, Mutt will call this command after a new message is
> received.
> + ** See the $$status_format documentation for the values that can be
> formatted
> + ** into this command.
> + */
> + { "new_command", DT_PATH, R_NONE, UL &NewCmd, UL NULL },
Similarly, make this newmail_command, new_mail_command, something like that.
> + /*
> + ** .pp
> ** When this variable is \fIset\fP, mutt will beep when an error occurs.
> */
> { "beep_new", DT_BOOL, R_NONE, OPTBEEPNEW, 0 },
>
Finally, a mention of this in the New Mail Detection section of the
manual would be appropriate; just make it part of the resubitted patch.
A sentence or two is fine, with a link back to the $newmail_command
documentation. The source file is doc/manual.xml.head and its published
form is at: http://dev.mutt.org/doc/manual.html#new-mail
Thanks!
--
David Champion • [email protected]