From 4e6ad0520f10f024a9605c49094ffe09c2efb889 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 25 Aug 2018 17:39:31 +0100 Subject: [PATCH] probe notmuch --- browser.c | 6 +++--- mailbox.c | 8 ++++---- muttlib.c | 7 +++++-- mx.c | 21 --------------------- mx.h | 3 --- notmuch/mutt_notmuch.c | 3 +-- 6 files changed, 13 insertions(+), 35 deletions(-) diff --git a/browser.c b/browser.c index 0a33fe2af..9d02397ee 100644 --- a/browser.c +++ b/browser.c @@ -415,7 +415,7 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c char *s = NULL; #ifdef USE_NOTMUCH - if (mx_is_notmuch(folder->ff->name)) + if (nm_path_probe(folder->ff->name, NULL) == MUTT_NOTMUCH) s = NONULL(folder->ff->desc); else #endif @@ -915,7 +915,7 @@ static int examine_vfolders(struct Menu *menu, struct BrowserState *state) struct MailboxNode *np = NULL; STAILQ_FOREACH(np, &AllMailboxes, entries) { - if (mx_is_notmuch(np->b->path)) + if (nm_path_probe(np->b->path, NULL) == MUTT_NOTMUCH) { nm_nonctx_get_count(np->b->path, &np->b->msg_count, &np->b->msg_unread); add_folder(menu, state, np->b->path, np->b->desc, NULL, np->b, NULL); @@ -1681,7 +1681,7 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int mutt_str_strfcpy(file, state.entry[menu->current].name, filelen); #endif #ifdef USE_NOTMUCH - else if (mx_is_notmuch(state.entry[menu->current].name)) + else if (nm_path_probe(state.entry[menu->current].name, NULL) == MUTT_NOTMUCH) mutt_str_strfcpy(file, state.entry[menu->current].name, filelen); #endif else diff --git a/mailbox.c b/mailbox.c index ed39d56bb..569ad2623 100644 --- a/mailbox.c +++ b/mailbox.c @@ -403,7 +403,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec tmp->magic = MUTT_NNTP; #endif #ifdef USE_NOTMUCH - if (mx_is_notmuch(tmp->path)) + if (nm_path_probe(tmp->path, NULL) == MUTT_NOTMUCH) tmp->magic = MUTT_NOTMUCH; else #endif @@ -623,7 +623,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, mutt_extract_token(path, s, 0); #ifdef USE_NOTMUCH - if (mx_is_notmuch(path->data)) + if (nm_path_probe(path->data, NULL) == MUTT_NOTMUCH) nm_normalize_uri(path->data, buf, sizeof(buf)); else #endif @@ -663,7 +663,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, b->newly_created = false; b->desc = desc; #ifdef USE_NOTMUCH - if (mx_is_notmuch(b->path)) + if (nm_path_probe(b->path, NULL) == MUTT_NOTMUCH) { b->magic = MUTT_NOTMUCH; b->size = 0; @@ -723,7 +723,7 @@ int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, else { #ifdef USE_NOTMUCH - if (mx_is_notmuch(path->data)) + if (nm_path_probe(path->data, NULL) == MUTT_NOTMUCH) { nm_normalize_uri(path->data, buf, sizeof(buf)); } diff --git a/muttlib.c b/muttlib.c index 3cdca4f40..6caf10a87 100644 --- a/muttlib.c +++ b/muttlib.c @@ -57,6 +57,9 @@ #ifdef USE_IMAP #include "imap/imap.h" #endif +#ifdef USE_NOTMUCH +#include "notmuch/mutt_notmuch.h" +#endif /* These Config Variables are only used in muttlib.c */ struct Regex *GecosMask; ///< Config: Regex for parsing GECOS field of /etc/passwd @@ -196,7 +199,7 @@ char *mutt_expand_path_regex(char *buf, size_t buflen, bool regex) else #endif #ifdef USE_NOTMUCH - if (mx_is_notmuch(Folder)) + if (nm_path_probe(Folder, NULL) == MUTT_NOTMUCH) mutt_str_strfcpy(p, Folder, sizeof(p)); else #endif @@ -1526,7 +1529,7 @@ void mutt_get_parent_path(char *path, char *buf, size_t buflen) else #endif #ifdef USE_NOTMUCH - if (mx_is_notmuch(path)) + if (nm_path_probe(path, NULL) == MUTT_NOTMUCH) mutt_str_strfcpy(buf, Folder, buflen); else #endif diff --git a/mx.c b/mx.c index e411b9c25..5657ee5a5 100644 --- a/mx.c +++ b/mx.c @@ -213,27 +213,6 @@ bool mx_is_nntp(const char *p) } #endif -#ifdef USE_NOTMUCH -/** - * mx_is_notmuch - Is this a Notmuch mailbox - * @param p Mailbox string to test - * @retval true It is a Notmuch mailbox - */ -bool mx_is_notmuch(const char *p) -{ - enum UrlScheme scheme; - - if (!p) - return false; - - scheme = url_check_scheme(p); - if (scheme == U_NOTMUCH) - return true; - - return false; -} -#endif - /** * mx_access - Wrapper for access, checks permissions on a given mailbox * @param path Path of mailbox diff --git a/mx.h b/mx.h index 8517fd32a..1c9265aa1 100644 --- a/mx.h +++ b/mx.h @@ -255,9 +255,6 @@ void mx_update_tables(struct Context *ctx, bool committing); #ifdef USE_IMAP bool mx_is_imap(const char *p); #endif -#ifdef USE_NOTMUCH -bool mx_is_notmuch(const char *p); -#endif #ifdef USE_NNTP bool mx_is_nntp(const char *p); #endif diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index add93fe9f..d2aa35347 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -2768,8 +2768,7 @@ int nm_path_probe(const char *path, const struct stat *st) if (!path) return MUTT_UNKNOWN; - enum UrlScheme scheme = url_check_scheme(path); - if (scheme == U_NOTMUCH) + if (mutt_str_strncasecmp(path, "notmuch://", 10) == 0) return MUTT_NOTMUCH; return MUTT_UNKNOWN; -- 2.40.0