]> granicus.if.org Git - mutt/commitdiff
Add a new command line option -A which is used to expand aliases.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 13 Nov 2002 10:07:03 +0000 (10:07 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 13 Nov 2002 10:07:03 +0000 (10:07 +0000)
doc/manual.sgml.head
doc/mutt.man
main.c
protos.h

index 96cdc1dc28c7c2c78dc2318f0d65a41cf9ca539b..1c26f5168d7a4db0cabcaa91267fb81ed03bf651 100644 (file)
@@ -2875,6 +2875,7 @@ mailbox.  However, it is possible to read other mailboxes and
 to send messages from the command line as well.
 
 <tscreen><verb>
+-A     expand an alias
 -a      attach a file to a message
 -b      specify a blind carbon-copy (BCC) address
 -c      specify a carbon-copy (Cc) address
index 4dc8b8bd1a7350ed12bf8c65a1eb45711643c7ca..312266142544b40c4cd407401355ea7abfb127c0 100644 (file)
@@ -44,6 +44,9 @@ mutt \- The Mutt Mail User Agent
 .B mutt
 [-n] [-e \fIcmd\fP] [-F \fIfile\fP] -Q \fIquery\fP
 .PP
+.B mutt
+[-n] [-e \fIcmd\fP] [-F \fIfile\fP] -A \fIalias\fP
+.PP
 .B mutt 
 -v[v]
 .SH DESCRIPTION
@@ -53,6 +56,8 @@ mail under unix operating systems, including support color terminals, MIME,
 and a threaded sorting mode.
 .SH OPTIONS
 .PP
+.IP "-A \fIalias\fP"
+An expanded version of the given alias is passed to stdout.
 .IP "-a \fIfile\fP"
 Attach a file to your message using MIME.
 .IP "-b \fIaddress\fP"
diff --git a/main.c b/main.c
index d2091a0025b56600e7de7478bfbd8e23b05486c1..aced3118f98a50e25896d524d3e5fdaee1455887 100644 (file)
--- a/main.c
+++ b/main.c
@@ -87,6 +87,7 @@ static void mutt_usage (void)
   puts _(
 "usage: mutt [ -nRyzZ ] [ -e <cmd> ] [ -F <file> ] [ -m <type> ] [ -f <file> ]\n\
        mutt [ -nR ] [ -e <cmd> ] [ -F <file> ] -Q <query> [ -Q <query> ] [...]\n\
+       mutt [ -nR ] [ -e <cmd> ] [ -F <file> ] -A <alias> [ -A <alias> ] [...]\n\
        mutt [ -nx ] [ -e <cmd> ] [ -a <file> ] [ -F <file> ] [ -H <file> ] [ -i <file> ] [ -s <subj> ] [ -b <addr> ] [ -c <addr> ] <addr> [ ... ]\n\
        mutt [ -n ] [ -e <cmd> ] [ -F <file> ] -p\n\
        mutt -v[v]\n\
@@ -468,6 +469,7 @@ int main (int argc, char **argv)
   LIST *attach = NULL;
   LIST *commands = NULL;
   LIST *queries = NULL;
+  LIST *alias_queries = NULL;
   int sendflags = 0;
   int flags = 0;
   int version = 0;
@@ -502,9 +504,12 @@ int main (int argc, char **argv)
   memset (Options, 0, sizeof (Options));
   memset (QuadOptions, 0, sizeof (QuadOptions));
   
-  while ((i = getopt (argc, argv, "a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
+  while ((i = getopt (argc, argv, "A:a:b:F:f:c:d:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
     switch (i)
     {
+      case 'A':
+        alias_queries = mutt_add_list (alias_queries, optarg);
+        break;
       case 'a':
        attach = mutt_add_list (attach, optarg);
        break;
@@ -615,7 +620,7 @@ int main (int argc, char **argv)
   }
 
   /* Check for a batch send. */
-  if (!isatty (0) || queries)
+  if (!isatty (0) || queries || alias_queries)
   {
     set_option (OPTNOCURSES);
     sendflags = SENDBATCH;
@@ -632,6 +637,23 @@ int main (int argc, char **argv)
 
   if (queries)
     return mutt_query_variables (queries);
+
+  if (alias_queries)
+  {
+    int rv = 0;
+    ADDRESS *a;
+    for (; alias_queries; alias_queries = alias_queries->next)
+    {
+      if ((a = mutt_lookup_alias (alias_queries->data)))
+       mutt_write_address_list (a, stdout, 0);
+      else
+      {
+       rv = 1;
+       printf ("%s\n", alias_queries->data);
+      }
+    }
+    return rv;
+  }
   
   if (newMagic)
     mx_set_magic (newMagic);
index f8e20afc0560a0c7111aff0d35bcd7c4d88f4a57..30aa9f8962bce70915994a7857f9653fc192c409 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -230,6 +230,7 @@ void mutt_update_encoding (BODY *a);
 void mutt_update_tree (ATTACHPTR **, short);
 void mutt_version (void);
 void mutt_view_attachments (HEADER *);
+void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen);
 void mutt_set_virtual (CONTEXT *);
 
 int mutt_addr_is_user (ADDRESS *);