]> granicus.if.org Git - neomutt/commitdiff
This patch adds an option -D to dump mutt's configuration after all
authorPaul Walker <paul@black-sun.demon.co.uk>
Sun, 24 Jul 2005 16:12:11 +0000 (16:12 +0000)
committerPaul Walker <paul@black-sun.demon.co.uk>
Sun, 24 Jul 2005 16:12:11 +0000 (16:12 +0000)
configuration files have been read.  Changes against PW's version:
(1) curses isn't initialized; (2) variables are dumped to stdout,
not to stderr.

doc/manual.sgml.head
init.c
main.c
protos.h

index 8b1a68ccc804bd3f8bd4e5511c49d99416bdb150..87be7dc1836ae152eec5d0b380acc7be5f08cba3 100644 (file)
@@ -3062,6 +3062,7 @@ to send messages from the command line as well.
 -a      attach a file to a message
 -b      specify a blind carbon-copy (BCC) address
 -c      specify a carbon-copy (Cc) address
+-D      print the value of all mutt variables to stderr
 -e      specify a config command to be run after initilization files are read
 -f      specify a mailbox to load
 -F      specify an alternate file to read initialization commands
diff --git a/init.c b/init.c
index 1910901febd4b0dc00ab5ca09396a081c6260ece..2e50d4380a2af02853c7279be61a67743d2e0cb6 100644 (file)
--- a/init.c
+++ b/init.c
@@ -2060,6 +2060,38 @@ int mutt_query_variables (LIST *queries)
   return 0;
 }
 
+/* dump out the value of all the variables we have */
+int mutt_dump_variables (void)
+{
+  int i;
+  
+  char errbuff[STRING];
+  char command[STRING];
+  
+  BUFFER err, token;
+  
+  memset (&err, 0, sizeof (err));
+  memset (&token, 0, sizeof (token));
+  
+  err.data = errbuff;
+  err.dsize = sizeof (errbuff);
+  
+  for (i = 0; MuttVars[i].option; i++)
+  {
+    snprintf (command, sizeof (command), "set ?%s\n", MuttVars[i].option);
+    if (mutt_parse_rc_line (command, &token, &err) == -1)
+    {
+      fprintf (stderr, "%s\n", err.data);
+      FREE (&token.data);
+      return 1;
+    }
+    printf("%s\n", err.data);
+  }
+  
+  FREE (&token.data);
+  return 0;
+}
+
 char *mutt_getnamebyvalue (int val, const struct mapping_t *map)
 {
   int i;
diff --git a/main.c b/main.c
index c979f1d63a53128513a4d4a4c8020dc0da550879..5d79b7f3da8b717c939a50f474d029907e089c81 100644 (file)
--- a/main.c
+++ b/main.c
@@ -99,6 +99,7 @@ static void mutt_usage (void)
 "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 [ -nR ] [ -e <cmd> ] [ -F <file> ] -D\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\
@@ -108,6 +109,7 @@ options:\n\
   -a <file>\tattach a file to the message\n\
   -b <address>\tspecify a blind carbon-copy (BCC) address\n\
   -c <address>\tspecify a carbon-copy (CC) address\n\
+  -D\t\tprint the value of all variables to stderr\n\
   -e <command>\tspecify a command to be executed after initialization\n\
   -f <file>\tspecify which mailbox to read\n\
   -F <file>\tspecify an alternate muttrc file\n\
@@ -517,6 +519,7 @@ int main (int argc, char **argv)
   int version = 0;
   int i;
   int explicit_folder = 0;
+  int dump_variables = 0;
   extern char *optarg;
   extern int optind;
 
@@ -546,7 +549,7 @@ int main (int argc, char **argv)
   memset (Options, 0, sizeof (Options));
   memset (QuadOptions, 0, sizeof (QuadOptions));
   
-  while ((i = getopt (argc, argv, "A: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:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
     switch (i)
     {
       case 'A':
@@ -577,6 +580,10 @@ int main (int argc, char **argv)
          msg->env->cc = rfc822_parse_adrlist (msg->env->cc, optarg);
        break;
 
+      case 'D':
+       dump_variables = 1;
+       break;
+
       case 'd':
 #ifdef DEBUG
        debuglevel = atoi (optarg);
@@ -662,7 +669,7 @@ int main (int argc, char **argv)
   }
 
   /* Check for a batch send. */
-  if (!isatty (0) || queries || alias_queries)
+  if (!isatty (0) || queries || alias_queries || dump_variables)
   {
     set_option (OPTNOCURSES);
     sendflags = SENDBATCH;
@@ -682,6 +689,8 @@ int main (int argc, char **argv)
 
   if (queries)
     return mutt_query_variables (queries);
+  if (dump_variables)
+    return mutt_dump_variables();
 
   if (alias_queries)
   {
index 3cda50538b733826e37cd35734e68755173f080c..248002b8ee018bad11e4cbc421067a3b406ef909 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -277,6 +277,7 @@ int mutt_compose_attachment (BODY *a);
 int mutt_copy_body (FILE *, BODY **, BODY *);
 int mutt_decode_save_attachment (FILE *, BODY *, char *, int, int);
 int mutt_display_message (HEADER *h);
+int mutt_dump_variables (void);
 int mutt_edit_attachment(BODY *);
 int mutt_edit_message (CONTEXT *, HEADER *);
 int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags);