NeoMutt  2025-01-09-117-gace867
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
set.c
Go to the documentation of this file.
1
31#include "config.h"
32#include <stdbool.h>
33#include <stdio.h>
34#include "mutt/lib.h"
35#include "config/lib.h"
36#include "core/lib.h"
37#include "mutt.h"
38#include "set.h"
39#include "commands.h"
40#include "extract.h"
41#include "muttlib.h"
42
58void command_set_expand_value(int type, struct Buffer *value)
59{
60 ASSERT(value);
61 if (CONFIG_TYPE(type) == DT_PATH)
62 {
63 if (type & (D_PATH_DIR | D_PATH_FILE))
64 buf_expand_path(value);
65 else
67 }
68 else if (IS_MAILBOX(type))
69 {
70 buf_expand_path(value);
71 }
72 else if (IS_COMMAND(type))
73 {
74 struct Buffer *scratch = buf_pool_get();
75 buf_copy(scratch, value);
76
77 if (!mutt_str_equal(value->data, "builtin"))
78 {
79 buf_expand_path(scratch);
80 }
81 buf_reset(value);
82 buf_addstr(value, buf_string(scratch));
83 buf_pool_release(&scratch);
84 }
85}
86
99enum CommandResult command_set_set(struct Buffer *name, struct Buffer *value,
100 struct Buffer *err)
101{
102 ASSERT(name);
103 ASSERT(value);
104 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
105 if (!he)
106 {
107 // In case it is a my_var, we have to create it
108 if (mutt_str_startswith(name->data, "my_"))
109 {
110 struct ConfigDef my_cdef = { 0 };
111 my_cdef.name = name->data;
112 my_cdef.type = DT_MYVAR;
113 he = cs_create_variable(NeoMutt->sub->cs, &my_cdef, err);
114 if (!he)
115 return MUTT_CMD_ERROR; // LCOV_EXCL_LINE
116 }
117 else
118 {
119 buf_printf(err, _("Unknown option %s"), name->data);
120 return MUTT_CMD_ERROR;
121 }
122 }
123
124 if (he->type & D_INTERNAL_DEPRECATED)
125 {
126 mutt_warning(_("Option %s is deprecated"), name->data);
127 return MUTT_CMD_SUCCESS;
128 }
129 int rc = CSR_ERR_CODE;
130
131 if (CONFIG_TYPE(he->type) == DT_MYVAR)
132 {
133 // my variables do not expand their value
134 rc = cs_subset_he_string_set(NeoMutt->sub, he, value->data, err);
135 }
136 else
137 {
138 command_set_expand_value(he->type, value);
139 rc = cs_subset_he_string_set(NeoMutt->sub, he, value->data, err);
140 }
141 if (CSR_RESULT(rc) != CSR_SUCCESS)
142 return MUTT_CMD_ERROR; // LCOV_EXCL_LINE
143
144 return MUTT_CMD_SUCCESS;
145}
146
160 struct Buffer *value, struct Buffer *err)
161{
162 ASSERT(name);
163 ASSERT(value);
164 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
165 if (!he)
166 {
167 // In case it is a my_var, we have to create it
168 if (mutt_str_startswith(name->data, "my_"))
169 {
170 struct ConfigDef my_cdef = { 0 };
171 my_cdef.name = name->data;
172 my_cdef.type = DT_MYVAR;
173 he = cs_create_variable(NeoMutt->sub->cs, &my_cdef, err);
174 if (!he)
175 return MUTT_CMD_ERROR; // LCOV_EXCL_LINE
176 }
177 else
178 {
179 buf_printf(err, _("Unknown option %s"), name->data);
180 return MUTT_CMD_ERROR;
181 }
182 }
183
184 if (he->type & D_INTERNAL_DEPRECATED)
185 {
186 mutt_warning(_("Option %s is deprecated"), name->data);
187 return MUTT_CMD_SUCCESS;
188 }
189
190 int rc = CSR_ERR_CODE;
191
192 if (CONFIG_TYPE(he->type) == DT_MYVAR)
193 {
194 // my variables do not expand their value
195 rc = cs_subset_he_string_plus_equals(NeoMutt->sub, he, value->data, err);
196 }
197 else
198 {
199 command_set_expand_value(he->type, value);
200 rc = cs_subset_he_string_plus_equals(NeoMutt->sub, he, value->data, err);
201 }
202 if (CSR_RESULT(rc) != CSR_SUCCESS)
203 return MUTT_CMD_ERROR;
204
205 return MUTT_CMD_SUCCESS;
206}
207
221 struct Buffer *value, struct Buffer *err)
222{
223 ASSERT(name);
224 ASSERT(value);
225 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
226 if (!he)
227 {
228 buf_printf(err, _("Unknown option %s"), name->data);
229 return MUTT_CMD_ERROR;
230 }
231
232 if (he->type & D_INTERNAL_DEPRECATED)
233 {
234 mutt_warning(_("Option %s is deprecated"), name->data);
235 return MUTT_CMD_SUCCESS;
236 }
237
238 command_set_expand_value(he->type, value);
239 int rc = cs_subset_he_string_minus_equals(NeoMutt->sub, he, value->data, err);
240 if (CSR_RESULT(rc) != CSR_SUCCESS)
241 return MUTT_CMD_ERROR;
242
243 return MUTT_CMD_SUCCESS;
244}
245
256enum CommandResult command_set_unset(struct Buffer *name, struct Buffer *err)
257{
258 ASSERT(name);
259 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
260 if (!he)
261 {
262 buf_printf(err, _("Unknown option %s"), name->data);
263 return MUTT_CMD_ERROR;
264 }
265
266 if (he->type & D_INTERNAL_DEPRECATED)
267 {
268 mutt_warning(_("Option %s is deprecated"), name->data);
269 return MUTT_CMD_SUCCESS;
270 }
271
272 int rc = CSR_ERR_CODE;
273 if (CONFIG_TYPE(he->type) == DT_MYVAR)
274 {
275 rc = cs_subset_he_delete(NeoMutt->sub, he, err);
276 }
277 else if ((CONFIG_TYPE(he->type) == DT_BOOL) || (CONFIG_TYPE(he->type) == DT_QUAD))
278 {
279 rc = cs_subset_he_native_set(NeoMutt->sub, he, false, err);
280 }
281 else
282 {
283 rc = cs_subset_he_string_set(NeoMutt->sub, he, NULL, err);
284 }
285 if (CSR_RESULT(rc) != CSR_SUCCESS)
286 return MUTT_CMD_ERROR; // LCOV_EXCL_LINE
287
288 return MUTT_CMD_SUCCESS;
289}
290
301enum CommandResult command_set_reset(struct Buffer *name, struct Buffer *err)
302{
303 ASSERT(name);
304 // Handle special "reset all" syntax
305 if (mutt_str_equal(name->data, "all"))
306 {
307 struct HashElemArray hea = get_elem_list(NeoMutt->sub->cs, GEL_ALL_CONFIG);
308 struct HashElem **hep = NULL;
309 ARRAY_FOREACH(hep, &hea)
310 {
311 struct HashElem *he = *hep;
312 if (CONFIG_TYPE(he->type) == DT_MYVAR)
314 else
315 cs_subset_he_reset(NeoMutt->sub, he, NULL);
316 }
317
318 ARRAY_FREE(&hea);
319 return MUTT_CMD_SUCCESS;
320 }
321
322 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
323 if (!he)
324 {
325 buf_printf(err, _("Unknown option %s"), name->data);
326 return MUTT_CMD_ERROR;
327 }
328
329 if (he->type & D_INTERNAL_DEPRECATED)
330 {
331 mutt_warning(_("Option %s is deprecated"), name->data);
332 return MUTT_CMD_SUCCESS;
333 }
334
335 int rc = CSR_ERR_CODE;
336 if (CONFIG_TYPE(he->type) == DT_MYVAR)
337 {
338 rc = cs_subset_he_delete(NeoMutt->sub, he, err);
339 }
340 else
341 {
342 rc = cs_subset_he_reset(NeoMutt->sub, he, err);
343 }
344 if (CSR_RESULT(rc) != CSR_SUCCESS)
345 return MUTT_CMD_ERROR; // LCOV_EXCL_LINE
346
347 return MUTT_CMD_SUCCESS;
348}
349
360enum CommandResult command_set_toggle(struct Buffer *name, struct Buffer *err)
361{
362 ASSERT(name);
363 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
364 if (!he)
365 {
366 buf_printf(err, _("Unknown option %s"), name->data);
367 return MUTT_CMD_ERROR;
368 }
369
370 if (he->type & D_INTERNAL_DEPRECATED)
371 {
372 mutt_warning(_("Option %s is deprecated"), name->data);
373 return MUTT_CMD_SUCCESS;
374 }
375
376 if (CONFIG_TYPE(he->type) == DT_BOOL)
377 {
378 bool_he_toggle(NeoMutt->sub, he, err);
379 }
380 else if (CONFIG_TYPE(he->type) == DT_QUAD)
381 {
382 quad_he_toggle(NeoMutt->sub, he, err);
383 }
384 else if (CONFIG_TYPE(he->type) == DT_NUMBER)
385 {
386 number_he_toggle(NeoMutt->sub, he, err);
387 }
388 else
389 {
390 buf_printf(err, _("Command '%s' can only be used with bool/quad variables"), "toggle");
391 return MUTT_CMD_ERROR;
392 }
393 return MUTT_CMD_SUCCESS;
394}
395
406enum CommandResult command_set_query(struct Buffer *name, struct Buffer *err)
407{
408 ASSERT(name);
409 // In the interactive case (outside of the initial parsing of neomuttrc) we
410 // support additional syntax: "set" (no arguments) and "set all".
411 // If not in interactive mode, we recognise them but do nothing.
412
413 // Handle "set" (no arguments), i.e. show list of changed variables.
414 if (buf_is_empty(name))
415 {
416 if (StartupComplete)
417 return set_dump(GEL_CHANGED_CONFIG, err);
418 else
419 return MUTT_CMD_SUCCESS;
420 }
421 // Handle special "set all" syntax
422 if (mutt_str_equal(name->data, "all"))
423 {
424 if (StartupComplete)
425 return set_dump(GEL_ALL_CONFIG, err);
426 else
427 return MUTT_CMD_SUCCESS;
428 }
429
430 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, name->data);
431 if (!he)
432 {
433 buf_printf(err, _("Unknown option %s"), name->data);
434 return MUTT_CMD_ERROR;
435 }
436
437 if (he->type & D_INTERNAL_DEPRECATED)
438 {
439 mutt_warning(_("Option %s is deprecated"), name->data);
440 return MUTT_CMD_SUCCESS;
441 }
442
443 buf_addstr(err, name->data);
444 buf_addch(err, '=');
445 struct Buffer *value = buf_pool_get();
446 int rc = cs_subset_he_string_get(NeoMutt->sub, he, value);
447 if (CSR_RESULT(rc) != CSR_SUCCESS)
448 {
449 // LCOV_EXCL_START
450 buf_reset(err);
451 buf_addstr(err, value->data);
452 buf_pool_release(&value);
453 return MUTT_CMD_ERROR;
454 // LCOV_EXCL_STOP
455 }
456 if (CONFIG_TYPE(he->type) == DT_PATH)
457 mutt_pretty_mailbox(value->data, value->dsize);
458 pretty_var(value->data, err);
459 buf_pool_release(&value);
460
461 return MUTT_CMD_SUCCESS;
462}
463
469enum CommandResult parse_set(struct Buffer *buf, struct Buffer *s,
470 intptr_t data, struct Buffer *err)
471{
472 /* The order must match `enum MuttSetCommand` */
473 static const char *set_commands[] = { "set", "toggle", "unset", "reset" };
474
475 if (!buf || !s)
476 return MUTT_CMD_ERROR;
477
478 do
479 {
480 bool prefix = false;
481 bool query = false;
482 bool inv = (data == MUTT_SET_INV);
483 bool reset = (data == MUTT_SET_RESET);
484 bool unset = (data == MUTT_SET_UNSET);
485
486 if (*s->dptr == '?')
487 {
488 prefix = true;
489 query = true;
490 s->dptr++;
491 }
492 else if (mutt_str_startswith(s->dptr, "no"))
493 {
494 prefix = true;
495 unset = !unset;
496 s->dptr += 2;
497 }
498 else if (mutt_str_startswith(s->dptr, "inv"))
499 {
500 prefix = true;
501 inv = !inv;
502 s->dptr += 3;
503 }
504 else if (*s->dptr == '&')
505 {
506 prefix = true;
507 reset = true;
508 s->dptr++;
509 }
510
511 if (prefix && (data != MUTT_SET_SET))
512 {
513 buf_printf(err, _("Can't use 'inv', 'no', '&' or '?' with the '%s' command"),
514 set_commands[data]);
515 return MUTT_CMD_WARNING;
516 }
517
518 // get the variable name. Note that buf might be empty if no additional
519 // argument was given.
521 if (ret == -1)
522 return MUTT_CMD_ERROR;
523
524 bool bool_or_quad = false;
525 bool invertible = false;
526 bool equals = false;
527 bool increment = false;
528 bool decrement = false;
529
530 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, buf->data);
531 if (he)
532 {
533 // Use the correct name if a synonym is used
534 buf_strcpy(buf, he->key.strkey);
535 bool_or_quad = ((CONFIG_TYPE(he->type) == DT_BOOL) ||
536 (CONFIG_TYPE(he->type) == DT_QUAD));
537 invertible = (bool_or_quad || (CONFIG_TYPE(he->type) == DT_NUMBER));
538 }
539
540 if (*s->dptr == '?')
541 {
542 if (prefix)
543 {
544 buf_printf(err, _("Can't use a prefix when querying a variable"));
545 return MUTT_CMD_WARNING;
546 }
547
548 if (reset || unset || inv)
549 {
550 buf_printf(err, _("Can't query option with the '%s' command"), set_commands[data]);
551 return MUTT_CMD_WARNING;
552 }
553
554 query = true;
555 s->dptr++;
556 }
557 else if ((*s->dptr == '+') || (*s->dptr == '-'))
558 {
559 if (prefix)
560 {
561 buf_printf(err, _("Can't use prefix when incrementing or decrementing a variable"));
562 return MUTT_CMD_WARNING;
563 }
564
565 if (reset || unset || inv)
566 {
567 buf_printf(err, _("Can't set option with the '%s' command"), set_commands[data]);
568 return MUTT_CMD_WARNING;
569 }
570 if (*s->dptr == '+')
571 increment = true;
572 else
573 decrement = true;
574
575 s->dptr++;
576 if (*s->dptr == '=')
577 {
578 equals = true;
579 s->dptr++;
580 }
581 else
582 {
583 buf_printf(err, _("'+' and '-' must be followed by '='"));
584 return MUTT_CMD_WARNING;
585 }
586 }
587 else if (*s->dptr == '=')
588 {
589 if (prefix)
590 {
591 buf_printf(err, _("Can't use prefix when setting a variable"));
592 return MUTT_CMD_WARNING;
593 }
594
595 if (reset || unset || inv)
596 {
597 buf_printf(err, _("Can't set option with the '%s' command"), set_commands[data]);
598 return MUTT_CMD_WARNING;
599 }
600
601 equals = true;
602 s->dptr++;
603 }
604
605 if (!invertible && (inv || (unset && prefix)))
606 {
607 if (data == MUTT_SET_SET)
608 {
609 buf_printf(err, _("Prefixes 'no' and 'inv' may only be used with bool/quad/number variables"));
610 }
611 else
612 {
613 buf_printf(err, _("Command '%s' can only be used with bool/quad/number variables"),
614 set_commands[data]);
615 }
616 return MUTT_CMD_WARNING;
617 }
618
619 // sanity checks for the above
620 // Each of inv, unset reset, query, equals implies that the others are not set.
621 // If none of them are set, then we are dealing with a "set foo" command.
622 // clang-format off
623 ASSERT(!inv || !( unset || reset || query || equals ));
624 ASSERT(!unset || !(inv || reset || query || equals ));
625 ASSERT(!reset || !(inv || unset || query || equals ));
626 ASSERT(!query || !(inv || unset || reset || equals ));
627 ASSERT(!equals || !(inv || unset || reset || query || prefix));
628 // clang-format on
629 ASSERT(!(increment && decrement)); // only one of increment or decrement is set
630 ASSERT(!(increment || decrement) || equals); // increment/decrement implies equals
631 ASSERT(!inv || invertible); // inv (aka toggle) implies bool or quad
632
634 if (query)
635 {
636 rc = command_set_query(buf, err);
637 return rc; // We can only do one query even if multiple config names are given
638 }
639 else if (reset)
640 {
641 rc = command_set_reset(buf, err);
642 }
643 else if (unset)
644 {
645 rc = command_set_unset(buf, err);
646 }
647 else if (inv)
648 {
649 rc = command_set_toggle(buf, err);
650 }
651 else if (equals)
652 {
653 // These three cases all need a value, since 'increment'/'decrement'
654 // implies 'equals', we can group them in this single case guarded by
655 // 'equals'.
656 struct Buffer *value = buf_pool_get();
658 if (increment)
659 rc = command_set_increment(buf, value, err);
660 else if (decrement)
661 rc = command_set_decrement(buf, value, err);
662 else
663 rc = command_set_set(buf, value, err);
664 buf_pool_release(&value);
665 }
666 else
667 {
668 // This is the "set foo" case which has different meanings depending on
669 // the type of the config variable
670 if (bool_or_quad)
671 {
672 struct Buffer *yes = buf_pool_get();
673 buf_addstr(yes, "yes");
674 rc = command_set_set(buf, yes, err);
675 buf_pool_release(&yes);
676 }
677 else
678 {
679 rc = command_set_query(buf, err);
680 return rc; // We can only do one query even if multiple config names are given
681 }
682 }
683 // Short circuit (i.e. skipping further config variable names) if the action on
684 // the current variable failed.
685 if (rc != MUTT_CMD_SUCCESS)
686 return rc;
687 } while (MoreArgs(s));
688
689 return MUTT_CMD_SUCCESS;
690}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:214
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
int bool_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:201
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:291
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:241
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:601
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
CommandResult
Error codes for command_t parse functions.
Definition: command.h:35
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition: command.h:38
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition: command.h:36
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition: command.h:37
enum CommandResult set_dump(enum GetElemListFlags flags, struct Buffer *err)
Dump list of config variables into a file/pager.
Definition: commands.c:888
Functions to parse commands in a config file.
size_t pretty_var(const char *str, struct Buffer *buf)
Escape and stringify a config item value.
Definition: dump.c:85
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:440
Convenience wrapper for the config headers.
struct HashElem * cs_create_variable(const struct ConfigSet *cs, struct ConfigDef *cdef, struct Buffer *err)
Create and register one config item.
Definition: set.c:326
#define CSR_ERR_CODE
Problem with the code.
Definition: set.h:34
#define CSR_RESULT(x)
Definition: set.h:50
bool StartupComplete
When the config has been read.
Definition: address.c:14
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:33
Convenience wrapper for the core headers.
int parse_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: extract.c:49
Text parser.
#define TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition: extract.h:54
#define TOKEN_EQUAL
Treat '=' as a special.
Definition: extract.h:47
#define TOKEN_PLUS
Treat '+' as a special.
Definition: extract.h:57
#define MoreArgs(buf)
Definition: extract.h:32
#define TOKEN_MINUS
Treat '-' as a special.
Definition: extract.h:58
#define TOKEN_QUESTION
Treat '?' as a special.
Definition: extract.h:56
enum CommandResult parse_set(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'set' family of commands - Implements Command::parse() -.
Definition: set.c:469
#define mutt_warning(...)
Definition: logging2.h:91
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
bool mutt_path_tilde(struct Buffer *path, const char *homedir)
Expand '~' in a path.
Definition: path.c:194
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:661
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:231
Many unsorted constants and some structs.
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:315
Some miscellaneous functions.
int number_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a number (value <-> 0)
Definition: number.c:307
enum CommandResult command_set_increment(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Increment a variable by a value.
Definition: set.c:159
void command_set_expand_value(int type, struct Buffer *value)
Expand special characters.
Definition: set.c:58
enum CommandResult command_set_decrement(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Decrement a variable by a value.
Definition: set.c:220
enum CommandResult command_set_toggle(struct Buffer *name, struct Buffer *err)
Toggle a boolean, quad, or number variable.
Definition: set.c:360
enum CommandResult command_set_reset(struct Buffer *name, struct Buffer *err)
Reset a variable.
Definition: set.c:301
enum CommandResult command_set_query(struct Buffer *name, struct Buffer *err)
Query a variable.
Definition: set.c:406
enum CommandResult command_set_unset(struct Buffer *name, struct Buffer *err)
Unset a variable.
Definition: set.c:256
enum CommandResult command_set_set(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Set a variable to the given value.
Definition: set.c:99
Parse the 'set' command.
@ MUTT_SET_INV
default is to invert all vars
Definition: set.h:37
@ MUTT_SET_SET
default is to set all vars
Definition: set.h:36
@ MUTT_SET_RESET
default is to reset all vars to default
Definition: set.h:39
@ MUTT_SET_UNSET
default is to unset all vars
Definition: set.h:38
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
int quad_he_toggle(struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Toggle the value of a quad.
Definition: quad.c:223
#define ASSERT(COND)
Definition: signal2.h:60
String manipulation buffer.
Definition: buffer.h:36
char * dptr
Current read/write position.
Definition: buffer.h:38
size_t dsize
Length of data.
Definition: buffer.h:39
char * data
Pointer to data.
Definition: buffer.h:37
Definition: set.h:62
const char * name
User-visible name.
Definition: set.h:63
uint32_t type
Variable type, e.g. DT_STRING.
Definition: set.h:64
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:50
The item stored in a Hash Table.
Definition: hash.h:44
union HashKey key
Key representing the data.
Definition: hash.h:46
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:45
void * data
User-supplied data.
Definition: hash.h:47
Container for Accounts, Notifications.
Definition: neomutt.h:43
char * home_dir
User's home directory.
Definition: neomutt.h:53
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:47
int cs_subset_he_string_minus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Remove from a config item by string.
Definition: subset.c:426
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:334
int cs_subset_he_native_set(const struct ConfigSubset *sub, struct HashElem *he, intptr_t value, struct Buffer *err)
Natively set the value of a HashElem config item.
Definition: subset.c:277
int cs_subset_he_delete(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Delete config item from a config.
Definition: subset.c:447
int cs_subset_he_reset(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *err)
Reset a config item to its initial value.
Definition: subset.c:314
int cs_subset_he_string_set(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:366
struct HashElemArray get_elem_list(struct ConfigSet *cs, enum GetElemListFlags flags)
Create a sorted list of all config items.
Definition: subset.c:80
int cs_subset_he_string_plus_equals(const struct ConfigSubset *sub, struct HashElem *he, const char *value, struct Buffer *err)
Add to a config item by string.
Definition: subset.c:404
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition: subset.c:189
@ GEL_CHANGED_CONFIG
Only config that has been changed.
Definition: subset.h:82
@ GEL_ALL_CONFIG
All the normal config (no synonyms or deprecated)
Definition: subset.h:81
#define CONFIG_TYPE(t)
Definition: types.h:49
#define IS_MAILBOX(flags)
Definition: types.h:121
#define D_INTERNAL_DEPRECATED
Config item shouldn't be used any more.
Definition: types.h:87
#define D_PATH_DIR
Path is a directory.
Definition: types.h:102
#define D_PATH_FILE
Path is a file.
Definition: types.h:103
@ DT_NUMBER
a number
Definition: types.h:38
@ DT_BOOL
boolean option
Definition: types.h:32
@ DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition: types.h:40
@ DT_MYVAR
a user-defined variable (my_foo)
Definition: types.h:37
@ DT_PATH
a path to a file/directory
Definition: types.h:39
#define IS_COMMAND(flags)
Definition: types.h:122
const char * strkey
String key.
Definition: hash.h:36