From: Kevin McCarthy Date: Sun, 29 Apr 2018 22:10:21 +0000 (-0700) Subject: Add echo command. X-Git-Tag: mutt-1-10-rel~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97bc33dc703bb468e94a0fff0cc241a7abed69c6;p=mutt 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. --- diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 008eabe4..4f413091 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -6507,6 +6507,36 @@ macro pager \cb |urlview\n + +Echoing Text + + +Usage: + + + +echo + +message + + + + +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 +$sleep_time. + + + +echo "Sourcing muttrc file" + +unset confirmappend +macro index ,a "<save-message>=archive<enter><enter-command>echo 'Saved to archive'<enter>" + + + + Miscellany @@ -9658,6 +9688,15 @@ The following are the commands understood by Mutt: + + +echo + +message + + + + exec diff --git a/init.c b/init.c index f5a89bff..f8a54e6d 100644 --- a/init.c +++ b/init.c @@ -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; diff --git a/init.h b/init.h index f5837be3..6c443945 100644 --- a/init.h +++ b/init.h @@ -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 },