NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
config.c
Go to the documentation of this file.
1
31#include "config.h"
32#include <stdbool.h>
33#include <stddef.h>
34#include "mutt/lib.h"
35#include "config/lib.h"
36#include "lib.h"
37#include "expando/lib.h"
38
42static const struct Mapping SortBrowserMethods[] = {
43 // clang-format off
44 { "alpha", SORT_SUBJECT },
45 { "count", SORT_COUNT },
46 { "date", SORT_DATE },
47 { "desc", SORT_DESC },
48 { "new", SORT_UNREAD },
49 { "unread", SORT_UNREAD },
50 { "size", SORT_SIZE },
51 { "unsorted", SORT_ORDER },
52 { NULL, 0 },
53 // clang-format on
54};
55
62struct ExpandoNode *parse_folder_date(const char *str, struct ExpandoFormat *fmt,
63 int did, int uid, ExpandoParserFlags flags,
64 const char **parsed_until,
65 struct ExpandoParseError *err)
66{
67 if (flags & EP_CONDITIONAL)
68 {
69 return node_conddate_parse(str, did, uid, parsed_until, err);
70 }
71
72 return node_expando_parse_enclosure(str, did, uid, ']', fmt, parsed_until, err);
73}
74
82static const struct ExpandoDefinition FolderFormatDef[] = {
83 // clang-format off
84 { "*", "padding-soft", ED_GLOBAL, ED_GLO_PADDING_SOFT, node_padding_parse },
85 { ">", "padding-hard", ED_GLOBAL, ED_GLO_PADDING_HARD, node_padding_parse },
86 { "|", "padding-eol", ED_GLOBAL, ED_GLO_PADDING_EOL, node_padding_parse },
87 { " ", "padding-space", ED_GLOBAL, ED_GLO_PADDING_SPACE, NULL },
88 { "a", "notify", ED_FOLDER, ED_FOL_NOTIFY, NULL },
89 { "C", "number", ED_FOLDER, ED_FOL_NUMBER, NULL },
90 { "d", "date", ED_FOLDER, ED_FOL_DATE, NULL },
91 { "D", "date-format", ED_FOLDER, ED_FOL_DATE_FORMAT, NULL },
92 { "f", "filename", ED_FOLDER, ED_FOL_FILENAME, NULL },
93 { "F", "file-mode", ED_FOLDER, ED_FOL_FILE_MODE, NULL },
94 { "g", "file-group", ED_FOLDER, ED_FOL_FILE_GROUP, NULL },
95 { "i", "description", ED_FOLDER, ED_FOL_DESCRIPTION, NULL },
96 { "l", "hard-links", ED_FOLDER, ED_FOL_HARD_LINKS, NULL },
97 { "m", "message-count", ED_FOLDER, ED_FOL_MESSAGE_COUNT, NULL },
98 { "n", "unread-count", ED_FOLDER, ED_FOL_UNREAD_COUNT, NULL },
99 { "N", "new-mail", ED_FOLDER, ED_FOL_NEW_MAIL, NULL },
100 { "p", "poll", ED_FOLDER, ED_FOL_POLL, NULL },
101 { "s", "file-size", ED_FOLDER, ED_FOL_FILE_SIZE, NULL },
102 { "t", "tagged", ED_FOLDER, ED_FOL_TAGGED, NULL },
103 { "u", "file-owner", ED_FOLDER, ED_FOL_FILE_OWNER, NULL },
104 { "[", NULL, ED_FOLDER, ED_FOL_STRF, parse_folder_date },
105 { NULL, NULL, 0, -1, NULL }
106 // clang-format on
107};
108
115static const struct ExpandoDefinition GroupIndexFormatDef[] = {
116 // clang-format off
117 { "*", "padding-soft", ED_GLOBAL, ED_GLO_PADDING_SOFT, node_padding_parse },
118 { ">", "padding-hard", ED_GLOBAL, ED_GLO_PADDING_HARD, node_padding_parse },
119 { "|", "padding-eol", ED_GLOBAL, ED_GLO_PADDING_EOL, node_padding_parse },
120 { "a", "notify", ED_FOLDER, ED_FOL_NOTIFY, NULL },
121 { "C", "number", ED_FOLDER, ED_FOL_NUMBER, NULL },
122 { "d", "description", ED_FOLDER, ED_FOL_DESCRIPTION, NULL },
123 { "f", "newsgroup", ED_FOLDER, ED_FOL_NEWSGROUP, NULL },
124 { "M", "flags", ED_FOLDER, ED_FOL_FLAGS, NULL },
125 { "n", "new-count", ED_FOLDER, ED_FOL_NEW_COUNT, NULL },
126 { "N", "flags2", ED_FOLDER, ED_FOL_FLAGS2, NULL },
127 { "p", "poll", ED_FOLDER, ED_FOL_POLL, NULL },
128 { "s", "unread-count", ED_FOLDER, ED_FOL_UNREAD_COUNT, NULL },
129 { NULL, NULL, 0, -1, NULL }
130 // clang-format on
131};
132
136static struct ConfigDef BrowserVars[] = {
137 // clang-format off
138 { "browser_abbreviate_mailboxes", DT_BOOL, true, 0, NULL,
139 "Abbreviate mailboxes using '~' and '=' in the browser"
140 },
141 { "folder_format", DT_EXPANDO|D_NOT_EMPTY, IP "%2C %t %N %F %2l %-8.8u %-8.8g %8s %d %i", IP &FolderFormatDef, NULL,
142 "printf-like format string for the browser's display of folders"
143 },
144 { "group_index_format", DT_EXPANDO|D_NOT_EMPTY, IP "%4C %M%N %5s %-45.45f %d", IP &GroupIndexFormatDef, NULL,
145 "(nntp) printf-like format string for the browser's display of newsgroups"
146 },
147 { "mailbox_folder_format", DT_EXPANDO|D_NOT_EMPTY, IP "%2C %<n?%6n& > %6m %i", IP &FolderFormatDef, NULL,
148 "printf-like format string for the browser's display of mailbox folders"
149 },
150 { "mask", DT_REGEX|D_REGEX_MATCH_CASE|D_REGEX_ALLOW_NOT|D_REGEX_NOSUB, IP "!^\\.[^.]", 0, NULL,
151 "Only display files/dirs matching this regex in the browser"
152 },
153 { "show_only_unread", DT_BOOL, false, 0, NULL,
154 "(nntp) Only show subscribed newsgroups with unread articles"
155 },
156 { "sort_browser", DT_SORT|D_SORT_REVERSE, SORT_ALPHA, IP SortBrowserMethods, NULL,
157 "Sort method for the browser"
158 },
159 { "browser_sort_dirs_first", DT_BOOL, false, 0, NULL,
160 "Group directories before files in the browser"
161 },
162 { NULL },
163 // clang-format on
164};
165
170{
172}
static struct ConfigDef BrowserVars[]
Config definitions for the browser.
Definition: config.c:136
static const struct Mapping SortBrowserMethods[]
Sort methods for the folder/dir browser.
Definition: config.c:42
static const struct ExpandoDefinition GroupIndexFormatDef[]
Expando definitions.
Definition: config.c:115
static const struct ExpandoDefinition FolderFormatDef[]
Expando definitions.
Definition: config.c:82
@ ED_FOL_POLL
FolderFile.poll_new_mail.
Definition: lib.h:133
@ ED_FOL_NOTIFY
FolderFile.notify_user.
Definition: lib.h:131
@ ED_FOL_NEW_COUNT
FolderFile.nd (NntpMboxData)
Definition: lib.h:129
@ ED_FOL_FILE_OWNER
FolderFile.uid.
Definition: lib.h:122
@ ED_FOL_FILE_GROUP
FolderFile.gid.
Definition: lib.h:120
@ ED_FOL_FILENAME
FolderFile.name.
Definition: lib.h:119
@ ED_FOL_DATE_FORMAT
FolderFile.mtime.
Definition: lib.h:117
@ ED_FOL_UNREAD_COUNT
FolderFile.msg_unread.
Definition: lib.h:136
@ ED_FOL_FLAGS2
FolderFile.nd (NntpMboxData)
Definition: lib.h:125
@ ED_FOL_FILE_MODE
FolderFile.move.
Definition: lib.h:121
@ ED_FOL_NEW_MAIL
FolderFile.has_new_mail.
Definition: lib.h:130
@ ED_FOL_FILE_SIZE
FolderFile.size.
Definition: lib.h:123
@ ED_FOL_HARD_LINKS
FolderFile.nlink.
Definition: lib.h:126
@ ED_FOL_DATE
FolderFile.mtime.
Definition: lib.h:116
@ ED_FOL_STRF
FolderFile.mtime.
Definition: lib.h:134
@ ED_FOL_TAGGED
FolderFile.tagged.
Definition: lib.h:135
@ ED_FOL_NUMBER
Folder.num.
Definition: lib.h:132
@ ED_FOL_DESCRIPTION
FolderFile.desc, FolderFile.name.
Definition: lib.h:118
@ ED_FOL_MESSAGE_COUNT
FolderFile.msg_count.
Definition: lib.h:127
@ ED_FOL_NEWSGROUP
FolderFile.name.
Definition: lib.h:128
@ ED_FOL_FLAGS
FolderFile.nd (NntpMboxData)
Definition: lib.h:124
Convenience wrapper for the config headers.
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition: set.c:281
#define IP
Definition: set.h:54
uint8_t ExpandoParserFlags
Flags for expando_parse(), e.g. EP_CONDITIONAL.
Definition: definition.h:33
#define EP_CONDITIONAL
Expando is being used as a condition.
Definition: definition.h:35
@ ED_FOLDER
Folder ED_FOL_ ExpandoDataFolder.
Definition: domain.h:43
@ ED_GLOBAL
Global ED_GLO_ ExpandoDataGlobal.
Definition: domain.h:44
Parse Expando string.
bool config_init_browser(struct ConfigSet *cs)
Register browser config variables - Implements module_init_config_t -.
Definition: config.c:169
struct ExpandoNode * node_padding_parse(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Padding Expando - Implements ExpandoDefinition::parse() -.
Definition: node_padding.c:234
struct ExpandoNode * parse_folder_date(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Date Expando - Implements ExpandoDefinition::parse() -.
Definition: config.c:62
Convenience wrapper for the library headers.
struct ExpandoNode * node_conddate_parse(const char *str, int did, int uid, const char **parsed_until, struct ExpandoParseError *err)
Parse a CondDate format string.
struct ExpandoNode * node_expando_parse_enclosure(const char *str, int did, int uid, char terminator, struct ExpandoFormat *fmt, const char **parsed_until, struct ExpandoParseError *err)
Parse an enclosed Expando.
Definition: node_expando.c:349
@ SORT_SUBJECT
Sort by the email's subject.
Definition: sort2.h:38
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:40
@ SORT_SIZE
Sort by the size of the email.
Definition: sort2.h:36
@ SORT_DESC
Sort by the folder's description.
Definition: sort2.h:55
@ SORT_ALPHA
Required by makedoc.c.
Definition: sort2.h:37
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:35
@ SORT_COUNT
Sort by number of emails in a folder.
Definition: sort2.h:50
@ SORT_UNREAD
Sort by the number of unread emails.
Definition: sort2.h:51
Key value store.
Definition: set.h:64
Container for lots of config items.
Definition: set.h:252
Definition of a format string.
Definition: definition.h:44
Formatting information for an Expando.
Definition: node.h:53
Basic Expando Node.
Definition: node.h:67
int uid
Unique ID, e.g. ED_EMA_SIZE.
Definition: node.h:70
int did
Domain ID, e.g. ED_EMAIL.
Definition: node.h:69
Buffer for parsing errors.
Definition: parse.h:37
Mapping between user-readable string and a constant.
Definition: mapping.h:33
#define D_REGEX_ALLOW_NOT
Regex can begin with '!'.
Definition: types.h:107
#define D_REGEX_MATCH_CASE
Case-sensitive matching.
Definition: types.h:106
@ DT_BOOL
boolean option
Definition: types.h:32
@ DT_SORT
sorting methods
Definition: types.h:44
@ DT_EXPANDO
an expando
Definition: types.h:34
@ DT_REGEX
regular expressions
Definition: types.h:42
#define D_SORT_REVERSE
Sort flag for -reverse prefix.
Definition: types.h:120
#define D_NOT_EMPTY
Empty strings are not allowed.
Definition: types.h:80
#define D_REGEX_NOSUB
Do not report what was matched (REG_NOSUB)
Definition: types.h:108
@ ED_GLO_PADDING_EOL
Padding to end-of-line.
Definition: uid.h:36
@ ED_GLO_PADDING_HARD
Hard Padding.
Definition: uid.h:37
@ ED_GLO_PADDING_SOFT
Soft Padding.
Definition: uid.h:38
@ ED_GLO_PADDING_SPACE
Space Padding.
Definition: uid.h:39