]> granicus.if.org Git - neomutt/commitdiff
Factor out mutt_edit_address() in send.c
authorKevin McCarthy <kevin@8t8.us>
Mon, 8 Jul 2019 22:23:44 +0000 (15:23 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 19 Aug 2019 23:14:27 +0000 (00:14 +0100)
For reuse by autocrypt for address prompts.

Co-authored-by: Richard Russon <rich@flatcap.org>
send.c
send.h

diff --git a/send.c b/send.c
index 3c3daba9e045ebcd4e53337c0a5ba11916d97bb2..d778ed60a95d3c3e0bfdc6e0e569b152b0eea770 100644 (file)
--- a/send.c
+++ b/send.c
@@ -197,13 +197,13 @@ static void add_mailing_lists(struct AddressList *out, const struct AddressList
 }
 
 /**
- * edit_address - Edit an email address
+ * mutt_edit_address - Edit an email address
  * @param[in,out] al    AddressList to edit
  * @param[in]  field Prompt for user
  * @retval  0 Success
  * @retval -1 Failure
  */
-static int edit_address(struct AddressList *al, const char *field)
+int mutt_edit_address(struct AddressList *al, const char *field, int expand_aliases)
 {
   char buf[8192];
   char *err = NULL;
@@ -218,7 +218,8 @@ static int edit_address(struct AddressList *al, const char *field)
       return -1;
     mutt_addrlist_clear(al);
     mutt_addrlist_parse2(al, buf);
-    mutt_expand_aliases(al);
+    if (expand_aliases)
+      mutt_expand_aliases(al);
     idna_ok = mutt_addrlist_to_intl(al, &err);
     if (idna_ok != 0)
     {
@@ -278,14 +279,14 @@ static int edit_envelope(struct Envelope *en, SendFlags flags)
   else
 #endif
   {
-    if ((edit_address(&en->to, _("To: ")) == -1) || TAILQ_EMPTY(&en->to))
+    if ((mutt_edit_address(&en->to, _("To: "), 1) == -1) || TAILQ_EMPTY(&en->to))
       return -1;
-    if (C_Askcc && (edit_address(&en->cc, _("Cc: ")) == -1))
+    if (C_Askcc && (mutt_edit_address(&en->cc, _("Cc: "), 1) == -1))
       return -1;
-    if (C_Askbcc && (edit_address(&en->bcc, _("Bcc: ")) == -1))
+    if (C_Askbcc && (mutt_edit_address(&en->bcc, _("Bcc: "), 1) == -1))
       return -1;
     if (C_ReplyWithXorig && (flags & (SEND_REPLY | SEND_LIST_REPLY | SEND_GROUP_REPLY)) &&
-        (edit_address(&en->from, "From: ") == -1))
+        (mutt_edit_address(&en->from, "From: ", 1) == -1))
     {
       return -1;
     }
diff --git a/send.h b/send.h
index 17e631de46f4779fc6d7e19a05498fb6cd76bfe0..5c38fb456fa5e1edfec9f70ebba5c29a93c9a4b3 100644 (file)
--- a/send.h
+++ b/send.h
@@ -103,6 +103,7 @@ typedef uint16_t SendFlags;             ///< Flags for ci_send_message(), e.g. #
 int             ci_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Context *ctx, struct EmailList *el);
 void            mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv);
 struct Address *mutt_default_from(void);
+int             mutt_edit_address(struct AddressList *al, const char *field, int expand_aliases);
 void            mutt_encode_descriptions(struct Body *b, bool recurse);
 int             mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags);
 void            mutt_fix_reply_recipients(struct Envelope *env);