From 6edfcee93294fb1ab50bf798a2c74c3fbfc9d6bb Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Mon, 3 Mar 2003 08:26:20 +0000 Subject: [PATCH] Introduce a new option named $bounce, and fix some inconsistencies in the messages created when bouncing. Based on work done by Thomas Glanzmann . --- commands.c | 30 +++++++++++++----------- contrib/sample.muttrc | 1 + doc/manual.sgml.head | 3 ++- init.h | 7 ++++++ mutt.h | 3 ++- recvcmd.c | 53 +++++++++++++++++++++++++++---------------- 6 files changed, 63 insertions(+), 34 deletions(-) diff --git a/commands.c b/commands.c index 6b505a63..cd177f9f 100644 --- a/commands.c +++ b/commands.c @@ -257,25 +257,29 @@ void ci_bounce_message (HEADER *h, int *redraw) rfc822_write_address (buf, sizeof (buf), adr); #define extra_space (15 + 7 + 2) - /* - * This is the printing width of "...? ([y=yes]/n=no): ?" plus 2 - * for good measure. This is not ideal. FIXME. - * - * While you fix this, please go to recvcmd.c, and do the same thing there. - */ - snprintf (prompt, sizeof (prompt) - 4, + snprintf (prompt, sizeof (prompt), (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); - mutt_format_string (prompt, sizeof (prompt) - 4, - 0, COLS-extra_space, 0, 0, - prompt, sizeof (prompt), 0); - strcat (prompt, "...?"); /* __STRCAT_CHECKED__ */ - if (mutt_yesorno (prompt, M_YES) != M_YES) + + if (mutt_strwidth (prompt) > COLS - extra_space) + { + mutt_format_string (prompt, sizeof (prompt), + 0, COLS-extra_space, 0, 0, + prompt, sizeof (prompt), 0); + strncat (prompt, "...?", sizeof (prompt)); + } + else + strncat (prompt, "?", sizeof (prompt)); + + if (query_quadoption (OPT_BOUNCE, prompt) == M_NO) { rfc822_free_address (&adr); - CLEARLINE (LINES-1); + CLEARLINE (LINES - 1); + mutt_message (h ? _("Message not bounced.") : _("Messages not bounced.")); return; } + CLEARLINE (LINES - 1); + rc = mutt_bounce_message (NULL, h, adr); rfc822_free_address (&adr); /* If no error, or background, display message. */ diff --git a/contrib/sample.muttrc b/contrib/sample.muttrc index 519ceb96..5ebd02f5 100644 --- a/contrib/sample.muttrc +++ b/contrib/sample.muttrc @@ -33,6 +33,7 @@ set copy=yes # always save a copy of outgoing messages set delete=yes # purge deleted messages without asking set edit_headers # let me edit the message header when composing #set editor="emacs -nw" # editor to use when composing messages +#set fast_bounce # don't ask about bouncing messages, just do it #set fast_reply # skip initial prompts when replying #set fcc_attach # keep attachments in copies of sent messages? #set force_name # fcc by recipient, create if mailbox doesn't exist diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index eb0dbf8f..960816a8 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -491,7 +491,8 @@ recipients to place on the ``To:'' header field. Next, it will ask you for the ``Subject:'' field for the message, providing a default if you are replying to or forwarding a message. See also , , , and , , and for changing how Mutt asks these questions. diff --git a/init.h b/init.h index 7dd732b8..697a5aeb 100644 --- a/init.h +++ b/init.h @@ -268,6 +268,13 @@ struct option_t MuttVars[] = { ** notifying you of new mail. This is independent of the setting of the ** ``$$beep'' variable. */ + { "bounce", DT_QUAD, R_NONE, OPT_BOUNCE, M_ASKYES }, + /* + ** Controls whether you will be asked to confirm bouncing messages. + ** If set to \fIyes\fP you don't get asked if you want to bounce a + ** message. Setting this variable to \fIno\fP is not generally useful, + ** and thus not recommended, because your are unable to bounce message. + */ { "bounce_delivered", DT_BOOL, R_NONE, OPTBOUNCEDELIVERED, 1 }, /* ** .pp diff --git a/mutt.h b/mutt.h index 86dff966..9b9c29d3 100644 --- a/mutt.h +++ b/mutt.h @@ -288,7 +288,8 @@ enum OPT_SUBJECT, OPT_MIMEFWDREST, OPT_FORWEDIT, - OPT_MAX + OPT_MAX, + OPT_BOUNCE }; /* flags to ci_send_message() */ diff --git a/recvcmd.c b/recvcmd.c index 9a758add..34435d1c 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -126,17 +126,19 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr, ATTACHPTR ** idx, short idxlen, BODY * cur) { short i; - short ntagged; char prompt[STRING]; char buf[HUGE_STRING]; ADDRESS *adr = NULL; + int ret = 0; + int p = 0; if (check_all_msg (idx, idxlen, cur, 1) == -1) return; - ntagged = count_tagged (idx, idxlen); - - if (cur || ntagged == 1) + /* one or more messages? */ + p = (cur || count_tagged (idx, idxlen) == 1); + + if (p) strfcpy (prompt, _("Bounce message to: "), sizeof (prompt)); else strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt)); @@ -161,31 +163,44 @@ void mutt_attach_bounce (FILE * fp, HEADER * hdr, * See commands.c. */ snprintf (prompt, sizeof (prompt) - 4, - cur ? _("Bounce message to %s...?") : _("Bounce messages to %s...?"), buf); - - mutt_format_string (prompt, sizeof (prompt) - 4, - 0, COLS-extra_space, 0, 0, - prompt, sizeof (prompt), 0); - strcat (prompt, "...?"); /* __STRCAT_CHECKED__ */ - - if (mutt_yesorno (prompt, M_YES) != M_YES) - goto bail; + (p ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); + + if (mutt_strwidth (prompt) > COLS - extra_space) + { + mutt_format_string (prompt, sizeof (prompt) - 4, + 0, COLS-extra_space, 0, 0, + prompt, sizeof (prompt), 0); + strncat (prompt, "...?", sizeof (prompt)); + } + else + strncat (prompt, "?", sizeof (prompt)); + if (query_quadoption (OPT_BOUNCE, prompt) == M_NO) + { + rfc822_free_address (&adr); + CLEARLINE (LINES - 1); + mutt_message (p ? _("Message not bounced.") : _("Messages not bounced.")); + return; + } + + CLEARLINE (LINES - 1); + if (cur) - mutt_bounce_message (fp, cur->hdr, adr); + ret = mutt_bounce_message (fp, cur->hdr, adr); else { for (i = 0; i < idxlen; i++) { if (idx[i]->content->tagged) - mutt_bounce_message (fp, idx[i]->content->hdr, adr); + if (mutt_bounce_message (fp, idx[i]->content->hdr, adr)) + ret = 1; } } -bail: - - rfc822_free_address (&adr); - CLEARLINE (LINES - 1); + if (!ret) + mutt_message (p ? _("Message bounced.") : _("Messages bounced.")); + else + mutt_error (p ? _("Error bouncing message!") : _("Error bouncing messages!")); } -- 2.40.0