From: Richard Russon Date: Wed, 27 Jun 2018 01:31:17 +0000 (+0100) Subject: notifications X-Git-Tag: 2019-10-25~739^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a9be2e80ee39445f807f2e6a7a854abb9d068d1;p=neomutt notifications --- diff --git a/browser.c b/browser.c index 9c8be2c9c..fddff3809 100644 --- a/browser.c +++ b/browser.c @@ -1639,7 +1639,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi #ifdef USE_IMAP case OP_BROWSER_TOGGLE_LSUB: - ImapListSubscribed = !ImapListSubscribed; + bool_str_toggle(Config, "imap_list_subscribed", NULL); mutt_unget_event(0, OP_CHECK_NEW); break; @@ -1830,77 +1830,56 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi break; case OP_ENTER_MASK: - + { mutt_str_strfcpy(buf, NONULL(Mask ? Mask->pattern : NULL), sizeof(buf)); - if (mutt_get_field(_("File Mask: "), buf, sizeof(buf), 0) == 0) - { - regex_t *rx = mutt_mem_malloc(sizeof(regex_t)); - char *s = buf; - int not = 0, err; + if (mutt_get_field(_("File Mask: "), buf, sizeof(buf), 0) != 0) + break; - buffy = 0; - /* assume that the user wants to see everything */ - if (!buf[0]) - mutt_str_strfcpy(buf, ".", sizeof(buf)); - SKIPWS(s); - if (*s == '!') - { - s++; - SKIPWS(s); - not = 1; - } + buffy = 0; + /* assume that the user wants to see everything */ + if (!buf[0]) + mutt_str_strfcpy(buf, ".", sizeof(buf)); - err = REGCOMP(rx, s, REG_NOSUB); - if (err != 0) + struct Buffer errmsg = { 0 }; + int rc = cs_str_string_set(Config, "mask", buf, NULL); + if (CSR_RESULT(rc) != CSR_SUCCESS) + { + if (!mutt_buffer_is_empty(&errmsg)) { - regerror(err, rx, buf, sizeof(buf)); - FREE(&rx); - mutt_error("%s", buf); + mutt_error("%s", errmsg.data); + FREE(&errmsg.data); } - else - { - if (Mask && Mask->regex) - { - regfree(Mask->regex); - FREE(&Mask->regex); - } - else - { - Mask = mutt_mem_calloc(1, sizeof(struct Regex)); - } - mutt_str_replace(&Mask->pattern, buf); - Mask->regex = rx; - Mask->not = not; + break; + } - destroy_state(&state); + destroy_state(&state); #ifdef USE_IMAP - if (state.imap_browse) - { - init_state(&state, NULL); - state.imap_browse = true; - imap_browse(LastDir, &state); - browser_sort(&state); - menu->data = state.entry; - init_menu(&state, menu, title, sizeof(title), buffy); - } - else + if (state.imap_browse) + { + init_state(&state, NULL); + state.imap_browse = true; + imap_browse(LastDir, &state); + browser_sort(&state); + menu->data = state.entry; + init_menu(&state, menu, title, sizeof(title), buffy); + } + else #endif - if (examine_directory(menu, &state, LastDir, NULL) == 0) - init_menu(&state, menu, title, sizeof(title), buffy); - else - { - mutt_error(_("Error scanning directory.")); - goto bail; - } - kill_prefix = 0; - if (state.entrylen == 0) - { - mutt_error(_("No files match the file mask")); - break; - } - } + if (examine_directory(menu, &state, LastDir, NULL) == 0) + init_menu(&state, menu, title, sizeof(title), buffy); + else + { + mutt_error(_("Error scanning directory.")); + goto bail; + } + kill_prefix = 0; + if (state.entrylen == 0) + { + mutt_error(_("No files match the file mask")); + break; } break; + } case OP_SORT: case OP_SORT_REVERSE: @@ -1961,7 +1940,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi browser_highlight_default(&state, menu); menu->redraw = REDRAW_FULL; } - SortBrowser = sort; + cs_str_native_set(Config, "sort_browser", sort, NULL); break; } @@ -2080,10 +2059,9 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi if (OptNews) { struct FolderFile *ff = &state.entry[menu->current]; - int rc; struct NntpData *nntp_data = NULL; - rc = nntp_newsrc_parse(CurrentNewsSrv); + int rc = nntp_newsrc_parse(CurrentNewsSrv); if (rc < 0) break; @@ -2149,7 +2127,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi regex_t rx; memset(&rx, 0, sizeof(rx)); char *s = buf; - int rc, j = menu->current; + int j = menu->current; if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) { @@ -2183,7 +2161,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi break; } - rc = nntp_newsrc_parse(nserv); + int rc = nntp_newsrc_parse(nserv); if (rc < 0) break; diff --git a/commands.c b/commands.c index 04cf2902f..3369fb36d 100644 --- a/commands.c +++ b/commands.c @@ -648,7 +648,7 @@ int mutt_select_sort(int reverse) if (reverse) new_sort |= SORT_REVERSE; - Sort = new_sort; + cs_str_native_set(Config, "sort", new_sort, NULL); return (Sort != method) ? 0 : -1; /* no need to resort if it's the same */ } diff --git a/curs_main.c b/curs_main.c index 6d8a32e29..d06f4d104 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2133,7 +2133,7 @@ int mutt_index_menu(void) * again while reading the message. */ if (op == OP_DISPLAY_HEADERS) - Weed = !Weed; + bool_str_toggle(Config, "weed", NULL); OptNeedResort = false; @@ -3343,7 +3343,7 @@ int mutt_index_menu(void) break; case OP_SIDEBAR_TOGGLE_VISIBLE: - SidebarVisible = !SidebarVisible; + bool_str_toggle(Config, "sidebar_visible", NULL); mutt_window_reflow(); break; diff --git a/init.h b/init.h index 1a4d6311e..7f5364cae 100644 --- a/init.h +++ b/init.h @@ -1812,7 +1812,7 @@ struct ConfigDef MuttVars[] = { ** .pp ** Also see the $$smart_wrap variable. */ - { "mask", DT_REGEX|DT_REGEX_MATCH_CASE|DT_REGEX_ALLOW_NOT, R_NONE, &Mask, IP "!^\\.[^.]" }, + { "mask", DT_REGEX|DT_REGEX_MATCH_CASE|DT_REGEX_ALLOW_NOT|DT_REGEX_NOSUB, R_NONE, &Mask, IP "!^\\.[^.]" }, /* ** .pp ** A regular expression used in the file browser, optionally preceded by diff --git a/main.c b/main.c index dbe41e05d..8e235791d 100644 --- a/main.c +++ b/main.c @@ -915,7 +915,7 @@ int main(int argc, char *argv[], char *envp[]) if (mutt_str_strncasecmp("X-Mutt-Resume-Draft:", np->data, 20) == 0) { if (ResumeEditedDraftFiles) - ResumeDraftFiles = true; + cs_str_native_set(Config, "resume_draft_files", true, NULL); STAILQ_REMOVE(&msg->env->userhdrs, np, ListNode, entries); FREE(&np->data); diff --git a/mutt_logging.c b/mutt_logging.c index 977a407bc..251632412 100644 --- a/mutt_logging.c +++ b/mutt_logging.c @@ -292,7 +292,7 @@ int mutt_log_set_level(int level, bool verbose) if (log_file_set_level(level, verbose) != 0) return -1; - DebugLevel = level; + cs_str_native_set(Config, "debug_level", level, NULL); return 0; } diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index e5e176f0a..29d8bf652 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -353,7 +353,7 @@ static bool query_window_check_timebase(const char *timebase) static void query_window_reset(void) { mutt_debug(2, "entering\n"); - NmQueryWindowCurrentPosition = 0; + cs_str_native_set(Config, "nm_query_window_current_position", 0, NULL); } /** diff --git a/pager.c b/pager.c index 4fa8abec3..9a62bc4eb 100644 --- a/pager.c +++ b/pager.c @@ -2373,7 +2373,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e if (query_quadoption(Quit, _("Quit NeoMutt?")) == MUTT_YES) { /* avoid prompting again in the index menu */ - Quit = MUTT_YES; + cs_str_native_set(Config, "quit", MUTT_YES, NULL); ch = -1; } break; @@ -3320,7 +3320,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e break; case OP_SIDEBAR_TOGGLE_VISIBLE: - SidebarVisible = !SidebarVisible; + bool_str_toggle(Config, "sidebar_visible", NULL); mutt_window_reflow(); break; #endif diff --git a/recvattach.c b/recvattach.c index 1214b6164..bd92e3463 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1067,7 +1067,7 @@ int mutt_attach_display_loop(struct Menu *menu, int op, struct Header *hdr, switch (op) { case OP_DISPLAY_HEADERS: - Weed = !Weed; + bool_str_toggle(Config, "weed", NULL); /* fallthrough */ case OP_VIEW_ATTACH: