]> granicus.if.org Git - neomutt/commitdiff
mbox_type -> enum
authorRichard Russon <rich@flatcap.org>
Sun, 9 Jun 2019 15:50:33 +0000 (16:50 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Jun 2019 23:23:35 +0000 (00:23 +0100)
Convert `$mbox_type` to use the new Config enumeration.

init.h
mx.c
mx.h

diff --git a/init.h b/init.h
index 91d639ab4893bbbe6b38803e9436671438125b6f..62100b240ff3f931db0b87e9a9844fb82c295b6c 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2042,7 +2042,7 @@ struct ConfigDef MuttVars[] = {
   ** .pp
   ** Also see the $$move variable.
   */
-  { "mbox_type", DT_MAGIC, &C_MboxType, MUTT_MBOX },
+  { "mbox_type", DT_ENUM, &C_MboxType, MUTT_MBOX, IP &MagicDef },
   /*
   ** .pp
   ** The default mailbox type used when creating new folders. May be any of
diff --git a/mx.c b/mx.c
index e1aeed4c7b068c5864e24c97781889092c802ca5..5faa4e5eec94a946e869d24cb8dd0b89084547fc 100644 (file)
--- a/mx.c
+++ b/mx.c
 /* These Config Variables are only used in mx.c */
 unsigned char C_CatchupNewsgroup; ///< Config: (nntp) Mark all articles as read when leaving a newsgroup
 bool C_KeepFlagged; ///< Config: Don't move flagged messages from #C_Spoolfile to #C_Mbox
-short C_MboxType; ///< Config: Default type for creating new mailboxes
+unsigned char C_MboxType; ///< Config: Default type for creating new mailboxes
 unsigned char C_Move; ///< Config: Move emails from #C_Spoolfile to #C_Mbox when read
 char *C_Trash;        ///< Config: Folder to put deleted emails
 
+// clang-format off
+static struct Mapping MagicMap[] = {
+  { "mbox",    MUTT_MBOX,    },
+  { "MMDF",    MUTT_MMDF,    },
+  { "MH",      MUTT_MH,      },
+  { "Maildir", MUTT_MAILDIR, },
+  { NULL,      0,            },
+};
+// clang-format on
+
+struct EnumDef MagicDef = {
+  "mbox_type",
+  4,
+  (struct Mapping *) &MagicMap,
+};
+
 /**
  * mx_ops - All the Mailbox backends
  */
diff --git a/mx.h b/mx.h
index cbf7006ef515eeacf135b4b841ec748cb795eb27..72caad97a22d408d9b7a08c84c6d46e70e689914 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -39,10 +39,12 @@ struct stat;
 /* These Config Variables are only used in mx.c */
 extern unsigned char C_CatchupNewsgroup;
 extern bool          C_KeepFlagged;
-extern short         C_MboxType;
+extern unsigned char C_MboxType;
 extern unsigned char C_Move;
 extern char *        C_Trash;
 
+struct EnumDef MagicDef;
+
 /* flags for mutt_open_mailbox() */
 typedef uint8_t OpenMailboxFlags;   ///< Flags for mutt_open_mailbox(), e.g. #MUTT_NOSORT
 #define MUTT_OPEN_NO_FLAGS       0  ///< No flags are set