Commit 97bc33dc authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Add echo command.

Prints messages using mutt_message().  Sets OPTFORCEREFRESH to allow
updates in the middle of a macro.

Calls mutt_sleep(0) to pause for $sleep_time seconds after displaying
the message.
parent 92ae6db7
Pipeline #21473085 passed with stages
in 13 minutes and 16 seconds
......@@ -6507,6 +6507,36 @@ macro pager \cb |urlview\n
</sect1>
<sect1 id="echo">
<title>Echoing Text</title>
<para>
Usage:
</para>
<cmdsynopsis>
<command>echo</command>
<arg choice="plain">
<replaceable class="parameter">message</replaceable>
</arg>
</cmdsynopsis>
<para>
You can print messages to the message window using the "echo" command.
This might be useful after a macro finishes executing. After printing
the message, echo will pause for the number of seconds specified by
<link linkend="sleep-time">$sleep_time</link>.
</para>
<screen>
echo "Sourcing muttrc file"
unset confirmappend
macro index ,a "&lt;save-message&gt;=archive&lt;enter&gt;&lt;enter-command&gt;echo 'Saved to archive'&lt;enter&gt;"
</screen>
</sect1>
<sect1 id="misc-topics">
<title>Miscellany</title>
......@@ -9658,6 +9688,15 @@ The following are the commands understood by Mutt:
</cmdsynopsis>
</listitem>
<listitem>
<cmdsynopsis>
<command><link linkend="echo">echo</link></command>
<arg choice="plain">
<replaceable class="parameter">message</replaceable>
</arg>
</cmdsynopsis>
</listitem>
<listitem>
<cmdsynopsis>
<command><link linkend="exec">exec</link></command>
......
......@@ -692,6 +692,22 @@ static int parse_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
return 0;
}
static int parse_echo (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
{
if (!MoreArgs (s))
{
strfcpy (err->data, _("not enough arguments"), err->dsize);
return -1;
}
mutt_extract_token (buf, s, 0);
set_option (OPTFORCEREFRESH);
mutt_message ("%s", buf->data);
unset_option (OPTFORCEREFRESH);
mutt_sleep (0);
return 0;
}
static void _alternates_clean (void)
{
int i;
......
......@@ -4101,6 +4101,7 @@ static int parse_lists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unlists (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_alias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unalias (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_echo (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_ignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_unignore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
static int parse_source (BUFFER *, BUFFER *, unsigned long, BUFFER *);
......@@ -4149,6 +4150,7 @@ const struct command_t Commands[] = {
{ "color", mutt_parse_color, 0 },
{ "uncolor", mutt_parse_uncolor, 0 },
#endif
{ "echo", parse_echo, 0 },
{ "exec", mutt_parse_exec, 0 },
{ "fcc-hook", mutt_parse_hook, MUTT_FCCHOOK },
{ "fcc-save-hook", mutt_parse_hook, MUTT_FCCHOOK | MUTT_SAVEHOOK },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment