]> granicus.if.org Git - neomutt/commitdiff
Introduce a new option named $bounce, and fix some inconsistencies
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 3 Mar 2003 08:26:20 +0000 (08:26 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 3 Mar 2003 08:26:20 +0000 (08:26 +0000)
in the messages created when bouncing.  Based on work done by Thomas
Glanzmann <sithglan@stud.uni-erlangen.de>.

commands.c
contrib/sample.muttrc
doc/manual.sgml.head
init.h
mutt.h
recvcmd.c

index 6b505a632979c9d0d0cc2e950d8271ee81573e37..cd177f9f962b2d14672122ea45142a9ab5e4451d 100644 (file)
@@ -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. */
index 519ceb960a84019bf9580a5befa163136ce5db72..5ebd02f5c07f88c5ea6fad73453f2845c27dcce4 100644 (file)
@@ -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
index eb0dbf8ff986540f52b9304d720ce7d15a0f94cd..960816a8adea7a9679a7929f9370c1c314149918 100644 (file)
@@ -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 <ref id="askcc"
 name="&dollar;askcc">, <ref id="askbcc" name="&dollar;askbcc">, <ref
-id="autoedit" name="&dollar;autoedit">, and <ref id="fast_reply"
+id="autoedit" name="&dollar;autoedit">, <ref id="bounce"
+name="&dollar;bounce">, and <ref id="fast_reply"
 name="&dollar;fast&lowbar;reply"> for changing how Mutt asks these
 questions.
 
diff --git a/init.h b/init.h
index 7dd732b83c4477804892603dc185a0bd9fe2097e..697a5aeb072b672d14130bca231f027538d5117c 100644 (file)
--- 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 86dff96647a829dc48ca418bab0aa7125479a004..9b9c29d38161b639a737779d55c9ae207ecab09b 100644 (file)
--- 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() */
index 9a758add57c7d00fa308cc31852513afd993ef82..34435d1c592ddd810da49e00d8da5c0d58b524e9 100644 (file)
--- 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!"));
 }