NeoMutt  2025-12-11-58-g09398d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
commands.c
Go to the documentation of this file.
1
30
36
37#include "config.h"
38#include <errno.h>
39#include <limits.h>
40#include <stdbool.h>
41#include <stdio.h>
42#include <string.h>
43#include <sys/types.h>
44#include <unistd.h>
45#include "mutt/lib.h"
46#include "address/lib.h"
47#include "config/lib.h"
48#include "email/lib.h"
49#include "core/lib.h"
50#include "alias/lib.h"
51#include "gui/lib.h"
52#include "mutt.h"
53#include "commands.h"
54#include "attach/lib.h"
55#include "color/lib.h"
56#include "imap/lib.h"
57#include "key/lib.h"
58#include "menu/lib.h"
59#include "pager/lib.h"
60#include "parse/lib.h"
61#include "store/lib.h"
62#include "alternates.h"
63#include "globals.h"
64#include "muttlib.h"
65#include "mx.h"
66#include "score.h"
67#include "version.h"
68#ifdef USE_INOTIFY
69#include "monitor.h"
70#endif
71#ifdef ENABLE_NLS
72#include <libintl.h>
73#endif
74
78
79#define MAX_ERRS 128
80
90
100
107static bool is_function(const char *name)
108{
109 for (size_t i = 0; MenuNames[i].name; i++)
110 {
111 const struct MenuFuncOp *fns = km_get_table(MenuNames[i].value);
112 if (!fns)
113 continue;
114
115 for (int j = 0; fns[j].name; j++)
116 if (mutt_str_equal(name, fns[j].name))
117 return true;
118 }
119 return false;
120}
121
128static bool is_color_object(const char *name)
129{
131
132 return (cid > 0);
133}
134
145int parse_grouplist(struct GroupList *gl, struct Buffer *token, struct Buffer *line,
146 struct Buffer *err, struct HashTable *groups)
147{
148 while (mutt_istr_equal(token->data, "-group"))
149 {
150 if (!MoreArgs(line))
151 {
152 buf_strcpy(err, _("-group: no group name"));
153 return -1;
154 }
155
157
158 grouplist_add_group(gl, groups_get_group(groups, token->data));
159
160 if (!MoreArgs(line))
161 {
162 buf_strcpy(err, _("out of arguments"));
163 return -1;
164 }
165
167 }
168
169 return 0;
170}
171
179enum CommandResult parse_rc_line_cwd(const char *line, char *cwd, struct Buffer *err)
180{
182
183 struct Buffer *buf = buf_pool_get();
184 buf_strcpy(buf, line);
185 enum CommandResult ret = parse_rc_line(buf, err);
186 buf_pool_release(&buf);
187
188 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
190 FREE(&np->data);
191 FREE(&np);
192
193 return ret;
194}
195
203{
204 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
205 if (np && np->data)
206 return mutt_str_dup(np->data);
207
208 // stack is empty, return our own dummy file relative to cwd
209 struct Buffer *cwd = buf_pool_get();
210 mutt_path_getcwd(cwd);
211 buf_addstr(cwd, "/dummy.rc");
212 char *ret = buf_strdup(cwd);
213 buf_pool_release(&cwd);
214 return ret;
215}
216
223int source_rc(const char *rcfile_path, struct Buffer *err)
224{
225 int lineno = 0, rc = 0, warnings = 0;
226 enum CommandResult line_rc;
227 struct Buffer *linebuf = NULL;
228 char *line = NULL;
229 char *currentline = NULL;
230 char rcfile[PATH_MAX + 1] = { 0 };
231 size_t linelen = 0;
232 pid_t pid;
233
234 mutt_str_copy(rcfile, rcfile_path, sizeof(rcfile));
235
236 size_t rcfilelen = mutt_str_len(rcfile);
237 if (rcfilelen == 0)
238 return -1;
239
240 bool ispipe = rcfile[rcfilelen - 1] == '|';
241
242 if (!ispipe)
243 {
244 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
245 if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
246 {
247 mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
248 return -1;
249 }
250
251 STAILQ_FOREACH(np, &MuttrcStack, entries)
252 {
253 if (mutt_str_equal(np->data, rcfile))
254 {
255 break;
256 }
257 }
258 if (np)
259 {
260 mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
261 return -1;
262 }
263
265 }
266
267 mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
268
269 FILE *fp = mutt_open_read(rcfile, &pid);
270 if (!fp)
271 {
272 buf_printf(err, "%s: %s", rcfile, strerror(errno));
273 return -1;
274 }
275
276 linebuf = buf_pool_get();
277
278 const char *const c_config_charset = cs_subset_string(NeoMutt->sub, "config_charset");
279 const char *const c_charset = cc_charset();
280 while ((line = mutt_file_read_line(line, &linelen, fp, &lineno, MUTT_RL_CONT)) != NULL)
281 {
282 const bool conv = c_config_charset && c_charset;
283 if (conv)
284 {
285 currentline = mutt_str_dup(line);
286 if (!currentline)
287 continue;
288 mutt_ch_convert_string(&currentline, c_config_charset, c_charset, MUTT_ICONV_NO_FLAGS);
289 }
290 else
291 {
292 currentline = line;
293 }
294
295 buf_strcpy(linebuf, currentline);
296
297 buf_reset(err);
298 line_rc = parse_rc_line(linebuf, err);
299 if (line_rc == MUTT_CMD_ERROR)
300 {
301 mutt_error("%s:%d: %s", rcfile, lineno, buf_string(err));
302 if (--rc < -MAX_ERRS)
303 {
304 if (conv)
305 FREE(&currentline);
306 break;
307 }
308 }
309 else if (line_rc == MUTT_CMD_WARNING)
310 {
311 /* Warning */
312 mutt_warning("%s:%d: %s", rcfile, lineno, buf_string(err));
313 warnings++;
314 }
315 else if (line_rc == MUTT_CMD_FINISH)
316 {
317 if (conv)
318 FREE(&currentline);
319 break; /* Found "finish" command */
320 }
321 else
322 {
323 if (rc < 0)
324 rc = -1;
325 }
326 if (conv)
327 FREE(&currentline);
328 }
329
330 FREE(&line);
331 mutt_file_fclose(&fp);
332 if (pid != -1)
333 filter_wait(pid);
334
335 if (rc)
336 {
337 /* the neomuttrc source keyword */
338 buf_reset(err);
339 buf_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
340 rcfile);
341 rc = -1;
342 }
343 else
344 {
345 /* Don't alias errors with warnings */
346 if (warnings > 0)
347 {
348 buf_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
349 warnings, rcfile);
350 rc = -2;
351 }
352 }
353
354 if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
355 {
356 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
358 FREE(&np->data);
359 FREE(&np);
360 }
361
362 buf_pool_release(&linebuf);
363 return rc;
364}
365
372enum CommandResult parse_cd(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
373{
374 struct Buffer *token = buf_pool_get();
376
378 if (buf_is_empty(token))
379 {
380 buf_strcpy(token, NeoMutt->home_dir);
381 }
382 else
383 {
384 buf_expand_path(token);
385 }
386
387 if (chdir(buf_string(token)) != 0)
388 {
389 buf_printf(err, "%s: %s", cmd->name, strerror(errno));
390 goto done;
391 }
392
393 rc = MUTT_CMD_SUCCESS;
394
395done:
396 buf_pool_release(&token);
397 return rc;
398}
399
406enum CommandResult parse_echo(const struct Command *cmd, struct Buffer *line,
407 struct Buffer *err)
408{
409 if (!MoreArgs(line))
410 {
411 buf_printf(err, _("%s: too few arguments"), cmd->name);
412 return MUTT_CMD_WARNING;
413 }
414
415 struct Buffer *token = buf_pool_get();
416
418 OptForceRefresh = true;
419 mutt_message("%s", buf_string(token));
420 OptForceRefresh = false;
421 mutt_sleep(0);
422
423 buf_pool_release(&token);
424 return MUTT_CMD_SUCCESS;
425}
426
437enum CommandResult parse_finish(const struct Command *cmd, struct Buffer *line,
438 struct Buffer *err)
439{
440 if (MoreArgs(line))
441 {
442 buf_printf(err, _("%s: too many arguments"), cmd->name);
443 return MUTT_CMD_WARNING;
444 }
445
446 return MUTT_CMD_FINISH;
447}
448
456enum CommandResult parse_group(const struct Command *cmd, struct Buffer *line,
457 struct Buffer *err)
458{
459 if (!MoreArgs(line))
460 {
461 buf_printf(err, _("%s: too few arguments"), cmd->name);
462 return MUTT_CMD_WARNING;
463 }
464
465 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
466 enum GroupState gstate = GS_NONE;
467 struct Buffer *token = buf_pool_get();
469
470 do
471 {
473 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
474 goto done;
475
476 if ((cmd->data == MUTT_UNGROUP) && mutt_istr_equal(buf_string(token), "*"))
477 {
479 rc = MUTT_CMD_SUCCESS;
480 goto done;
481 }
482
483 if (mutt_istr_equal(buf_string(token), "-rx"))
484 {
485 gstate = GS_RX;
486 }
487 else if (mutt_istr_equal(buf_string(token), "-addr"))
488 {
489 gstate = GS_ADDR;
490 }
491 else
492 {
493 switch (gstate)
494 {
495 case GS_NONE:
496 buf_printf(err, _("%s: missing -rx or -addr"), cmd->name);
497 rc = MUTT_CMD_WARNING;
498 goto done;
499
500 case GS_RX:
501 if ((cmd->data == MUTT_GROUP) &&
502 (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0))
503 {
504 goto done;
505 }
506 else if ((cmd->data == MUTT_UNGROUP) &&
507 (groups_remove_regex(NeoMutt->groups, &gl, buf_string(token)) < 0))
508 {
509 goto done;
510 }
511 break;
512
513 case GS_ADDR:
514 {
515 char *estr = NULL;
516 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
517 mutt_addrlist_parse2(&al, buf_string(token));
518 if (TAILQ_EMPTY(&al))
519 goto done;
520 if (mutt_addrlist_to_intl(&al, &estr))
521 {
522 buf_printf(err, _("%s: warning: bad IDN '%s'"), cmd->name, estr);
524 FREE(&estr);
525 goto done;
526 }
527 if (cmd->data == MUTT_GROUP)
528 grouplist_add_addrlist(&gl, &al);
529 else if (cmd->data == MUTT_UNGROUP)
532 break;
533 }
534 }
535 }
536 } while (MoreArgs(line));
537
538 rc = MUTT_CMD_SUCCESS;
539
540done:
541 buf_pool_release(&token);
543 return rc;
544}
545
563enum CommandResult parse_ifdef(const struct Command *cmd, struct Buffer *line,
564 struct Buffer *err)
565{
566 if (!MoreArgs(line))
567 {
568 buf_printf(err, _("%s: too few arguments"), cmd->name);
569 return MUTT_CMD_WARNING;
570 }
571
572 struct Buffer *token = buf_pool_get();
574
576
577 // is the item defined as:
578 bool res = cs_subset_lookup(NeoMutt->sub, buf_string(token)) // a variable?
579 || feature_enabled(buf_string(token)) // a compiled-in feature?
580 || is_function(buf_string(token)) // a function?
581 || commands_get(&NeoMutt->commands, buf_string(token)) // a command?
582 || is_color_object(buf_string(token)) // a color?
583#ifdef USE_HCACHE
584 || store_is_valid_backend(buf_string(token)) // a store? (database)
585#endif
586 || mutt_str_getenv(buf_string(token)); // an environment variable?
587
588 if (!MoreArgs(line))
589 {
590 buf_printf(err, _("%s: too few arguments"), cmd->name);
591 rc = MUTT_CMD_WARNING;
592 goto done;
593 }
594 parse_extract_token(token, line, TOKEN_SPACE);
595
596 /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
597 if ((res && (cmd->data == 0)) || (!res && (cmd->data == 1)))
598 {
599 rc = parse_rc_line(token, err);
600 if (rc == MUTT_CMD_ERROR)
601 mutt_error(_("Error: %s"), buf_string(err));
602
603 goto done;
604 }
605
606done:
607 buf_pool_release(&token);
608 return rc;
609}
610
617enum CommandResult parse_ignore(const struct Command *cmd, struct Buffer *line,
618 struct Buffer *err)
619{
620 if (!MoreArgs(line))
621 {
622 buf_printf(err, _("%s: too few arguments"), cmd->name);
623 return MUTT_CMD_WARNING;
624 }
625
626 struct Buffer *token = buf_pool_get();
627
628 do
629 {
633 } while (MoreArgs(line));
634
635 buf_pool_release(&token);
636 return MUTT_CMD_SUCCESS;
637}
638
645enum CommandResult parse_lists(const struct Command *cmd, struct Buffer *line,
646 struct Buffer *err)
647{
648 if (!MoreArgs(line))
649 {
650 buf_printf(err, _("%s: too few arguments"), cmd->name);
651 return MUTT_CMD_WARNING;
652 }
653
654 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
655 struct Buffer *token = buf_pool_get();
657
658 do
659 {
661
662 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
663 goto done;
664
666
667 if (mutt_regexlist_add(&MailLists, buf_string(token), REG_ICASE, err) != 0)
668 goto done;
669
670 if (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0)
671 goto done;
672 } while (MoreArgs(line));
673
674 rc = MUTT_CMD_SUCCESS;
675
676done:
677 buf_pool_release(&token);
679 return rc;
680}
681
692static enum CommandResult mailbox_add(const char *folder, const char *mailbox,
693 const char *label, enum TriBool poll,
694 enum TriBool notify, struct Buffer *err)
695{
696 mutt_debug(LL_DEBUG1, "Adding mailbox: '%s' label '%s', poll %s, notify %s\n",
697 mailbox, label ? label : "[NONE]",
698 (poll == TB_UNSET) ? "[UNSPECIFIED]" :
699 (poll == TB_TRUE) ? "true" :
700 "false",
701 (notify == TB_UNSET) ? "[UNSPECIFIED]" :
702 (notify == TB_TRUE) ? "true" :
703 "false");
704 struct Mailbox *m = mailbox_new();
705
706 buf_strcpy(&m->pathbuf, mailbox);
707 /* int rc = */ mx_path_canon2(m, folder);
708
709 if (m->type <= MUTT_UNKNOWN)
710 {
711 buf_printf(err, "Unknown Mailbox: %s", m->realpath);
712 mailbox_free(&m);
713 return MUTT_CMD_ERROR;
714 }
715
716 bool new_account = false;
717 struct Account *a = mx_ac_find(m);
718 if (!a)
719 {
720 a = account_new(NULL, NeoMutt->sub);
721 a->type = m->type;
722 new_account = true;
723 }
724
725 if (!new_account)
726 {
727 struct Mailbox *m_old = mx_mbox_find(a, m->realpath);
728 if (m_old)
729 {
730 if (!m_old->visible)
731 {
732 m_old->visible = true;
733 m_old->gen = mailbox_gen();
734 }
735
736 if (label)
737 mutt_str_replace(&m_old->name, label);
738
739 if (notify != TB_UNSET)
740 m_old->notify_user = notify;
741
742 if (poll != TB_UNSET)
743 m_old->poll_new_mail = poll;
744
745 struct EventMailbox ev_m = { m_old };
747
748 mailbox_free(&m);
749 return MUTT_CMD_SUCCESS;
750 }
751 }
752
753 if (label)
754 m->name = mutt_str_dup(label);
755
756 if (notify != TB_UNSET)
757 m->notify_user = notify;
758
759 if (poll != TB_UNSET)
760 m->poll_new_mail = poll;
761
762 if (!mx_ac_add(a, m))
763 {
764 mailbox_free(&m);
765 if (new_account)
766 {
767 cs_subset_free(&a->sub);
768 FREE(&a->name);
769 notify_free(&a->notify);
770 FREE(&a);
771 }
772 return MUTT_CMD_SUCCESS;
773 }
774
775 if (new_account)
776 {
778 }
779
780 // this is finally a visible mailbox in the sidebar and mailboxes list
781 m->visible = true;
782
783#ifdef USE_INOTIFY
785#endif
786
787 return MUTT_CMD_SUCCESS;
788}
789
796bool mailbox_add_simple(const char *mailbox, struct Buffer *err)
797{
798 enum CommandResult rc = mailbox_add("", mailbox, NULL, TB_UNSET, TB_UNSET, err);
799
800 return (rc == MUTT_CMD_SUCCESS);
801}
802
810enum CommandResult parse_mailboxes(const struct Command *cmd,
811 struct Buffer *line, struct Buffer *err)
812{
813 if (!MoreArgs(line))
814 {
815 buf_printf(err, _("%s: too few arguments"), cmd->name);
816 return MUTT_CMD_WARNING;
817 }
818
819 struct Buffer *label = buf_pool_get();
820 struct Buffer *mailbox = buf_pool_get();
821 struct Buffer *token = buf_pool_get();
823
824 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
825 while (MoreArgs(line))
826 {
827 bool label_set = false;
828 enum TriBool notify = TB_UNSET;
829 enum TriBool poll = TB_UNSET;
830
831 do
832 {
833 // Start by handling the options
835
836 if (mutt_str_equal(buf_string(token), "-label"))
837 {
838 if (!MoreArgs(line))
839 {
840 buf_printf(err, _("%s: too few arguments"), "mailboxes -label");
841 goto done;
842 }
843
845 label_set = true;
846 }
847 else if (mutt_str_equal(buf_string(token), "-nolabel"))
848 {
849 buf_reset(label);
850 label_set = true;
851 }
852 else if (mutt_str_equal(buf_string(token), "-notify"))
853 {
854 notify = TB_TRUE;
855 }
856 else if (mutt_str_equal(buf_string(token), "-nonotify"))
857 {
858 notify = TB_FALSE;
859 }
860 else if (mutt_str_equal(buf_string(token), "-poll"))
861 {
862 poll = TB_TRUE;
863 }
864 else if (mutt_str_equal(buf_string(token), "-nopoll"))
865 {
866 poll = TB_FALSE;
867 }
868 else if ((cmd->data & MUTT_NAMED) && !label_set)
869 {
870 if (!MoreArgs(line))
871 {
872 buf_printf(err, _("%s: too few arguments"), cmd->name);
873 goto done;
874 }
875
876 buf_copy(label, token);
877 label_set = true;
878 }
879 else
880 {
881 buf_copy(mailbox, token);
882 break;
883 }
884 } while (MoreArgs(line));
885
886 if (buf_is_empty(mailbox))
887 {
888 buf_printf(err, _("%s: too few arguments"), cmd->name);
889 goto done;
890 }
891
892 rc = mailbox_add(c_folder, buf_string(mailbox),
893 label_set ? buf_string(label) : NULL, poll, notify, err);
894 if (rc != MUTT_CMD_SUCCESS)
895 goto done;
896
897 buf_reset(label);
898 buf_reset(mailbox);
899 }
900
901 rc = MUTT_CMD_SUCCESS;
902
903done:
904 buf_pool_release(&label);
905 buf_pool_release(&mailbox);
906 buf_pool_release(&token);
907 return rc;
908}
909
916enum CommandResult parse_my_hdr(const struct Command *cmd, struct Buffer *line,
917 struct Buffer *err)
918{
919 if (!MoreArgs(line))
920 {
921 buf_printf(err, _("%s: too few arguments"), cmd->name);
922 return MUTT_CMD_WARNING;
923 }
924
925 struct Buffer *token = buf_pool_get();
927
929 char *p = strpbrk(buf_string(token), ": \t");
930 if (!p || (*p != ':'))
931 {
932 buf_strcpy(err, _("invalid header field"));
933 goto done;
934 }
935
936 struct EventHeader ev_h = { token->data };
937 struct ListNode *node = header_find(&UserHeader, buf_string(token));
938
939 if (node)
940 {
941 header_update(node, buf_string(token));
942 mutt_debug(LL_NOTIFY, "NT_HEADER_CHANGE: %s\n", buf_string(token));
944 }
945 else
946 {
948 mutt_debug(LL_NOTIFY, "NT_HEADER_ADD: %s\n", buf_string(token));
950 }
951
952 rc = MUTT_CMD_SUCCESS;
953
954done:
955 buf_pool_release(&token);
956 return rc;
957}
958
968enum CommandResult set_dump(enum GetElemListFlags flags, struct Buffer *err)
969{
970 struct Buffer *tempfile = buf_pool_get();
971 buf_mktemp(tempfile);
972
973 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
974 if (!fp_out)
975 {
976 // L10N: '%s' is the file name of the temporary file
977 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
978 buf_pool_release(&tempfile);
979 return MUTT_CMD_ERROR;
980 }
981
982 struct ConfigSet *cs = NeoMutt->sub->cs;
983 struct HashElemArray hea = get_elem_list(cs, flags);
984 dump_config(cs, &hea, CS_DUMP_NO_FLAGS, fp_out);
985 ARRAY_FREE(&hea);
986
987 mutt_file_fclose(&fp_out);
988
989 struct PagerData pdata = { 0 };
990 struct PagerView pview = { &pdata };
991
992 pdata.fname = buf_string(tempfile);
993
994 pview.banner = "set";
996 pview.mode = PAGER_MODE_OTHER;
997
998 mutt_do_pager(&pview, NULL);
999 buf_pool_release(&tempfile);
1000
1001 return MUTT_CMD_SUCCESS;
1002}
1003
1007static int envlist_sort(const void *a, const void *b, void *sdata)
1008{
1009 return strcmp(*(const char **) a, *(const char **) b);
1010}
1011
1019enum CommandResult parse_setenv(const struct Command *cmd, struct Buffer *line,
1020 struct Buffer *err)
1021{
1022 struct Buffer *token = buf_pool_get();
1023 struct Buffer *tempfile = NULL;
1025
1026 char **envp = NeoMutt->env;
1027
1028 bool query = false;
1029 bool prefix = false;
1030 bool unset = (cmd->data == MUTT_SET_UNSET);
1031
1032 if (!MoreArgs(line))
1033 {
1034 if (!StartupComplete)
1035 {
1036 buf_printf(err, _("%s: too few arguments"), cmd->name);
1037 goto done;
1038 }
1039
1040 tempfile = buf_pool_get();
1041 buf_mktemp(tempfile);
1042
1043 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
1044 if (!fp_out)
1045 {
1046 // L10N: '%s' is the file name of the temporary file
1047 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
1048 rc = MUTT_CMD_ERROR;
1049 goto done;
1050 }
1051
1052 int count = 0;
1053 for (char **env = NeoMutt->env; *env; env++)
1054 count++;
1055
1056 mutt_qsort_r(NeoMutt->env, count, sizeof(char *), envlist_sort, NULL);
1057
1058 for (char **env = NeoMutt->env; *env; env++)
1059 fprintf(fp_out, "%s\n", *env);
1060
1061 mutt_file_fclose(&fp_out);
1062
1063 struct PagerData pdata = { 0 };
1064 struct PagerView pview = { &pdata };
1065
1066 pdata.fname = buf_string(tempfile);
1067
1068 pview.banner = cmd->name;
1069 pview.flags = MUTT_PAGER_NO_FLAGS;
1070 pview.mode = PAGER_MODE_OTHER;
1071
1072 mutt_do_pager(&pview, NULL);
1073
1074 rc = MUTT_CMD_SUCCESS;
1075 goto done;
1076 }
1077
1078 if (*line->dptr == '?')
1079 {
1080 query = true;
1081 prefix = true;
1082
1083 if (unset)
1084 {
1085 buf_printf(err, _("Can't query option with the '%s' command"), cmd->name);
1086 goto done;
1087 }
1088
1089 line->dptr++;
1090 }
1091
1092 /* get variable name */
1094
1095 if (*line->dptr == '?')
1096 {
1097 if (unset)
1098 {
1099 buf_printf(err, _("Can't query option with the '%s' command"), cmd->name);
1100 goto done;
1101 }
1102
1103 if (prefix)
1104 {
1105 buf_printf(err, _("Can't use a prefix when querying a variable"));
1106 goto done;
1107 }
1108
1109 query = true;
1110 line->dptr++;
1111 }
1112
1113 if (query)
1114 {
1115 bool found = false;
1116 while (envp && *envp)
1117 {
1118 /* This will display all matches for "^QUERY" */
1119 if (mutt_str_startswith(*envp, buf_string(token)))
1120 {
1121 if (!found)
1122 {
1123 mutt_endwin();
1124 found = true;
1125 }
1126 puts(*envp);
1127 }
1128 envp++;
1129 }
1130
1131 if (found)
1132 {
1134 rc = MUTT_CMD_SUCCESS;
1135 goto done;
1136 }
1137
1138 buf_printf(err, _("%s is unset"), buf_string(token));
1139 goto done;
1140 }
1141
1142 if (unset)
1143 {
1144 if (envlist_unset(&NeoMutt->env, buf_string(token)))
1145 rc = MUTT_CMD_SUCCESS;
1146 else
1147 buf_printf(err, _("%s is unset"), buf_string(token));
1148
1149 goto done;
1150 }
1151
1152 /* set variable */
1153
1154 if (*line->dptr == '=')
1155 {
1156 line->dptr++;
1157 SKIPWS(line->dptr);
1158 }
1159
1160 if (!MoreArgs(line))
1161 {
1162 buf_printf(err, _("%s: too few arguments"), cmd->name);
1163 goto done;
1164 }
1165
1166 char *varname = mutt_str_dup(buf_string(token));
1167 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1168 envlist_set(&NeoMutt->env, varname, buf_string(token), true);
1169 FREE(&varname);
1170
1171 rc = MUTT_CMD_SUCCESS;
1172
1173done:
1174 buf_pool_release(&token);
1175 buf_pool_release(&tempfile);
1176 return rc;
1177}
1178
1185enum CommandResult parse_source(const struct Command *cmd, struct Buffer *line,
1186 struct Buffer *err)
1187{
1188 if (!MoreArgs(line))
1189 {
1190 buf_printf(err, _("%s: too few arguments"), cmd->name);
1191 return MUTT_CMD_WARNING;
1192 }
1193
1194 struct Buffer *token = buf_pool_get();
1195 struct Buffer *path = buf_pool_get();
1196 enum CommandResult rc = MUTT_CMD_ERROR;
1197
1198 do
1199 {
1200 if (parse_extract_token(token, line, TOKEN_BACKTICK_VARS) != 0)
1201 {
1202 buf_printf(err, _("source: error at %s"), line->dptr);
1203 goto done;
1204 }
1205 buf_copy(path, token);
1206 buf_expand_path(path);
1207
1208 if (source_rc(buf_string(path), err) < 0)
1209 {
1210 buf_printf(err, _("source: file %s could not be sourced"), buf_string(path));
1211 goto done;
1212 }
1213
1214 } while (MoreArgs(line));
1215
1216 rc = MUTT_CMD_SUCCESS;
1217
1218done:
1219 buf_pool_release(&path);
1220 buf_pool_release(&token);
1221 return rc;
1222}
1223
1230enum CommandResult parse_nospam(const struct Command *cmd, struct Buffer *line,
1231 struct Buffer *err)
1232{
1233 if (!MoreArgs(line))
1234 {
1235 buf_printf(err, _("%s: too few arguments"), cmd->name);
1236 return MUTT_CMD_WARNING;
1237 }
1238
1239 struct Buffer *token = buf_pool_get();
1241
1242 // Extract the first token, a regex or "*"
1243 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1244
1245 if (MoreArgs(line))
1246 {
1247 buf_printf(err, _("%s: too many arguments"), cmd->name);
1248 goto done;
1249 }
1250
1251 // "*" is special - clear both spam and nospam lists
1252 if (mutt_str_equal(buf_string(token), "*"))
1253 {
1256 rc = MUTT_CMD_SUCCESS;
1257 goto done;
1258 }
1259
1260 // If it's on the spam list, just remove it
1261 if (mutt_replacelist_remove(&SpamList, buf_string(token)) != 0)
1262 {
1263 rc = MUTT_CMD_SUCCESS;
1264 goto done;
1265 }
1266
1267 // Otherwise, add it to the nospam list
1268 if (mutt_regexlist_add(&NoSpamList, buf_string(token), REG_ICASE, err) != 0)
1269 {
1270 rc = MUTT_CMD_ERROR;
1271 goto done;
1272 }
1273
1274 rc = MUTT_CMD_SUCCESS;
1275
1276done:
1277 buf_pool_release(&token);
1278 return rc;
1279}
1280
1287enum CommandResult parse_spam(const struct Command *cmd, struct Buffer *line,
1288 struct Buffer *err)
1289{
1290 if (!MoreArgs(line))
1291 {
1292 buf_printf(err, _("%s: too few arguments"), cmd->name);
1293 return MUTT_CMD_WARNING;
1294 }
1295
1296 struct Buffer *token = buf_pool_get();
1297 struct Buffer *templ = NULL;
1298 enum CommandResult rc = MUTT_CMD_ERROR;
1299
1300 // Extract the first token, a regex
1301 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1302
1303 // If there's a second parameter, it's a template for the spam tag
1304 if (MoreArgs(line))
1305 {
1306 templ = buf_pool_get();
1307 parse_extract_token(templ, line, TOKEN_NO_FLAGS);
1308
1309 // Add to the spam list
1310 if (mutt_replacelist_add(&SpamList, buf_string(token), buf_string(templ), err) != 0)
1311 goto done;
1312 }
1313 else
1314 {
1315 // If not, try to remove from the nospam list
1317 }
1318
1319 rc = MUTT_CMD_SUCCESS;
1320
1321done:
1322 buf_pool_release(&templ);
1323 buf_pool_release(&token);
1324 return rc;
1325}
1326
1337enum CommandResult parse_stailq(const struct Command *cmd, struct Buffer *line,
1338 struct Buffer *err)
1339{
1340 if (!MoreArgs(line))
1341 {
1342 buf_printf(err, _("%s: too few arguments"), cmd->name);
1343 return MUTT_CMD_WARNING;
1344 }
1345
1346 struct Buffer *token = buf_pool_get();
1347
1348 do
1349 {
1350 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1351 add_to_stailq((struct ListHead *) cmd->data, buf_string(token));
1352 } while (MoreArgs(line));
1353
1354 buf_pool_release(&token);
1355 return MUTT_CMD_SUCCESS;
1356}
1357
1365 struct Buffer *line, struct Buffer *err)
1366{
1367 if (!MoreArgs(line))
1368 {
1369 buf_printf(err, _("%s: too few arguments"), cmd->name);
1370 return MUTT_CMD_WARNING;
1371 }
1372
1373 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
1374 struct Buffer *token = buf_pool_get();
1375 enum CommandResult rc = MUTT_CMD_ERROR;
1376
1377 do
1378 {
1379 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1380
1381 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
1382 goto done;
1383
1386
1387 if (mutt_regexlist_add(&MailLists, buf_string(token), REG_ICASE, err) != 0)
1388 goto done;
1389
1390 if (mutt_regexlist_add(&SubscribedLists, buf_string(token), REG_ICASE, err) != 0)
1391 goto done;
1392
1393 if (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0)
1394 goto done;
1395 } while (MoreArgs(line));
1396
1397 rc = MUTT_CMD_SUCCESS;
1398
1399done:
1400 buf_pool_release(&token);
1401 grouplist_destroy(&gl);
1402 return rc;
1403}
1404
1415 struct Buffer *line, struct Buffer *err)
1416{
1417 if (!MoreArgs(line))
1418 {
1419 buf_printf(err, _("%s: too few arguments"), cmd->name);
1420 return MUTT_CMD_WARNING;
1421 }
1422
1423 struct Buffer *token = buf_pool_get();
1425
1426 buf_reset(err);
1427
1428 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1429
1430 if (MoreArgs(line))
1431 {
1432 buf_printf(err, _("%s: too many arguments"), cmd->name);
1433 goto done;
1434 }
1435
1436 // Expand and subscribe
1437 buf_expand_path(token);
1438 if (imap_subscribe(buf_string(token), true) != 0)
1439 {
1440 buf_printf(err, _("Could not subscribe to %s"), buf_string(token));
1441 rc = MUTT_CMD_ERROR;
1442 goto done;
1443 }
1444
1445 mutt_message(_("Subscribed to %s"), buf_string(token));
1446 rc = MUTT_CMD_SUCCESS;
1447
1448done:
1449 buf_pool_release(&token);
1450 return rc;
1451}
1452
1464 struct Buffer *line, struct Buffer *err)
1465{
1466 if (!MoreArgs(line))
1467 {
1468 buf_printf(err, _("%s: too few arguments"), cmd->name);
1469 return MUTT_CMD_WARNING;
1470 }
1471
1472 struct Buffer *tag = buf_pool_get();
1473 struct Buffer *fmt = buf_pool_get();
1474
1475 while (MoreArgs(line))
1476 {
1478 if (buf_is_empty(tag))
1479 continue;
1480
1482
1483 /* avoid duplicates */
1484 const char *tmp = mutt_hash_find(TagFormats, buf_string(fmt));
1485 if (tmp)
1486 {
1487 mutt_warning(_("tag format '%s' already registered as '%s'"), buf_string(fmt), tmp);
1488 continue;
1489 }
1490
1492 }
1493
1494 buf_pool_release(&tag);
1495 buf_pool_release(&fmt);
1496 return MUTT_CMD_SUCCESS;
1497}
1498
1510 struct Buffer *line, struct Buffer *err)
1511{
1512 if (!MoreArgs(line))
1513 {
1514 buf_printf(err, _("%s: too few arguments"), cmd->name);
1515 return MUTT_CMD_WARNING;
1516 }
1517
1518 struct Buffer *tag = buf_pool_get();
1519 struct Buffer *trnbuf = buf_pool_get();
1520
1521 while (MoreArgs(line))
1522 {
1524 if (buf_is_empty(tag))
1525 continue;
1526
1527 parse_extract_token(trnbuf, line, TOKEN_NO_FLAGS);
1528 const char *trn = buf_string(trnbuf);
1529
1530 /* avoid duplicates */
1531 const char *tmp = mutt_hash_find(TagTransforms, buf_string(tag));
1532 if (tmp)
1533 {
1534 mutt_warning(_("tag transform '%s' already registered as '%s'"),
1535 buf_string(tag), tmp);
1536 continue;
1537 }
1538
1540 }
1541
1542 buf_pool_release(&tag);
1543 buf_pool_release(&trnbuf);
1544 return MUTT_CMD_SUCCESS;
1545}
1546
1553enum CommandResult parse_unignore(const struct Command *cmd,
1554 struct Buffer *line, struct Buffer *err)
1555{
1556 if (!MoreArgs(line))
1557 {
1558 buf_printf(err, _("%s: too few arguments"), cmd->name);
1559 return MUTT_CMD_WARNING;
1560 }
1561
1562 struct Buffer *token = buf_pool_get();
1563
1564 do
1565 {
1566 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1567
1568 /* don't add "*" to the unignore list */
1569 if (!mutt_str_equal(buf_string(token), "*"))
1571
1573 } while (MoreArgs(line));
1574
1575 buf_pool_release(&token);
1576 return MUTT_CMD_SUCCESS;
1577}
1578
1585enum CommandResult parse_unlists(const struct Command *cmd, struct Buffer *line,
1586 struct Buffer *err)
1587{
1588 if (!MoreArgs(line))
1589 {
1590 buf_printf(err, _("%s: too few arguments"), cmd->name);
1591 return MUTT_CMD_WARNING;
1592 }
1593
1594 struct Buffer *token = buf_pool_get();
1595 enum CommandResult rc = MUTT_CMD_ERROR;
1596
1598 do
1599 {
1600 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1603
1604 if (!mutt_str_equal(buf_string(token), "*") &&
1605 (mutt_regexlist_add(&UnMailLists, buf_string(token), REG_ICASE, err) != 0))
1606 {
1607 goto done;
1608 }
1609 } while (MoreArgs(line));
1610
1611 rc = MUTT_CMD_SUCCESS;
1612
1613done:
1614 buf_pool_release(&token);
1615 return rc;
1616}
1617
1622static void do_unmailboxes(struct Mailbox *m)
1623{
1624#ifdef USE_INOTIFY
1625 if (m->poll_new_mail)
1627#endif
1628 m->visible = false;
1629 m->gen = -1;
1630 if (m->opened)
1631 {
1632 struct EventMailbox ev_m = { NULL };
1633 mutt_debug(LL_NOTIFY, "NT_MAILBOX_CHANGE: NULL\n");
1635 }
1636 else
1637 {
1639 mailbox_free(&m);
1640 }
1641}
1642
1646static void do_unmailboxes_star(void)
1647{
1648 struct MailboxArray ma = neomutt_mailboxes_get(NeoMutt, MUTT_MAILBOX_ANY);
1649
1650 struct Mailbox **mp = NULL;
1651 ARRAY_FOREACH(mp, &ma)
1652 {
1653 do_unmailboxes(*mp);
1654 }
1655 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
1656}
1657
1665 struct Buffer *line, struct Buffer *err)
1666{
1667 if (!MoreArgs(line))
1668 {
1669 buf_printf(err, _("%s: too few arguments"), cmd->name);
1670 return MUTT_CMD_WARNING;
1671 }
1672
1673 struct Buffer *token = buf_pool_get();
1674
1675 while (MoreArgs(line))
1676 {
1677 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1678
1679 if (mutt_str_equal(buf_string(token), "*"))
1680 {
1682 goto done;
1683 }
1684
1685 buf_expand_path(token);
1686
1687 struct Account **ap = NULL;
1689 {
1690 struct Mailbox *m = mx_mbox_find(*ap, buf_string(token));
1691 if (m)
1692 {
1693 do_unmailboxes(m);
1694 break;
1695 }
1696 }
1697 }
1698
1699done:
1700 buf_pool_release(&token);
1701 return MUTT_CMD_SUCCESS;
1702}
1703
1710enum CommandResult parse_unmy_hdr(const struct Command *cmd,
1711 struct Buffer *line, struct Buffer *err)
1712{
1713 if (!MoreArgs(line))
1714 {
1715 buf_printf(err, _("%s: too few arguments"), cmd->name);
1716 return MUTT_CMD_WARNING;
1717 }
1718
1719 struct Buffer *token = buf_pool_get();
1720
1721 struct ListNode *np = NULL, *tmp = NULL;
1722 size_t l;
1723
1724 do
1725 {
1726 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1727 if (mutt_str_equal("*", buf_string(token)))
1728 {
1729 /* Clear all headers, send a notification for each header */
1730 STAILQ_FOREACH(np, &UserHeader, entries)
1731 {
1732 mutt_debug(LL_NOTIFY, "NT_HEADER_DELETE: %s\n", np->data);
1733 struct EventHeader ev_h = { np->data };
1735 }
1737 continue;
1738 }
1739
1740 l = mutt_str_len(buf_string(token));
1741 if (buf_at(token, l - 1) == ':')
1742 l--;
1743
1744 STAILQ_FOREACH_SAFE(np, &UserHeader, entries, tmp)
1745 {
1746 if (mutt_istrn_equal(buf_string(token), np->data, l) && (np->data[l] == ':'))
1747 {
1748 mutt_debug(LL_NOTIFY, "NT_HEADER_DELETE: %s\n", np->data);
1749 struct EventHeader ev_h = { np->data };
1751
1752 header_free(&UserHeader, np);
1753 }
1754 }
1755 } while (MoreArgs(line));
1756 buf_pool_release(&token);
1757 return MUTT_CMD_SUCCESS;
1758}
1759
1770enum CommandResult parse_unstailq(const struct Command *cmd,
1771 struct Buffer *line, struct Buffer *err)
1772{
1773 if (!MoreArgs(line))
1774 {
1775 buf_printf(err, _("%s: too few arguments"), cmd->name);
1776 return MUTT_CMD_WARNING;
1777 }
1778
1779 struct Buffer *token = buf_pool_get();
1780
1781 do
1782 {
1783 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1784 /* Check for deletion of entire list */
1785 if (mutt_str_equal(buf_string(token), "*"))
1786 {
1787 mutt_list_free((struct ListHead *) cmd->data);
1788 break;
1789 }
1790 remove_from_stailq((struct ListHead *) cmd->data, buf_string(token));
1791 } while (MoreArgs(line));
1792
1793 buf_pool_release(&token);
1794 return MUTT_CMD_SUCCESS;
1795}
1796
1804 struct Buffer *line, struct Buffer *err)
1805{
1806 if (!MoreArgs(line))
1807 {
1808 buf_printf(err, _("%s: too few arguments"), cmd->name);
1809 return MUTT_CMD_WARNING;
1810 }
1811
1812 struct Buffer *token = buf_pool_get();
1813 enum CommandResult rc = MUTT_CMD_ERROR;
1814
1816 do
1817 {
1818 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1820
1821 if (!mutt_str_equal(buf_string(token), "*") &&
1822 (mutt_regexlist_add(&UnSubscribedLists, buf_string(token), REG_ICASE, err) != 0))
1823 {
1824 goto done;
1825 }
1826 } while (MoreArgs(line));
1827
1828 rc = MUTT_CMD_SUCCESS;
1829
1830done:
1831 buf_pool_release(&token);
1832 return rc;
1833}
1834
1845 struct Buffer *line, struct Buffer *err)
1846{
1847 if (!MoreArgs(line))
1848 {
1849 buf_printf(err, _("%s: too few arguments"), cmd->name);
1850 return MUTT_CMD_WARNING;
1851 }
1852
1853 struct Buffer *token = buf_pool_get();
1855
1856 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1857
1858 if (MoreArgs(line))
1859 {
1860 buf_printf(err, _("%s: too many arguments"), cmd->name);
1861 goto done;
1862 }
1863
1864 // Expand and unsubscribe
1865 buf_expand_path(token);
1866 if (imap_subscribe(buf_string(token), false) != 0)
1867 {
1868 buf_printf(err, _("Could not unsubscribe from %s"), buf_string(token));
1869 rc = MUTT_CMD_ERROR;
1870 goto done;
1871 }
1872
1873 mutt_message(_("Unsubscribed from %s"), buf_string(token));
1874 rc = MUTT_CMD_SUCCESS;
1875
1876done:
1877 buf_pool_release(&token);
1878 return rc;
1879}
1880
1887enum CommandResult parse_version(const struct Command *cmd, struct Buffer *line,
1888 struct Buffer *err)
1889{
1890 // silently ignore 'version' if it's in a config file
1891 if (!StartupComplete)
1892 return MUTT_CMD_SUCCESS;
1893
1894 if (MoreArgs(line))
1895 {
1896 buf_printf(err, _("%s: too many arguments"), cmd->name);
1897 return MUTT_CMD_WARNING;
1898 }
1899
1900 struct Buffer *tempfile = buf_pool_get();
1901 enum CommandResult rc = MUTT_CMD_ERROR;
1902
1903 buf_mktemp(tempfile);
1904
1905 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
1906 if (!fp_out)
1907 {
1908 // L10N: '%s' is the file name of the temporary file
1909 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
1910 goto done;
1911 }
1912
1913 print_version(fp_out, false);
1914 mutt_file_fclose(&fp_out);
1915
1916 struct PagerData pdata = { 0 };
1917 struct PagerView pview = { &pdata };
1918
1919 pdata.fname = buf_string(tempfile);
1920
1921 pview.banner = cmd->name;
1922 pview.flags = MUTT_PAGER_NO_FLAGS;
1923 pview.mode = PAGER_MODE_OTHER;
1924
1925 mutt_do_pager(&pview, NULL);
1926 rc = MUTT_CMD_SUCCESS;
1927
1928done:
1929 buf_pool_release(&tempfile);
1930 return rc;
1931}
1932
1937{
1939}
1940
1944static const struct Command MuttCommands[] = {
1945 // clang-format off
1946 { "alias", parse_alias, 0,
1947 N_("Define an alias (name to email address)"),
1948 N_("alias [ -group <name> ... ] <key> <address> [, <address> ... ]"),
1949 "configuration.html#alias" },
1950 { "alternates", parse_alternates, 0,
1951 N_("Define a list of alternate email addresses for the user"),
1952 N_("alternates [ -group <name> ... ] <regex> [ <regex> ... ]"),
1953 "configuration.html#alternates" },
1954 { "alternative_order", parse_stailq, IP &AlternativeOrderList,
1955 N_("Set preference order for multipart alternatives"),
1956 N_("alternative_order <mime-type>[/<mime-subtype> ] [ <mime-type>[/<mime-subtype> ] ... ]"),
1957 "mimesupport.html#alternative-order" },
1958 { "attachments", parse_attachments, 0,
1959 N_("Set attachment counting rules"),
1960 N_("attachments { + | - }<disposition> <mime-type> [ <mime-type> ... ] | ?"),
1961 "mimesupport.html#attachments" },
1962 { "auto_view", parse_stailq, IP &AutoViewList,
1963 N_("Automatically display specified MIME types inline"),
1964 N_("auto_view <mime-type>[/<mime-subtype> ] [ <mime-type>[/<mime-subtype> ] ... ]"),
1965 "mimesupport.html#auto-view" },
1966 { "cd", parse_cd, 0,
1967 N_("Change NeoMutt's current working directory"),
1968 N_("cd [ <directory> ]"),
1969 "configuration.html#cd" },
1970 { "color", parse_color, 0,
1971 N_("Define colors for the user interface"),
1972 N_("color <object> [ <attribute> ... ] <foreground> <background> [ <regex> [ <num> ]]"),
1973 "configuration.html#color" },
1974 { "echo", parse_echo, 0,
1975 N_("Print a message to the status line"),
1976 N_("echo <message>"),
1977 "advancedusage.html#echo" },
1978 { "finish", parse_finish, 0,
1979 N_("Stop reading current config file"),
1980 N_("finish "),
1981 "optionalfeatures.html#ifdef" },
1982 { "group", parse_group, MUTT_GROUP,
1983 N_("Add addresses to an address group"),
1984 N_("group [ -group <name> ... ] { -rx <regex> ... | -addr <address> ... }"),
1985 "configuration.html#addrgroup" },
1986 { "hdr_order", parse_stailq, IP &HeaderOrderList,
1987 N_("Define custom order of headers displayed"),
1988 N_("hdr_order <header> [ <header> ... ]"),
1989 "configuration.html#hdr-order" },
1990 { "ifdef", parse_ifdef, 0,
1991 N_("Conditionally include config commands if symbol defined"),
1992 N_("ifdef <symbol> '<config-command> [ <args> ... ]'"),
1993 "optionalfeatures.html#ifdef" },
1994 { "ifndef", parse_ifdef, 1,
1995 N_("Conditionally include if symbol is not defined"),
1996 N_("ifndef <symbol> '<config-command> [ <args> ... ]'"),
1997 "optionalfeatures.html#ifdef" },
1998 { "ignore", parse_ignore, 0,
1999 N_("Hide specified headers when displaying messages"),
2000 N_("ignore { * | <string> ... }"),
2001 "configuration.html#ignore" },
2002 { "lists", parse_lists, 0,
2003 N_("Add address to the list of mailing lists"),
2004 N_("lists [ -group <name> ... ] <regex> [ <regex> ... ]"),
2005 "configuration.html#lists" },
2006 { "mailboxes", parse_mailboxes, 0,
2007 N_("Define a list of mailboxes to watch"),
2008 N_("mailboxes [[ -label <label> ] | -nolabel ] [[ -notify | -nonotify ] [ -poll | -nopoll ] <mailbox> ] [ ... ]"),
2009 "configuration.html#mailboxes" },
2010 { "mailto_allow", parse_stailq, IP &MailToAllow,
2011 N_("Permit specific header-fields in mailto URL processing"),
2012 N_("mailto_allow { * | <header-field> ... }"),
2013 "configuration.html#mailto-allow" },
2014 { "mime_lookup", parse_stailq, IP &MimeLookupList,
2015 N_("Map specified MIME types/subtypes to display handlers"),
2016 N_("mime_lookup <mime-type>[/<mime-subtype> ] [ <mime-type>[/<mime-subtype> ] ... ]"),
2017 "mimesupport.html#mime-lookup" },
2018 { "mono", parse_mono, 0,
2019 N_("**Deprecated**: Use `color`"),
2020 N_("mono <object> <attribute> [ <pattern> | <regex> ]"),
2021 "configuration.html#color-mono" },
2022 { "my_hdr", parse_my_hdr, 0,
2023 N_("Add a custom header to outgoing messages"),
2024 N_("my_hdr <string>"),
2025 "configuration.html#my-hdr" },
2026 { "named-mailboxes", parse_mailboxes, MUTT_NAMED,
2027 N_("Define a list of labelled mailboxes to watch"),
2028 N_("named-mailboxes <description> <mailbox> [ <description> <mailbox> ... ]"),
2029 "configuration.html#mailboxes" },
2030 { "nospam", parse_nospam, 0,
2031 N_("Remove a spam detection rule"),
2032 N_("nospam { * | <regex> }"),
2033 "configuration.html#spam" },
2034 { "reset", parse_set, MUTT_SET_RESET,
2035 N_("Reset a config option to its initial value"),
2036 N_("reset <variable> [ <variable> ... ]"),
2037 "configuration.html#set" },
2038 { "score", parse_score, 0,
2039 N_("Set a score value on emails matching a pattern"),
2040 N_("score <pattern> <value>"),
2041 "configuration.html#score-command" },
2042 { "set", parse_set, MUTT_SET_SET,
2043 N_("Set a config variable"),
2044 N_("set { [ no | inv | & ] <variable> [?] | <variable> [=|+=|-=] value } [ ... ]"),
2045 "configuration.html#set" },
2046 { "setenv", parse_setenv, MUTT_SET_SET,
2047 N_("Set an environment variable"),
2048 N_("setenv { <variable>? | <variable> <value> }"),
2049 "advancedusage.html#setenv" },
2050 { "source", parse_source, 0,
2051 N_("Read and execute commands from a config file"),
2052 N_("source <filename>"),
2053 "configuration.html#source" },
2054 { "spam", parse_spam, 0,
2055 N_("Define rules to parse spam detection headers"),
2056 N_("spam <regex> <format>"),
2057 "configuration.html#spam" },
2058 { "subjectrx", parse_subjectrx_list, 0,
2059 N_("Apply regex-based rewriting to message subjects"),
2060 N_("subjectrx <regex> <replacement>"),
2061 "advancedusage.html#display-munging" },
2062 { "subscribe", parse_subscribe, 0,
2063 N_("Add address to the list of subscribed mailing lists"),
2064 N_("subscribe [ -group <name> ... ] <regex> [ <regex> ... ]"),
2065 "configuration.html#lists" },
2066 { "tag-formats", parse_tag_formats, 0,
2067 N_("Define expandos tags"),
2068 N_("tag-formats <tag> <format-string> { tag format-string ... }"),
2069 "optionalfeatures.html#custom-tags" },
2070 { "tag-transforms", parse_tag_transforms, 0,
2071 N_("Rules to transform tags into icons"),
2072 N_("tag-transforms <tag> <transformed-string> { tag transformed-string ... }"),
2073 "optionalfeatures.html#custom-tags" },
2074 { "toggle", parse_set, MUTT_SET_INV,
2075 N_("Toggle the value of a boolean/quad config option"),
2076 N_("toggle <variable> [ <variable> ... ]"),
2077 "configuration.html#set" },
2078 { "unalias", parse_unalias, 0,
2079 N_("Remove an alias definition"),
2080 N_("unalias [ -group <name> ... ] { * | <key> ... }"),
2081 "configuration.html#alias" },
2082 { "unalternates", parse_unalternates, 0,
2083 N_("Remove addresses from `alternates` list"),
2084 N_("unalternates [ -group <name> ... ] { * | <regex> ... }"),
2085 "configuration.html#alternates" },
2086 { "unalternative_order", parse_unstailq, IP &AlternativeOrderList,
2087 N_("Remove MIME types from preference order"),
2088 N_("unalternative_order { * | [ <mime-type>[/<mime-subtype> ] ... ] }"),
2089 "mimesupport.html#alternative-order" },
2090 { "unattachments", parse_unattachments, 0,
2091 N_("Remove attachment counting rules"),
2092 N_("unattachments { * | { + | - }<disposition> <mime-type> [ <mime-type> ... ] }"),
2093 "mimesupport.html#attachments" },
2094 { "unauto_view", parse_unstailq, IP &AutoViewList,
2095 N_("Remove MIME types from `auto_view` list"),
2096 N_("unauto_view { * | [ <mime-type>[/<mime-subtype> ] ... ] }"),
2097 "mimesupport.html#auto-view" },
2098 { "uncolor", parse_uncolor, 0,
2099 N_("Remove a `color` definition"),
2100 N_("uncolor <object> { * | <pattern> ... }"),
2101 "configuration.html#color" },
2102 { "ungroup", parse_group, MUTT_UNGROUP,
2103 N_("Remove addresses from an address `group`"),
2104 N_("ungroup [ -group <name> ... ] { * | -rx <regex> ... | -addr <address> ... }"),
2105 "configuration.html#addrgroup" },
2106 { "unhdr_order", parse_unstailq, IP &HeaderOrderList,
2107 N_("Remove header from `hdr_order` list"),
2108 N_("unhdr_order { * | <header> ... }"),
2109 "configuration.html#hdr-order" },
2110 { "unignore", parse_unignore, 0,
2111 N_("Remove a header from the `hdr_order` list"),
2112 N_("unignore { * | <string> ... }"),
2113 "configuration.html#ignore" },
2114 { "unlists", parse_unlists, 0,
2115 N_("Remove address from the list of mailing lists"),
2116 N_("unlists [ -group <name> ... ] { * | <regex> ... }"),
2117 "configuration.html#lists" },
2118 { "unmailboxes", parse_unmailboxes, 0,
2119 N_("Remove mailboxes from the watch list"),
2120 N_("unmailboxes { * | <mailbox> ... }"),
2121 "configuration.html#mailboxes" },
2122 { "unmailto_allow", parse_unstailq, IP &MailToAllow,
2123 N_("Disallow header-fields in mailto processing"),
2124 N_("unmailto_allow { * | <header-field> ... }"),
2125 "configuration.html#mailto-allow" },
2126 { "unmime_lookup", parse_unstailq, IP &MimeLookupList,
2127 N_("Remove custom MIME-type handlers"),
2128 N_("unmime_lookup { * | [ <mime-type>[/<mime-subtype> ] ... ] }"),
2129 "mimesupport.html#mime-lookup" },
2130 { "unmono", parse_unmono, 0,
2131 N_("**Deprecated**: Use `uncolor`"),
2132 N_("unmono <object> { * | <pattern> ... }"),
2133 "configuration.html#color-mono" },
2134 { "unmy_hdr", parse_unmy_hdr, 0,
2135 N_("Remove a header previously added with `my_hdr`"),
2136 N_("unmy_hdr { * | <field> ... }"),
2137 "configuration.html#my-hdr" },
2138 { "unscore", parse_unscore, 0,
2139 N_("Remove scoring rules for matching patterns"),
2140 N_("unscore { * | <pattern> ... }"),
2141 "configuration.html#score-command" },
2142 { "unset", parse_set, MUTT_SET_UNSET,
2143 N_("Reset a config option to false/empty"),
2144 N_("unset <variable> [ <variable> ... ]"),
2145 "configuration.html#set" },
2146 { "unsetenv", parse_setenv, MUTT_SET_UNSET,
2147 N_("Unset an environment variable"),
2148 N_("unsetenv <variable>"),
2149 "advancedusage.html#setenv" },
2150 { "unsubjectrx", parse_unsubjectrx_list, 0,
2151 N_("Remove subject-rewriting rules"),
2152 N_("unsubjectrx { * | <regex> }"),
2153 "advancedusage.html#display-munging" },
2154 { "unsubscribe", parse_unsubscribe, 0,
2155 N_("Remove address from the list of subscribed mailing lists"),
2156 N_("unsubscribe [ -group <name> ... ] { * | <regex> ... }"),
2157 "configuration.html#lists" },
2158 { "version", parse_version, 0,
2159 N_("Show NeoMutt version and build information"),
2160 N_("version "),
2161 "configuration.html#version" },
2162
2163 { NULL, NULL, 0, NULL, NULL, NULL, CF_NO_FLAGS },
2164 // clang-format on
2165};
2166
2171{
2173}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition address.c:1460
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition address.c:644
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition address.c:1293
Email Address Handling.
Email Aliases.
Alternate address handling.
#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
GUI display the mailboxes in a side panel.
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
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
Definition buffer.c:668
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
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:571
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
Color and attribute parsing.
const struct Mapping ColorFields[]
Mapping of colour names to their IDs.
Definition commands.c:54
#define CF_NO_FLAGS
No flags are set.
Definition command.h:46
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
@ MUTT_CMD_FINISH
Finish: Stop processing this file.
Definition command.h:39
static const struct Command MuttCommands[]
General NeoMutt Commands.
Definition commands.c:1944
static enum CommandResult mailbox_add(const char *folder, const char *mailbox, const char *label, enum TriBool poll, enum TriBool notify, struct Buffer *err)
Add a new Mailbox.
Definition commands.c:692
static bool is_color_object(const char *name)
Is the argument a neomutt colour?
Definition commands.c:128
GroupState
Type of email address group.
Definition commands.c:95
@ GS_RX
Entry is a regular expression.
Definition commands.c:97
@ GS_NONE
Group is missing an argument.
Definition commands.c:96
@ GS_ADDR
Entry is an address.
Definition commands.c:98
#define MAX_ERRS
Definition commands.c:79
enum CommandResult parse_rc_line_cwd(const char *line, char *cwd, struct Buffer *err)
Parse and run a muttrc line in a relative directory.
Definition commands.c:179
void source_stack_cleanup(void)
Free memory from the stack used for the source command.
Definition commands.c:1936
int parse_grouplist(struct GroupList *gl, struct Buffer *token, struct Buffer *line, struct Buffer *err, struct HashTable *groups)
Parse a group context.
Definition commands.c:145
bool commands_init(void)
Initialize commands array and register default commands.
Definition commands.c:2170
static void do_unmailboxes_star(void)
Remove all Mailboxes from the Sidebar/notifications.
Definition commands.c:1646
static struct ListHead MuttrcStack
LIFO designed to contain the list of config files that have been sourced and avoid cyclic sourcing.
Definition commands.c:77
enum CommandResult set_dump(enum GetElemListFlags flags, struct Buffer *err)
Dump list of config variables into a file/pager.
Definition commands.c:968
TriBool
Tri-state boolean.
Definition commands.c:85
@ TB_FALSE
Value is false.
Definition commands.c:87
@ TB_TRUE
Value is true.
Definition commands.c:88
@ TB_UNSET
Value hasn't been set.
Definition commands.c:86
bool mailbox_add_simple(const char *mailbox, struct Buffer *err)
Add a new Mailbox.
Definition commands.c:796
static void do_unmailboxes(struct Mailbox *m)
Remove a Mailbox from the Sidebar/notifications.
Definition commands.c:1622
int source_rc(const char *rcfile_path, struct Buffer *err)
Read an initialization file.
Definition commands.c:223
char * mutt_get_sourced_cwd(void)
Get the current file path that is being parsed.
Definition commands.c:202
static bool is_function(const char *name)
Is the argument a neomutt function?
Definition commands.c:107
Functions to parse commands in a config file.
#define MUTT_NAMED
Definition commands.h:36
bool dump_config(struct ConfigSet *cs, struct HashElemArray *hea, ConfigDumpFlags flags, FILE *fp)
Write all the config to a file.
Definition dump.c:196
#define CS_DUMP_NO_FLAGS
No flags are set.
Definition dump.h:36
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
Convenience wrapper for the config headers.
bool StartupComplete
When the config has been read.
Definition address.c:13
#define IP
Definition set.h:52
const char * cc_charset(void)
Get the cached value of $charset.
void account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition account.c:94
struct Account * account_new(const char *name, struct ConfigSubset *sub)
Create a new Account.
Definition account.c:44
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
const struct Command * commands_get(struct CommandArray *ca, const char *name)
Get a Command by its name.
Definition command.c:82
Convenience wrapper for the core headers.
int mailbox_gen(void)
Get the next generation number.
Definition mailbox.c:58
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition mailbox.c:68
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition mailbox.c:89
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition mailbox.h:176
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition mailbox.h:42
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:44
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition curs_lib.c:174
void mutt_endwin(void)
Shutdown curses.
Definition curs_lib.c:152
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition do_pager.c:122
void header_free(struct ListHead *hdrlist, struct ListNode *target)
Free and remove a header from a header list.
Definition email.c:202
struct ListNode * header_add(struct ListHead *hdrlist, const char *header)
Add a header to a list.
Definition email.c:160
struct ListNode * header_update(struct ListNode *hdr, const char *header)
Update an existing header.
Definition email.c:174
struct ListNode * header_find(const struct ListHead *hdrlist, const char *header)
Find a header, matching on its field, in a list of headers.
Definition email.c:137
struct ReplaceList SpamList
List of regexes to match subscribed mailing lists.
Definition globals.c:46
struct RegexList SubscribedLists
List of header patterns to unignore (see)
Definition globals.c:48
struct HashTable * AutoSubscribeCache
< Hash Table: "mailto:" -> AutoSubscribeCache
Definition globals.c:36
struct RegexList UnSubscribedLists
Definition globals.c:54
struct RegexList UnMailLists
List of regexes to exclude false matches in SubscribedLists.
Definition globals.c:52
struct RegexList MailLists
List of permitted fields in a mailto: url.
Definition globals.c:40
struct ListHead MailToAllow
List of regexes to identify non-spam emails.
Definition globals.c:42
struct ListHead Ignore
List of regexes to match mailing lists.
Definition globals.c:38
struct RegexList NoSpamList
List of regexes and patterns to match spam emails.
Definition globals.c:44
struct ListHead UnIgnore
List of regexes to exclude false matches in MailLists.
Definition globals.c:50
Structs that make up an email.
@ NT_HEADER_CHANGE
An existing header has been changed.
Definition email.h:210
@ NT_HEADER_ADD
Header has been added.
Definition email.h:208
@ NT_HEADER_DELETE
Header has been removed.
Definition email.h:209
bool envlist_set(char ***envp, const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition envlist.c:88
bool envlist_unset(char ***envp, const char *name)
Unset an environment variable.
Definition envlist.c:136
int parse_extract_token(struct Buffer *dest, struct Buffer *line, TokenFlags flags)
Extract one token from a string.
Definition extract.c:48
#define TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition extract.h:52
#define TOKEN_SPACE
Don't treat whitespace as a term.
Definition extract.h:47
#define TOKEN_QUOTE
Don't interpret quotes.
Definition extract.h:48
#define TOKEN_EQUAL
Treat '=' as a special.
Definition extract.h:45
#define MoreArgs(buf)
Definition extract.h:30
#define TOKEN_QUESTION
Treat '?' as a special.
Definition extract.h:54
#define TOKEN_NO_FLAGS
No flags are set.
Definition extract.h:44
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
Definition file.c:685
#define MUTT_RL_CONT
-continuation
Definition file.h:41
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
struct ListHead MimeLookupList
List of mime types that that shouldn't use the mailcap entry.
Definition globals.c:47
struct ListHead AlternativeOrderList
List of preferred mime types to display.
Definition globals.c:44
struct ListHead AutoViewList
List of mime types to auto view.
Definition globals.c:45
bool OptForceRefresh
(pseudo) refresh even during macros
Definition globals.c:58
struct ListHead UserHeader
List of custom headers to add to outgoing emails.
Definition globals.c:49
struct ListHead HeaderOrderList
List of header fields in the order they should be displayed.
Definition globals.c:46
Global variables.
int grouplist_add_regex(struct GroupList *gl, const char *str, uint16_t flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition group.c:245
int groups_remove_addrlist(struct HashTable *groups, struct GroupList *gl, struct AddressList *al)
Remove an AddressList from a GroupList.
Definition group.c:337
void groups_remove_grouplist(struct HashTable *groups, struct GroupList *gl)
Clear a GroupList.
Definition group.c:312
int groups_remove_regex(struct HashTable *groups, struct GroupList *gl, const char *str)
Remove matching addresses from a GroupList.
Definition group.c:368
struct Group * groups_get_group(struct HashTable *groups, const char *name)
Get a Group by its name.
Definition group.c:291
void grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition group.c:224
void grouplist_add_group(struct GroupList *gl, struct Group *g)
Add a Group to a GroupList.
Definition group.c:183
void grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition group.c:203
#define MUTT_GROUP
'group' config command
Definition group.h:32
#define MUTT_UNGROUP
'ungroup' config command
Definition group.h:33
enum CommandResult parse_unsubscribe_from(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unsubscribe-from' command - Implements Command::parse() -.
Definition commands.c:1844
enum CommandResult parse_cd(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'cd' command - Implements Command::parse() -.
Definition commands.c:372
enum CommandResult parse_tag_formats(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'tag-formats' command - Implements Command::parse() -.
Definition commands.c:1463
enum CommandResult parse_unscore(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unscore' command - Implements Command::parse() -.
Definition score.c:220
enum CommandResult parse_alias(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'alias' command - Implements Command::parse() -.
Definition commands.c:137
enum CommandResult parse_lists(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'lists' command - Implements Command::parse() -.
Definition commands.c:645
enum CommandResult parse_finish(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'finish' command - Implements Command::parse() -.
Definition commands.c:437
enum CommandResult parse_version(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'version' command - Implements Command::parse() -.
Definition commands.c:1887
enum CommandResult parse_unsubjectrx_list(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unsubjectrx' command - Implements Command::parse() -.
Definition subjectrx.c:218
enum CommandResult parse_unmy_hdr(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unmy_hdr' command - Implements Command::parse() -.
Definition commands.c:1710
enum CommandResult parse_score(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'score' command - Implements Command::parse() -.
Definition score.c:94
enum CommandResult parse_attachments(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'attachments' command - Implements Command::parse() -.
Definition commands.c:485
enum CommandResult parse_unmailboxes(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unmailboxes' command - Implements Command::parse() -.
Definition commands.c:1664
enum CommandResult parse_unlists(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unlists' command - Implements Command::parse() -.
Definition commands.c:1585
enum CommandResult parse_ignore(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'ignore' command - Implements Command::parse() -.
Definition commands.c:617
enum CommandResult parse_subscribe(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'subscribe' command - Implements Command::parse() -.
Definition commands.c:1364
enum CommandResult parse_ifdef(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'ifdef' and 'ifndef' commands - Implements Command::parse() -.
Definition commands.c:563
enum CommandResult parse_alternates(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'alternates' command - Implements Command::parse() -.
Definition alternates.c:94
enum CommandResult parse_source(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'source' command - Implements Command::parse() -.
Definition commands.c:1185
enum CommandResult parse_my_hdr(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'my_hdr' command - Implements Command::parse() -.
Definition commands.c:916
enum CommandResult parse_set(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'set' family of commands - Implements Command::parse() -.
Definition set.c:473
enum CommandResult parse_unalias(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unalias' command - Implements Command::parse() -.
Definition commands.c:258
enum CommandResult parse_nospam(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'nospam' command - Implements Command::parse() -.
Definition commands.c:1230
enum CommandResult parse_mono(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'mono' command - Implements Command::parse() -.
Definition commands.c:536
enum CommandResult parse_stailq(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse a list command - Implements Command::parse() -.
Definition commands.c:1337
enum CommandResult parse_unsubscribe(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unsubscribe' command - Implements Command::parse() -.
Definition commands.c:1803
enum CommandResult parse_unmono(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unmono' command - Implements Command::parse() -.
Definition commands.c:485
enum CommandResult parse_group(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'group' and 'ungroup' commands - Implements Command::parse() -.
Definition commands.c:456
enum CommandResult parse_setenv(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'setenv' and 'unsetenv' commands - Implements Command::parse() -.
Definition commands.c:1019
enum CommandResult parse_unignore(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unignore' command - Implements Command::parse() -.
Definition commands.c:1553
enum CommandResult parse_unstailq(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse an unlist command - Implements Command::parse() -.
Definition commands.c:1770
enum CommandResult parse_spam(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'spam' command - Implements Command::parse() -.
Definition commands.c:1287
enum CommandResult parse_echo(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'echo' command - Implements Command::parse() -.
Definition commands.c:406
enum CommandResult parse_tag_transforms(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'tag-transforms' command - Implements Command::parse() -.
Definition commands.c:1509
enum CommandResult parse_unalternates(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unalternates' command - Implements Command::parse() -.
Definition alternates.c:140
enum CommandResult parse_unattachments(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'unattachments' command - Implements Command::parse() -.
Definition commands.c:557
enum CommandResult parse_color(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'color' command - Implements Command::parse() -.
Definition commands.c:505
enum CommandResult parse_uncolor(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'uncolor' command - Implements Command::parse() -.
Definition commands.c:449
enum CommandResult parse_subscribe_to(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'subscribe-to' command - Implements Command::parse() -.
Definition commands.c:1414
enum CommandResult parse_subjectrx_list(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'subjectrx' command - Implements Command::parse() -.
Definition subjectrx.c:192
enum CommandResult parse_mailboxes(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the 'mailboxes' command - Implements Command::parse() -.
Definition commands.c:810
#define mutt_warning(...)
Definition logging2.h:91
#define mutt_error(...)
Definition logging2.h:93
#define mutt_message(...)
Definition logging2.h:92
#define mutt_debug(LEVEL,...)
Definition logging2.h:90
static int envlist_sort(const void *a, const void *b, void *sdata)
Compare two environment strings - Implements sort_t -.
Definition commands.c:1007
Convenience wrapper for the gui headers.
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition hash.c:335
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition hash.c:362
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:457
IMAP network mailbox.
int imap_subscribe(const char *path, bool subscribe)
Subscribe to a mailbox.
Definition imap.c:1245
const struct MenuFuncOp * km_get_table(enum MenuType mtype)
Lookup a Menu's functions.
Definition lib.c:485
Manage keymappings.
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition list.c:46
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
@ LL_DEBUG2
Log at debug level 2.
Definition logging2.h:45
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:44
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:49
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
Definition mapping.c:85
#define FREE(x)
Definition memory.h:62
GUI present the user with a selectable list.
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition monitor.c:484
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition monitor.c:528
Monitor files for changes.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition charset.c:831
#define MUTT_ICONV_NO_FLAGS
No flags are set.
Definition charset.h:64
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition filter.c:220
Convenience wrapper for the library headers.
#define N_(a)
Definition message.h:32
#define _(a)
Definition message.h:28
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
bool mutt_path_to_absolute(char *path, const char *reference)
Convert a relative path to its absolute form.
Definition path.c:333
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
Definition path.c:476
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition regex.c:565
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition regex.c:178
int mutt_regexlist_add(struct RegexList *rl, const char *str, uint16_t flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition regex.c:139
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition regex.c:449
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition regex.c:234
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition regex.c:270
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:672
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:255
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:726
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition string.c:232
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:498
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition string.c:581
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition string.c:455
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:282
Many unsorted constants and some structs.
#define PATH_MAX
Definition mutt.h:42
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition muttlib.c:1063
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition muttlib.c:1038
void mutt_sleep(short s)
Sleep for a while.
Definition muttlib.c:841
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Definition muttlib.c:314
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition muttlib.c:699
Some miscellaneous functions.
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition mx.c:1549
bool mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add()
Definition mx.c:1740
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition mx.c:1524
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition mx.c:1476
API for mailboxes.
struct MailboxArray neomutt_mailboxes_get(struct NeoMutt *n, enum MailboxType type)
Get an Array of matching Mailboxes.
Definition neomutt.c:189
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
Definition neomutt.c:119
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:49
@ NT_HEADER
A header has changed, NotifyHeader EventHeader.
Definition notify_type.h:47
GUI display a file/email/help in a viewport with paging.
#define MUTT_PAGER_NO_FLAGS
No flags are set.
Definition lib.h:60
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition lib.h:140
Text parsing functions.
@ MUTT_SET_INV
default is to invert all vars
Definition set.h:36
@ MUTT_SET_SET
default is to set all vars
Definition set.h:35
@ MUTT_SET_RESET
default is to reset all vars to default
Definition set.h:38
@ MUTT_SET_UNSET
default is to unset all vars
Definition set.h:37
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
void mutt_qsort_r(void *base, size_t nmemb, size_t size, sort_t compar, void *sdata)
Sort an array, where the comparator has access to opaque data rather than requiring global variables.
Definition qsort_r.c:67
#define STAILQ_REMOVE_HEAD(head, field)
Definition queue.h:461
#define STAILQ_HEAD_INITIALIZER(head)
Definition queue.h:324
#define STAILQ_FIRST(head)
Definition queue.h:388
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
#define STAILQ_EMPTY(head)
Definition queue.h:382
#define TAILQ_HEAD_INITIALIZER(head)
Definition queue.h:694
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition queue.h:400
#define TAILQ_EMPTY(head)
Definition queue.h:778
enum CommandResult parse_rc_line(struct Buffer *line, struct Buffer *err)
Parse a line of user config.
Definition rc.c:45
Routines for adding user scores to emails.
Key value store.
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition store.c:126
#define NONULL(x)
Definition string2.h:43
#define SKIPWS(ch)
Definition string2.h:51
A group of associated Mailboxes.
Definition account.h:36
enum MailboxType type
Type of Mailboxes this Account contains.
Definition account.h:37
char * name
Name of Account.
Definition account.h:38
struct Notify * notify
Notifications: NotifyAccount, EventAccount.
Definition account.h:41
struct ConfigSubset * sub
Inherited config items.
Definition account.h:39
String manipulation buffer.
Definition buffer.h:36
char * dptr
Current read/write position.
Definition buffer.h:38
char * data
Pointer to data.
Definition buffer.h:37
intptr_t data
Data or flags to pass to the command.
Definition command.h:77
const char * name
Name of the command.
Definition command.h:59
Container for lots of config items.
Definition set.h:248
struct ConfigSet * cs
Parent ConfigSet.
Definition subset.h:50
An event that happened to a header.
Definition email.h:217
An Event that happened to a Mailbox.
Definition mailbox.h:190
struct Mailbox * mailbox
The Mailbox this Event relates to.
Definition mailbox.h:191
A Hash Table.
Definition hash.h:99
A List node for strings.
Definition list.h:37
char * data
String.
Definition list.h:38
A mailbox.
Definition mailbox.h:79
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:81
enum MailboxType type
Mailbox type.
Definition mailbox.h:102
bool poll_new_mail
Check for new mail.
Definition mailbox.h:115
char * name
A short name for the Mailbox.
Definition mailbox.h:82
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:145
bool notify_user
Notify the user of new mail.
Definition mailbox.h:113
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:80
struct Account * account
Account that owns this Mailbox.
Definition mailbox.h:127
bool visible
True if a result of "mailboxes".
Definition mailbox.h:130
int opened
Number of times mailbox is opened.
Definition mailbox.h:128
int gen
Generation number, for sorting.
Definition mailbox.h:147
Mapping between a function and an operation.
Definition lib.h:117
const char * name
Name of the function.
Definition lib.h:118
Container for Accounts, Notifications.
Definition neomutt.h:43
struct AccountArray accounts
All Accounts.
Definition neomutt.h:48
struct CommandArray commands
NeoMutt commands.
Definition neomutt.h:51
char ** env
Private copy of the environment variables.
Definition neomutt.h:56
char * home_dir
User's home directory.
Definition neomutt.h:54
struct Notify * notify
Notifications handler.
Definition neomutt.h:44
struct HashTable * groups
Hash Table: "group-name" -> Group.
Definition neomutt.h:52
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
Data to be displayed by PagerView.
Definition lib.h:159
const char * fname
Name of the file to read.
Definition lib.h:163
Paged view into some data.
Definition lib.h:170
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:171
enum PagerMode mode
Pager mode.
Definition lib.h:172
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:173
const char * banner
Title to display in status bar.
Definition lib.h:174
struct HashElemArray get_elem_list(struct ConfigSet *cs, enum GetElemListFlags flags)
Create a sorted list of all config items.
Definition subset.c:81
void cs_subset_free(struct ConfigSubset **ptr)
Free a Config Subset.
Definition subset.c:112
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition subset.c:193
GetElemListFlags
Flags for get_elem_list()
Definition subset.h:80
struct HashTable * TagFormats
Hash Table: "inbox" -> "GI" - Tag format strings.
Definition tags.c:42
struct HashTable * TagTransforms
Hash Table: "inbox" -> "i" - Alternative tag names.
Definition tags.c:41
#define buf_mktemp(buf)
Definition tmp.h:33
const struct Mapping MenuNames[]
Menu name lookup table.
Definition type.c:37
bool print_version(FILE *fp, bool use_ansi)
Print system and compile info to a file.
Definition version.c:591
bool feature_enabled(const char *name)
Test if a compile-time feature is enabled.
Definition version.c:729
Display version and copyright about NeoMutt.