diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2021-06-09 19:02:43 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2021-06-09 19:06:51 +0300 |
commit | 572ead443051b2851cfdce12156c7e5418821ff2 (patch) | |
tree | ccd4c55a7b26767666b60efa3203921e229af325 | |
parent | e64463fca2a11cff98d497b60f959914c3010e92 (diff) | |
download | mailutils-572ead443051b2851cfdce12156c7e5418821ff2.tar.gz mailutils-572ead443051b2851cfdce12156c7e5418821ff2.tar.bz2 |
mail: implement the fullnames variable
* NEWS: Document changes.
* doc/texinfo/programs/mail.texi: Likewise.
* mail/mail.c (default_setup): Set fullnames.
* mail/mail.h (mailvar_name_fullnames): New define.
* mail/mailvar.c (fullnames): New variable.
* mail/reply.c (compose_remove_personal): New function.
(respond_msg,respond_all): Call compose_remove_personal if
fullnames is not set.
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | doc/texinfo/programs/mail.texi | 17 | ||||
-rw-r--r-- | mail/mail.c | 1 | ||||
-rw-r--r-- | mail/mail.h | 1 | ||||
-rw-r--r-- | mail/mailvar.c | 12 | ||||
-rw-r--r-- | mail/reply.c | 43 |
6 files changed, 76 insertions, 5 deletions
@@ -1,4 +1,4 @@ -GNU mailutils NEWS -- history of user-visible changes. 2021-06-08 +GNU mailutils NEWS -- history of user-visible changes. 2021-06-09 See the end of file for copying conditions. Please send mailutils bug reports to <bug-mailutils@gnu.org>. @@ -37,6 +37,11 @@ deprecated. Use 'retry-sleep' instead. * mail: improve POSIX mailx compatible mode +* New mail variables + + - fullnames + Controls whether personal parts of emails are preserved in + recipient addresses when replying. Default is true. Version 3.12, 2021-02-13 diff --git a/doc/texinfo/programs/mail.texi b/doc/texinfo/programs/mail.texi index 6355c588c..ff947a558 100644 --- a/doc/texinfo/programs/mail.texi +++ b/doc/texinfo/programs/mail.texi @@ -1042,6 +1042,10 @@ is derived from the author of the first message. @xref{Mail}, for a detailed discussion of how the file name is selected. @end deffn +By default, @command{mail} will preserve personal email parts when +forming lists of recipient addresses. If this is not desired, unset +the @code{fullnames} variable (@pxref{fullnames}). + To determine the sender of the message @command{mail} uses the list of sender fields (@pxref{Controlling Sender Fields}). The first field from this list is looked up in message headers. If it is found @@ -2208,6 +2212,19 @@ Unsetting this variable tells @command{mail} to obtain it from the @xref{datefield}. +@anchor{fullnames} +@kwindex fullnames +@item fullnames +@*Type: Boolean. +@*Default: True. + +Preserve personal parts (comments) of recipient addresses when replying to a +message. + +When unset, only emails will be used. + +@xref{Replying}. + @kwindex header @item header @*Type: Boolean. diff --git a/mail/mail.c b/mail/mail.c index 5e55e22fb..1b88bbf5f 100644 --- a/mail/mail.c +++ b/mail/mail.c @@ -402,6 +402,7 @@ static char *default_setup[] = { "set fromfield", "set headline=\"%>%a%4m %18f %16d %3L/%-5o %s\"", "unset folder", + "set fullnames", /* Start in mail reading mode */ "setq mode=read", diff --git a/mail/mail.h b/mail/mail.h index d2451f222..19971d4d8 100644 --- a/mail/mail.h +++ b/mail/mail.h @@ -181,6 +181,7 @@ struct mailvar_variable #define mailvar_name_flipr "flipr" #define mailvar_name_folder "folder" #define mailvar_name_fromfield "fromfield" +#define mailvar_name_fullnames "fullnames" #define mailvar_name_gnu_last_command "gnu-last-command" #define mailvar_name_header "header" #define mailvar_name_headline "headline" diff --git a/mail/mailvar.c b/mail/mailvar.c index aaa3dcded..28a4d4b44 100644 --- a/mail/mailvar.c +++ b/mail/mailvar.c @@ -289,6 +289,14 @@ struct mailvar_symbol mailvar_tab[] = MAILVAR_TYPEMASK (mailvar_type_boolean), N_("always compose MIME messages") }, + { { mailvar_name_fullnames }, + MAILVAR_TYPEMASK (mailvar_type_boolean), + N_("when replying, preserve personal parts of recipient emails") }, + + { { mailvar_name_PID }, + MAILVAR_TYPEMASK (mailvar_type_string) | MAILVAR_RDONLY, + N_("PID of this process") }, + /* These will be implemented later */ { { mailvar_name_onehop, }, MAILVAR_HIDDEN, NULL }, @@ -296,10 +304,6 @@ struct mailvar_symbol mailvar_tab[] = MAILVAR_TYPEMASK (mailvar_type_boolean) | MAILVAR_HIDDEN, N_("suppress the printing of the version when first invoked") }, - { { mailvar_name_PID }, - MAILVAR_TYPEMASK (mailvar_type_string) | MAILVAR_RDONLY, - N_("PID of this process") }, - { { NULL }, } }; diff --git a/mail/reply.c b/mail/reply.c index d304a58d3..6c1b44572 100644 --- a/mail/reply.c +++ b/mail/reply.c @@ -85,6 +85,37 @@ compose_set_address (compose_env_t *env, char const *hname, char const *input) } } +static void +compose_remove_personal (compose_env_t *env, char *hname) +{ + char const *value; + + value = compose_header_get (env, hname, NULL); + if (value) + { + mu_address_t addr = NULL, ap; + struct mu_address hint = MU_ADDRESS_HINT_INITIALIZER; + char *result; + + mu_address_create_hint (&addr, value, &hint, 0); + for (ap = addr; ap; ap = ap->next) + { + free (ap->printable); + ap->printable = NULL; + free (ap->comments); + ap->comments = NULL; + free (ap->personal); + ap->personal = NULL; + free (ap->route); + ap->route = NULL; + } + mu_address_aget_printable (addr, &result); + compose_header_set (env, hname, result, COMPOSE_REPLACE); + free (result); + mu_address_destroy (&addr); + } +} + /* * r[eply] [message] * r[espond] [message] @@ -158,6 +189,12 @@ respond_all (int argc, char **argv, int record_sender) else compose_header_set (&env, MU_HEADER_SUBJECT, "", COMPOSE_REPLACE); + if (!mailvar_is_true (mailvar_name_fullnames)) + { + compose_remove_personal (&env, MU_HEADER_TO); + compose_remove_personal (&env, MU_HEADER_CC); + } + mu_printf ("To: %s\n", compose_header_get (&env, MU_HEADER_TO, "")); str = compose_header_get (&env, MU_HEADER_CC, NULL); if (str) @@ -242,6 +279,12 @@ respond_msg (int argc, char **argv, int record_sender) } else compose_header_set (&env, MU_HEADER_SUBJECT, "", COMPOSE_REPLACE); + + if (!mailvar_is_true (mailvar_name_fullnames)) + { + compose_remove_personal (&env, MU_HEADER_TO); + compose_remove_personal (&env, MU_HEADER_CC); + } mu_printf ("To: %s\n", compose_header_get (&env, MU_HEADER_TO, "")); str = compose_header_get (&env, MU_HEADER_CC, NULL); |