]> granicus.if.org Git - mutt/commitdiff
Bradon long's alias_path patch, for the sake of Elm mutt-0-93-unstable
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 18 Jun 1998 20:37:56 +0000 (20:37 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 18 Jun 1998 20:37:56 +0000 (20:37 +0000)
compatibility.

alias.c
lib.c
protos.h

diff --git a/alias.c b/alias.c
index b4cd7c07e62f85998b1b813ac96e1f5bcae72184..d927fbc5778435000c5086d6f76d3b361e7c475b 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -22,7 +22,7 @@
 #include <pwd.h>
 #include <string.h>
 
-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 e71027b9dab2ab9f0be263074ef100ed2f124989..3c14bc68284b1c44a21b88b921ccfae9543b437d 100644 (file)
--- 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 == '>')
index 4405cf3987acee3aae00a57dc3d4aa293110bbac..b577b7de5a898fe94c44267966ff14a90f2594f9 100644 (file)
--- 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 *);