From 1072c9c51ecfb2228e24bcb4f976bc03c29e4102 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Tue, 6 Nov 2001 10:34:02 +0000 Subject: [PATCH] Fix an addressbook bug, and introduce "unalias *". From "g.c.w. de bruijn" . --- alias.c | 5 ++++- doc/manual.sgml.head | 6 +++--- doc/muttrc.man.head | 5 +++-- init.c | 43 ++++++++++++++++++++++++++++--------------- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/alias.c b/alias.c index 96eb80f45..777c0aea3 100644 --- a/alias.c +++ b/alias.c @@ -418,7 +418,7 @@ int mutt_alias_complete (char *s, size_t buflen) /* remove any aliases marked for deletion */ a_list = NULL; - for (a_cur = Aliases; a_cur; a_cur = a_cur->next) + for (a_cur = Aliases; a_cur;) { if (a_cur->del) { @@ -436,7 +436,10 @@ int mutt_alias_complete (char *s, size_t buflen) a_cur = Aliases; } else + { a_list = a_cur; + a_cur = a_cur->next; + } } return 0; diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index de45a4e0f..f111ac0df 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -828,9 +828,9 @@ a short string to a full address. alias muttdude me@cs.hmc.edu (Michael Elkins) @@ -2864,7 +2864,7 @@ The following are the commands understood by mutt. - [ * | diff --git a/doc/muttrc.man.head b/doc/muttrc.man.head index 632578855..44722d46b 100644 --- a/doc/muttrc.man.head +++ b/doc/muttrc.man.head @@ -69,11 +69,12 @@ like sh and bash: Prepend the name of the environment by a dollar .PP .nf \fBalias\fP \fIkey\fP \fIaddress\fP [\fB,\fP \fIaddress\fP [ ... ]] -\fBunalias\fP \fIkey\fP +\fBunalias\fP [\fB * \fP | \fIkey\fP ] .fi .IP \fBalias\fP defines an alias \fIkey\fP for the given addresses. -\fBunalias\fP removes the alias corresponding to the given \fIkey\fP. +\fBunalias\fP removes the alias corresponding to the given \fIkey\fP or +all aliases when \(lq\fB*\fP\(rq is used as an argument. .TP \fBalternative_order\fP \fItype\fP[\fB/\fP\fIsubtype\fP] [ ... ] This command permits you to define an order of preference which is diff --git a/init.c b/init.c index dd1f3d60f..06974c397 100644 --- a/init.c +++ b/init.c @@ -428,27 +428,40 @@ static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er { mutt_extract_token (buf, s, 0); - for (tmp = Aliases; tmp; tmp = tmp->next) + if (mutt_strcmp ("*", buf->data) == 0) { - if (mutt_strcasecmp (buf->data, tmp->name) == 0) + if (CurrentMenu == MENU_ALIAS) { - if (CurrentMenu == MENU_ALIAS) - { + for (tmp = Aliases; tmp ; tmp = tmp->next) tmp->del = 1; - set_option (OPTFORCEREDRAWINDEX); + set_option (OPTFORCEREDRAWINDEX); + } + else + mutt_free_alias (&Aliases); + break; + } + else + for (tmp = Aliases; tmp; tmp = tmp->next) + { + if (mutt_strcasecmp (buf->data, tmp->name) == 0) + { + if (CurrentMenu == MENU_ALIAS) + { + tmp->del = 1; + set_option (OPTFORCEREDRAWINDEX); + break; + } + + if (last) + last->next = tmp->next; + else + Aliases = tmp->next; + tmp->next = NULL; + mutt_free_alias (&tmp); break; } - - if (last) - last->next = tmp->next; - else - Aliases = tmp->next; - tmp->next = NULL; - mutt_free_alias (&tmp); - break; + last = tmp; } - last = tmp; - } } while (MoreArgs (s)); return 0; -- 2.40.0