From: Thomas Roessler Date: Thu, 18 Jun 1998 20:37:56 +0000 (+0000) Subject: Bradon long's alias_path patch, for the sake of Elm X-Git-Tag: mutt-0-93-unstable X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b26bcd69b0f8c381dd4012edf05bb21a765d9e6;p=mutt Bradon long's alias_path patch, for the sake of Elm compatibility. --- diff --git a/alias.c b/alias.c index b4cd7c07..d927fbc5 100644 --- a/alias.c +++ b/alias.c @@ -22,7 +22,7 @@ #include #include -static ADDRESS *lookup_alias (const char *s) +ADDRESS *mutt_lookup_alias (const char *s) { ALIAS *t = Aliases; @@ -42,7 +42,7 @@ static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn) { if (!a->group && !a->personal && a->mailbox && strchr (a->mailbox, '@') == NULL) { - t = lookup_alias (a->mailbox); + t = mutt_lookup_alias (a->mailbox); if (t) { @@ -191,7 +191,7 @@ void mutt_create_alias (ENVELOPE *cur, ADDRESS *iadr) return; /* check to see if the user already has an alias defined */ - if (lookup_alias (buf)) + if (mutt_lookup_alias (buf)) { mutt_error ("You already have an alias defined with that name!"); return; diff --git a/lib.c b/lib.c index e71027b9..3c14bc68 100644 --- a/lib.c +++ b/lib.c @@ -215,6 +215,26 @@ char *mutt_expand_path (char *s, size_t slen) } else if (*s == '=' || *s == '+') snprintf (p, sizeof (p), "%s/%s", NONULL (Maildir), s + 1); + else if (*s == '@') + { + /* elm compatibility, @ expands alias to user name */ + HEADER *h; + ADDRESS *alias; + + alias = mutt_lookup_alias (s + 1); + if (alias != NULL) + { + h = mutt_new_header(); + h->env = mutt_new_envelope(); + h->env->from = h->env->to = alias; + mutt_default_save (p, sizeof (p), h); + h->env->from = h->env->to = NULL; + mutt_free_header (&h); + /* Avoid infinite recursion if the resulting folder starts with '@' */ + if (*p != '@') + mutt_expand_path (p, sizeof (p)); + } + } else { if (*s == '>') diff --git a/protos.h b/protos.h index 4405cf39..b577b7de 100644 --- a/protos.h +++ b/protos.h @@ -64,6 +64,7 @@ void set_quadoption (int, int); int query_quadoption (int, const char *); int quadoption (int); +ADDRESS *mutt_lookup_alias (const char *s); ADDRESS *mutt_remove_duplicates (ADDRESS *); ADDRESS *mutt_expand_aliases (ADDRESS *); ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *);