155  if (c_nm_default_url)
 
  157    snprintf(url, len, 
"%s", c_nm_default_url);
 
  161    snprintf(url, len, 
"notmuch://%s", c_folder);
 
 
  228  return edata->virtual_id;
 
 
  295  if (!c_nm_query_window_current_search || !
mutt_str_equal(query, c_nm_query_window_current_search))
 
  301      buf, buflen, c_nm_query_window_enable, c_nm_query_window_duration,
 
  302      c_nm_query_window_current_position, c_nm_query_window_current_search,
 
  303      c_nm_query_window_timebase, c_nm_query_window_or_terms);
 
  322          _(
"Invalid nm_query_window_timebase value (valid values are: hour, day, week, month, year)"));
 
 
  387    char buf[1024] = { 0 };
 
  394    if (!strstr(mdata->
db_query, 
"date:") &&
 
 
  427  if (!c_nm_exclude_tags || !query)
 
  432  const char **tag = NULL;
 
  436    notmuch_query_add_tag_exclude(query, *tag);
 
  439  notmuch_query_set_omit_excluded(query, 1);
 
 
  456  notmuch_database_t *db = 
nm_db_get(m, writable);
 
  462  notmuch_query_t *q = notmuch_query_create(db, str);
 
  467  notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
 
 
  490  for (notmuch_tags_t *tags = notmuch_message_get_tags(msg);
 
  491       tags && notmuch_tags_valid(tags); notmuch_tags_move_to_next(tags))
 
  493    const char *t = notmuch_tags_get(tags);
 
  494    if (!t || (*t == 
'\0'))
 
 
  540  char *p = strrchr(
path, 
'/');
 
  541  if (p && ((p - 
path) > 3) &&
 
  557    for (; (p > 
path) && (*(p - 1) == 
'/'); p--)
 
 
  598  char *p = strrchr(
path, 
'/');
 
  600  if (p && ((p - 
path) > 3) &&
 
  605    for (; (p > 
path) && (*(p - 1) == 
'/'); p--)
 
 
  649  const char *
id = notmuch_message_get_message_id(msg);
 
 
  685  const char *name = NULL;
 
  687  for (notmuch_filenames_t *ls = notmuch_message_get_filenames(msg);
 
  688       ls && notmuch_filenames_valid(ls); notmuch_filenames_move_to_next(ls))
 
  690    name = notmuch_filenames_get(ls);
 
 
  710  mdata->ignmsgcount = 0;
 
 
  741  const char *
id = notmuch_message_get_message_id(msg);
 
 
  771                           notmuch_message_t *msg, 
bool dedup)
 
  777  char *newpath = NULL;
 
  778  struct Email *e = NULL;
 
  786               notmuch_message_get_message_id(msg));
 
  804    if (access(
path, F_OK) == 0)
 
 
  884                           notmuch_query_t *q, notmuch_message_t *top, 
bool dedup)
 
  886  notmuch_messages_t *msgs = NULL;
 
  888  for (msgs = notmuch_message_get_replies(top); notmuch_messages_valid(msgs);
 
  889       notmuch_messages_move_to_next(msgs))
 
  891    notmuch_message_t *nm = notmuch_messages_get(msgs);
 
  895    notmuch_message_destroy(nm);
 
 
  911                          notmuch_query_t *q, notmuch_thread_t *
thread, 
bool dedup)
 
  913  notmuch_messages_t *msgs = NULL;
 
  915  for (msgs = notmuch_thread_get_toplevel_messages(
thread);
 
  916       notmuch_messages_valid(msgs); notmuch_messages_move_to_next(msgs))
 
  918    notmuch_message_t *nm = notmuch_messages_get(msgs);
 
  921    notmuch_message_destroy(nm);
 
 
  939  notmuch_messages_t *msgs = NULL;
 
  941#if LIBNOTMUCH_CHECK_VERSION(5, 0, 0) 
  942  if (notmuch_query_search_messages(query, &msgs) != NOTMUCH_STATUS_SUCCESS)
 
  944#elif LIBNOTMUCH_CHECK_VERSION(4, 3, 0) 
  945  if (notmuch_query_search_messages_st(query, &msgs) != NOTMUCH_STATUS_SUCCESS)
 
  948  msgs = notmuch_query_search_messages(query);
 
 
  977  for (; notmuch_messages_valid(msgs) && ((limit == 0) || (m->
msg_count < limit));
 
  978       notmuch_messages_move_to_next(msgs))
 
  986    notmuch_message_t *nm = notmuch_messages_get(msgs);
 
  988    notmuch_message_destroy(nm);
 
 
 1009  notmuch_threads_t *threads = NULL;
 
 1010#if LIBNOTMUCH_CHECK_VERSION(5, 0, 0) 
 1011  if (notmuch_query_search_threads(query, &threads) != NOTMUCH_STATUS_SUCCESS)
 
 1013#elif LIBNOTMUCH_CHECK_VERSION(4, 3, 0) 
 1014  if (notmuch_query_search_threads_st(query, &threads) != NOTMUCH_STATUS_SUCCESS)
 
 1017  threads = notmuch_query_search_threads(query);
 
 
 1044  for (; notmuch_threads_valid(threads) && ((limit == 0) || (m->
msg_count < limit));
 
 1045       notmuch_threads_move_to_next(threads))
 
 1053    notmuch_thread_t *thread = notmuch_threads_get(threads);
 
 1055    notmuch_thread_destroy(thread);
 
 
 1071  notmuch_message_t *msg = NULL;
 
 1077    notmuch_database_find_message(db, 
id, &msg);
 
 
 1090  const char *possible_match_tag = NULL;
 
 1091  notmuch_tags_t *tags = NULL;
 
 1093  for (tags = notmuch_message_get_tags(msg); notmuch_tags_valid(tags);
 
 1094       notmuch_tags_move_to_next(tags))
 
 1096    possible_match_tag = notmuch_tags_get(tags);
 
 
 1132  notmuch_message_freeze(msg);
 
 1135  const char **tag_elem = NULL;
 
 1138    const char *tag = *tag_elem;
 
 1143      notmuch_message_remove_tag(msg, tag + 1);
 
 1145    else if (tag[0] == 
'!')
 
 1150        notmuch_message_remove_tag(msg, tag + 1);
 
 1154        notmuch_message_add_tag(msg, tag + 1);
 
 1160      notmuch_message_add_tag(msg, (tag[0] == 
'+') ? tag + 1 : tag);
 
 1164  notmuch_message_thaw(msg);
 
 
 1191  const char **tag_elem = NULL;
 
 1194    const char *tag = *tag_elem;
 
 1208      tag = (tag[0] == 
'+') ? tag + 1 : tag;
 
 
 1240  char *p = strrchr(folder, 
'/');
 
 1254  p = strrchr(folder, 
'/');
 
 1260  p = strchr(filename, c_maildir_field_delimiter);
 
 1267  snprintf(buf, buflen, 
"%s/%s/%s%s", folder,
 
 1268           (e->
read || e->
old) ? 
"cur" : 
"new", filename, suffix);
 
 1273  if (rename(old, buf) != 0)
 
 
 1297  notmuch_database_t *db = 
nm_db_get(m, 
true);
 
 1301  notmuch_message_t *msg = NULL;
 
 1302  notmuch_status_t st = notmuch_database_find_message_by_filename(db, path, &msg);
 
 1312  notmuch_filenames_t *ls = NULL;
 
 1313  st = notmuch_database_remove_message(db, path);
 
 1316    case NOTMUCH_STATUS_SUCCESS:
 
 1320    case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
 
 1323      for (ls = notmuch_message_get_filenames(msg);
 
 1324           ls && notmuch_filenames_valid(ls); notmuch_filenames_move_to_next(ls))
 
 1326        path = notmuch_filenames_get(ls);
 
 1330        notmuch_database_remove_message(db, path);
 
 1338  notmuch_message_destroy(msg);
 
 
 1354                           const char *new_file, 
struct Email *e)
 
 1360  notmuch_database_t *db = 
nm_db_get(m, 
true);
 
 1361  if (!db || !new_file || !old_file || (access(new_file, F_OK) != 0))
 
 1365  notmuch_status_t st;
 
 1366  notmuch_filenames_t *ls = NULL;
 
 1367  notmuch_message_t *msg = NULL;
 
 1375#if LIBNOTMUCH_CHECK_VERSION(5, 1, 0) 
 1376  st = notmuch_database_index_file(db, new_file, NULL, &msg);
 
 1378  st = notmuch_database_add_message(db, new_file, &msg);
 
 1381  if ((st != NOTMUCH_STATUS_SUCCESS) && (st != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID))
 
 1388  st = notmuch_database_remove_message(db, old_file);
 
 1391    case NOTMUCH_STATUS_SUCCESS:
 
 1393    case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
 
 1395      notmuch_message_destroy(msg);
 
 1397      notmuch_database_find_message_by_filename(db, new_file, &msg);
 
 1399      for (ls = notmuch_message_get_filenames(msg);
 
 1400           msg && ls && notmuch_filenames_valid(ls); notmuch_filenames_move_to_next(ls))
 
 1402        const char *path = notmuch_filenames_get(ls);
 
 1413          notmuch_database_remove_message(db, path);
 
 1414#if LIBNOTMUCH_CHECK_VERSION(5, 1, 0) 
 1415          notmuch_database_index_file(db, newpath, NULL, NULL);
 
 1417          notmuch_database_add_message(db, newpath, NULL);
 
 1421      notmuch_message_destroy(msg);
 
 1423      notmuch_database_find_message_by_filename(db, new_file, &msg);
 
 1424      st = NOTMUCH_STATUS_SUCCESS;
 
 1431  if ((st == NOTMUCH_STATUS_SUCCESS) && e && msg)
 
 1433    notmuch_message_maildir_flags_to_tags(msg);
 
 1445    notmuch_message_destroy(msg);
 
 
 1458static unsigned int count_query(notmuch_database_t *db, 
const char *qstr, 
int limit)
 
 1460  notmuch_query_t *q = notmuch_query_create(db, qstr);
 
 1464  unsigned int res = 0;
 
 1467#if LIBNOTMUCH_CHECK_VERSION(5, 0, 0) 
 1468  if (notmuch_query_count_messages(q, &res) != NOTMUCH_STATUS_SUCCESS)
 
 1470#elif LIBNOTMUCH_CHECK_VERSION(4, 3, 0) 
 1471  if (notmuch_query_count_messages_st(q, &res) != NOTMUCH_STATUS_SUCCESS)
 
 1474  res = notmuch_query_count_messages(q);
 
 1476  notmuch_query_destroy(q);
 
 1479  if ((limit > 0) && (res > limit))
 
 
 1497  return edata->folder;
 
 
 1522  char *
path = full_folder + prefix;
 
 
 1545  notmuch_query_t *q = NULL;
 
 1546  notmuch_database_t *db = NULL;
 
 1547  notmuch_message_t *msg = NULL;
 
 1557  const char *
id = notmuch_message_get_thread_id(msg);
 
 1563  q = notmuch_query_create(db, 
buf_string(qstr));
 
 1568  notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
 
 1572  mdata->
mtime.tv_nsec = 0;
 
 1579    notmuch_query_destroy(q);
 
 
 1607  bool using_default_data = 
false;
 
 1618    using_default_data = 
true;
 
 1628    added = snprintf(url, 
sizeof(url), 
"%s%s?type=%s&query=", 
NmUrlProtocol,
 
 1633    added = snprintf(url, 
sizeof(url), 
"%s%s?type=%s&limit=%d&query=", 
NmUrlProtocol,
 
 1638  if (added >= 
sizeof(url))
 
 1647  buf[buflen - 1] = 
'\0';
 
 1649  if (using_default_data)
 
 
 1665  return c_nm_query_window_enable || (c_nm_query_window_duration > 0);
 
 
 1680  if (c_nm_query_window_current_position != 0)
 
 1683                             c_nm_query_window_current_position - 1, NULL);
 
 
 1701                           c_nm_query_window_current_position + 1, NULL);
 
 
 1726  notmuch_database_t *db = 
nm_db_get(m, 
false);
 
 1729  if (!db || !orig_str)
 
 1732  char *new_str = NULL;
 
 1739  notmuch_query_t *q = notmuch_query_create(db, new_str);
 
 1741  switch (
mdata->query_type)
 
 1751      rc = notmuch_messages_valid(messages);
 
 1752      notmuch_messages_destroy(messages);
 
 1762      rc = notmuch_threads_valid(threads);
 
 1763      notmuch_threads_destroy(threads);
 
 1768  notmuch_query_destroy(q);
 
 1771             new_str, rc ? 
"true" : 
"false");
 
 
 1786                       const char *new_file, 
struct Email *e)
 
 1790  if (!
mdata || !new_file)
 
 1803  mdata->mtime.tv_nsec = 0;
 
 
 1813  struct Url *url = NULL;
 
 1814  const char *db_filename = NULL;
 
 1815  char *db_query = NULL;
 
 1816  notmuch_database_t *db = NULL;
 
 1819  int limit = c_nm_db_limit;
 
 1833      db_query = item->
value;
 
 1838      if (!mutt_str_atoi_full(item->
value, &limit))
 
 1849  db_filename = url->
path;
 
 
 1920  notmuch_database_t *db = NULL;
 
 1921  notmuch_status_t st;
 
 1922  notmuch_message_t *msg = NULL;
 
 1941  if (!path || !
mdata || (access(path, F_OK) != 0))
 
 1952#if LIBNOTMUCH_CHECK_VERSION(5, 1, 0) 
 1953  st = notmuch_database_index_file(db, path, NULL, &msg);
 
 1955  st = notmuch_database_add_message(db, path, &msg);
 
 1958  if ((st != NOTMUCH_STATUS_SUCCESS) && (st != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID))
 
 1964  if ((st == NOTMUCH_STATUS_SUCCESS) && msg)
 
 1966    notmuch_message_maildir_flags_to_tags(msg);
 
 1975    if (c_nm_record_tags)
 
 1982    notmuch_message_destroy(msg);
 
 
 2007  notmuch_database_t *db = NULL;
 
 2008  notmuch_tags_t *tags = NULL;
 
 2009  const char *tag = NULL;
 
 2012  if (!(db = 
nm_db_get(m, 
false)) || !(tags = notmuch_database_get_all_tags(db)))
 
 2018  while (notmuch_tags_valid(tags))
 
 2020    tag = notmuch_tags_get(tags);
 
 2028    notmuch_tags_move_to_next(tags);
 
 2034    notmuch_tags_destroy(tags);
 
 
 2082  notmuch_query_t *q = 
get_query(m, 
false);
 
 2086    switch (
mdata->query_type)
 
 2098    notmuch_query_destroy(q);
 
 2104  mdata->mtime.tv_nsec = 0;
 
 2106  mdata->oldmsgcount = 0;
 
 
 2126  bool occult = 
false;
 
 2131               (
unsigned long long) 
mtime, (
unsigned long long) 
mdata->mtime.tv_sec);
 
 2136             (
unsigned long long) 
mtime, (
unsigned long long) 
mdata->mtime.tv_sec);
 
 2138  notmuch_query_t *q = 
get_query(m, 
false);
 
 2159#if LIBNOTMUCH_CHECK_VERSION(5, 0, 0) 
 2162#elif LIBNOTMUCH_CHECK_VERSION(4, 3, 0) 
 2169  for (
int i = 0; notmuch_messages_valid(msgs) && ((limit == 0) || (i < limit));
 
 2170       notmuch_messages_move_to_next(msgs), i++)
 
 2172    notmuch_message_t *msg = notmuch_messages_get(msgs);
 
 2179      notmuch_message_destroy(msg);
 
 2209    notmuch_message_destroy(msg);
 
 2231    notmuch_query_destroy(q);
 
 2236  mdata->
mtime.tv_nsec = 0;
 
 
 2260  struct Progress *progress = NULL;
 
 2262  bool changed = 
false;
 
 2275  int mh_sync_errors = 0;
 
 2293      old_file[
sizeof(old_file) - 1] = 
'\0';
 
 2309      notmuch_database_t *db = 
nm_db_get(m, 
true);
 
 2330      mh_sync_errors += 1;
 
 2341      else if (*new_file && *old_file && (
rename_filename(m, old_file, new_file, e) == 0))
 
 2348  if (mh_sync_errors > 0)
 
 2350    mutt_error(ngettext(
"Unable to sync %d message due to external mailbox modification",
 
 2351                        "Unable to sync %d messages due to external mailbox modification",
 
 2364    mdata->
mtime.tv_nsec = 0;
 
 
 2401  return msg->
fp != NULL;
 
 
 2449  notmuch_database_t *db = NULL;
 
 2450  notmuch_message_t *msg = NULL;
 
 2470    mdata->mtime.tv_nsec = 0;
 
 
 2506  .mbox_open_append = NULL,
 
 2515  .msg_padding_size = NULL,
 
 2516  .msg_save_hcache  = NULL,
 
 2521  .path_is_empty    = NULL,
 
 
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
 
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
 
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
 
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
 
void buf_join_str(struct Buffer *buf, const char *str, char sep)
Join a buffer with a string separated by sep.
 
bool buf_str_equal(const struct Buffer *a, const struct Buffer *b)
Return if two buffers are equal.
 
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
 
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
 
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
 
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
 
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
 
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
 
Convenience wrapper for the config headers.
 
const char * cc_maildir_field_delimiter(void)
Get the cached value of $maildir_field_delimiter.
 
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
 
Convenience wrapper for the core headers.
 
void mailbox_size_add(struct Mailbox *m, const struct Email *e)
Add an email's size to the total size of a Mailbox.
 
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
 
@ NT_MAILBOX_INVALID
Email list was changed.
 
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
 
MailboxType
Supported mailbox formats.
 
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
 
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
 
@ MUTT_MAILDIR
'Maildir' Mailbox type
 
void email_set_color(struct Mailbox *m, struct Email *e)
Select an Index colour for an Email.
 
void mutt_body_free(struct Body **ptr)
Free a Body.
 
void email_free(struct Email **ptr)
Free an Email.
 
Structs that make up an email.
 
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
 
#define mutt_file_fclose(FP)
 
#define mutt_file_fopen(PATH, MODE)
 
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
 
void nm_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free() -.
 
enum CommandResult parse_unmailboxes(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unmailboxes' command - Implements Command::parse() -.
 
enum CommandResult parse_mailboxes(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'mailboxes' command - Implements Command::parse() -.
 
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
 
#define mutt_message(...)
 
#define mutt_debug(LEVEL,...)
 
void nm_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free() -.
 
static bool nm_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Implements MxOps::ac_add() -.
 
static bool nm_ac_owns_path(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -.
 
const struct MxOps MxNotmuchOps
Notmuch Mailbox - Implements MxOps -.
 
static enum MxStatus nm_mbox_check_stats(struct Mailbox *m, uint8_t flags)
Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -.
 
static enum MxStatus nm_mbox_check(struct Mailbox *m)
Check for new mail - Implements MxOps::mbox_check() -.
 
static enum MxStatus nm_mbox_close(struct Mailbox *m)
Close a Mailbox - Implements MxOps::mbox_close() -.
 
static enum MxOpenReturns nm_mbox_open(struct Mailbox *m)
Open a Mailbox - Implements MxOps::mbox_open() -.
 
static enum MxStatus nm_mbox_sync(struct Mailbox *m)
Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
 
static int nm_msg_close(struct Mailbox *m, struct Message *msg)
Close an email - Implements MxOps::msg_close() -.
 
static int nm_msg_commit(struct Mailbox *m, struct Message *msg)
Save changes to an email - Implements MxOps::msg_commit() -.
 
bool maildir_msg_open_new(struct Mailbox *m, struct Message *msg, const struct Email *e)
Open a new message in a Mailbox - Implements MxOps::msg_open_new() -.
 
static bool nm_msg_open(struct Mailbox *m, struct Message *msg, struct Email *e)
Open an email message in a Mailbox - Implements MxOps::msg_open() -.
 
static int nm_path_canon(struct Buffer *path)
Canonicalise a Mailbox path - Implements MxOps::path_canon() -.
 
enum MailboxType nm_path_probe(const char *path, const struct stat *st)
Is this a Notmuch Mailbox?
 
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
 
struct HeaderCache * hcache_open(const char *path, const char *folder, hcache_namer_t namer, bool create)
Multiplexor for StoreOps::open.
 
void hcache_close(struct HeaderCache **ptr)
Multiplexor for StoreOps::close.
 
struct HCacheEntry hcache_fetch_email(struct HeaderCache *hc, const char *key, size_t keylen, uint32_t uidvalidity)
Multiplexor for StoreOps::fetch.
 
int hcache_store_email(struct HeaderCache *hc, const char *key, size_t keylen, struct Email *e, uint32_t uidvalidity)
Multiplexor for StoreOps::store.
 
Header cache multiplexor.
 
Read/write command history from/to a file.
 
@ HC_OTHER
Miscellaneous strings.
 
GUI manage the main index (list of emails)
 
@ LL_DEBUG2
Log at debug level 2.
 
@ LL_DEBUG1
Log at debug level 1.
 
bool maildir_parse_message(const char *fname, bool is_old, struct Email *e)
Actually parse a maildir message.
 
struct Email * maildir_email_new(void)
Create a Maildir Email.
 
bool maildir_parse_stream(FILE *fp, const char *fname, bool is_old, struct Email *e)
Parse a Maildir message.
 
void maildir_parse_flags(struct Email *e, const char *path)
Parse Maildir file flags.
 
FILE * maildir_open_find_message(const char *folder, const char *msg, char **newname)
Find a message by name.
 
bool maildir_sync_mailbox_message(struct Mailbox *m, struct Email *e, struct HeaderCache *hc)
Save changes to the mailbox.
 
void maildir_gen_flags(char *dest, size_t destlen, struct Email *e)
Generate the Maildir flags for an email.
 
bool maildir_update_flags(struct Mailbox *m, struct Email *e_old, struct Email *e_new)
Update the mailbox flags.
 
Maildir shared functions.
 
#define MUTT_MEM_MALLOC(n, type)
 
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
 
Convenience wrapper for the library headers.
 
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
 
char * mutt_str_dup(const char *str)
Copy a string, safely.
 
int mutt_str_asprintf(char **strp, const char *fmt,...)
 
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
 
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
 
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
 
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
 
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
 
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
 
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
 
Many unsorted constants and some structs.
 
#define MUTT_COMP_NO_FLAGS
No flags are set.
 
@ MUTT_READ
Messages that have been read.
 
@ MUTT_FLAG
Flagged messages.
 
@ MUTT_REPLIED
Messages that have been replied to.
 
struct HashTable * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
 
Create/manipulate threading in emails.
 
void mx_alloc_memory(struct Mailbox *m, int req_size)
Create storage for the emails.
 
bool mx_mbox_ac_link(struct Mailbox *m)
Link a Mailbox to an existing or new Account.
 
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
 
MxOpenReturns
Return values for mbox_open()
 
@ MX_OPEN_ERROR
Open failed with an error.
 
@ MX_OPEN_ABORT
Open was aborted.
 
@ MX_OPEN_OK
Open succeeded.
 
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
 
@ MX_STATUS_ERROR
An error occurred.
 
@ MX_STATUS_OK
No changes.
 
@ MX_STATUS_FLAGS
Nondestructive flags change (IMAP)
 
@ MX_STATUS_REOPENED
Mailbox was reopened.
 
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
 
struct NmAccountData * nm_adata_new(void)
Allocate and initialise a new NmAccountData structure.
 
Notmuch-specific Account data.
 
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
 
notmuch_database_t * nm_db_get(struct Mailbox *m, bool writable)
Get the Notmuch database.
 
int nm_db_trans_begin(struct Mailbox *m)
Start a Notmuch database transaction.
 
notmuch_database_t * nm_db_do_open(const char *filename, bool writable, bool verbose)
Open a Notmuch database.
 
const char * nm_db_get_filename(struct Mailbox *m)
Get the filename of the Notmuch database.
 
int nm_db_get_mtime(struct Mailbox *m, time_t *mtime)
Get the database modification time.
 
int nm_db_release(struct Mailbox *m)
Close the Notmuch database.
 
void nm_db_free(notmuch_database_t *db)
Decoupled way to close a Notmuch database.
 
int nm_db_trans_end(struct Mailbox *m)
End a database transaction.
 
struct NmEmailData * nm_edata_get(struct Email *e)
Get the Notmuch Email data.
 
struct NmEmailData * nm_edata_new(void)
Create a new NmEmailData for an email.
 
Notmuch-specific Email data.
 
Notmuch virtual mailbox type.
 
struct NmMboxData * nm_mdata_new(const char *url)
Create a new NmMboxData object from a query.
 
struct NmMboxData * nm_mdata_get(struct Mailbox *m)
Get the Notmuch Mailbox data.
 
Notmuch-specific Mailbox data.
 
static notmuch_threads_t * get_threads(notmuch_query_t *query)
Load threads for a query.
 
static char * get_query_string(struct NmMboxData *mdata, bool window)
Builds the notmuch vfolder search string.
 
static char * nm_get_default_url(void)
Create a Mailbox with default Notmuch settings.
 
int nm_update_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Change the filename.
 
void nm_query_window_reset(void)
Resets the vfolder window position to the present.
 
static char * email_get_id(struct Email *e)
Get the unique Notmuch Id.
 
static void apply_exclude_tags(notmuch_query_t *query)
Exclude the configured tags.
 
static char * email_get_fullpath(struct Email *e, char *buf, size_t buflen)
Get the full path of an email.
 
static bool windowed_query_from_query(const char *query, char *buf, size_t buflen)
Transforms a vfolder search query into a windowed one.
 
int nm_get_all_tags(struct Mailbox *m, const char **tag_list, int *tag_count)
Fill a list with all notmuch tags.
 
static unsigned int count_query(notmuch_database_t *db, const char *qstr, int limit)
Count the results of a query.
 
static int init_mailbox(struct Mailbox *m)
Add Notmuch data to the Mailbox.
 
static int rename_maildir_filename(const char *old, char *buf, size_t buflen, struct Email *e)
Rename a Maildir file.
 
static void sync_email_path_with_nm(struct Email *e, notmuch_message_t *msg)
Synchronize Neomutt's Email path with notmuch.
 
static notmuch_message_t * get_nm_message(notmuch_database_t *db, struct Email *e)
Find a Notmuch message.
 
static int init_email(struct Email *e, const char *path, notmuch_message_t *msg)
Set up an email's Notmuch data.
 
static int get_limit(struct NmMboxData *mdata)
Get the database limit.
 
char * nm_email_get_folder_rel_db(struct Mailbox *m, struct Email *e)
Get the folder for a Email from the same level as the notmuch database.
 
static bool read_threads_query(struct Mailbox *m, notmuch_query_t *q, bool dedup, int limit)
Perform a query with threads.
 
static struct Mailbox * get_default_mailbox(void)
Get Mailbox for notmuch without any parameters.
 
int nm_record_message(struct Mailbox *m, char *path, struct Email *e)
Add a message to the Notmuch database.
 
static const struct Command NmCommands[]
Notmuch Commands.
 
static struct NmMboxData * nm_get_default_data(void)
Create a Mailbox with default Notmuch settings.
 
int nm_read_entire_thread(struct Mailbox *m, struct Email *e)
Get the entire thread of an email.
 
static void append_thread(struct HeaderCache *hc, struct Mailbox *m, notmuch_query_t *q, notmuch_thread_t *thread, bool dedup)
Add each top level reply in the thread.
 
static void query_window_reset(void)
Restore vfolder's search window to its original position.
 
const int NmUrlProtocolLen
Length of NmUrlProtocol string.
 
static int rename_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Rename the file.
 
void nm_query_window_backward(void)
Function to move the current search window backward in time.
 
static struct HeaderCache * nm_hcache_open(struct Mailbox *m)
Open a header cache.
 
static notmuch_query_t * get_query(struct Mailbox *m, bool writable)
Create a new query.
 
static int update_message_path(struct Email *e, const char *path)
Set the path for a message.
 
static bool nm_message_has_tag(notmuch_message_t *msg, const char *tag)
Does a message have this tag?
 
bool nm_query_window_available(void)
Are windowed queries enabled for use?
 
static int update_tags(notmuch_message_t *msg, const char *tag_str)
Update the tags on a message.
 
static bool read_mesgs_query(struct Mailbox *m, notmuch_query_t *q, bool dedup)
Search for matching messages.
 
static const char * get_message_last_filename(notmuch_message_t *msg)
Get a message's last filename.
 
static void append_replies(struct HeaderCache *hc, struct Mailbox *m, notmuch_query_t *q, notmuch_message_t *top, bool dedup)
Add all the replies to a given messages into the display.
 
char * nm_url_from_query(struct Mailbox *m, char *buf, size_t buflen)
Turn a query into a URL.
 
static char * get_folder_from_path(const char *path)
Find an email's folder from its path.
 
void nm_init(void)
Setup feature commands.
 
static char * nm2mutt_message_id(const char *id)
Converts notmuch message Id to neomutt message Id.
 
char * nm_email_get_folder(struct Email *e)
Get the folder for a Email.
 
static void append_message(struct HeaderCache *hc, struct Mailbox *m, notmuch_message_t *msg, bool dedup)
Associate a message.
 
static int update_email_tags(struct Email *e, notmuch_message_t *msg)
Update the Email's tags from Notmuch.
 
bool nm_message_is_still_queried(struct Mailbox *m, struct Email *e)
Is a message still visible in the query?
 
static int update_email_flags(struct Mailbox *m, struct Email *e, const char *tag_str)
Update the Email's flags.
 
static int remove_filename(struct Mailbox *m, const char *path)
Delete a file.
 
static void progress_setup(struct Mailbox *m)
Set up the Progress Bar.
 
static void nm_hcache_close(struct HeaderCache **ptr)
Close the header cache.
 
void nm_query_window_forward(void)
Function to move the current search window forward in time.
 
static notmuch_messages_t * get_messages(notmuch_query_t *query)
Load messages for a query.
 
const char NmUrlProtocol[]
Protocol string for Notmuch URLs.
 
static void nm_progress_update(struct Mailbox *m)
Update the progress counter.
 
static struct Email * get_mutt_email(struct Mailbox *m, notmuch_message_t *msg)
Get the Email of a Notmuch message.
 
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
 
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
 
@ MUTT_PROGRESS_READ
Progress tracks elements, according to $read_inc
 
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
 
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
 
void progress_free(struct Progress **ptr)
Free a Progress Bar.
 
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
 
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
 
Prototypes for many functions.
 
enum NmQueryType nm_string_to_query_type(const char *str)
Lookup a query type.
 
enum NmQueryType nm_parse_type_from_query(char *buf, enum NmQueryType fallback)
Parse a query type out of a query.
 
const char * nm_query_type_to_string(enum NmQueryType query_type)
Turn a query type into a string.
 
enum NmWindowQueryRc nm_windowed_query_from_query(char *buf, size_t buflen, const bool force_enable, const short duration, const short cur_pos, const char *cur_search, const char *timebase, const char *or_terms)
Windows buf with notmuch date: search term.
 
NmWindowQueryRc
Return codes for nm_windowed_query_from_query()
 
@ NM_WINDOW_QUERY_SUCCESS
Query was successful.
 
@ NM_WINDOW_QUERY_INVALID_DURATION
Invalid duration.
 
@ NM_WINDOW_QUERY_INVALID_TIMEBASE
Invalid timebase.
 
NmQueryType
Notmuch Query Types.
 
@ NM_QUERY_TYPE_UNKNOWN
Unknown query type. Error in notmuch query.
 
@ NM_QUERY_TYPE_THREADS
Whole threads.
 
@ NM_QUERY_TYPE_MESGS
Default: Messages only.
 
#define STAILQ_FOREACH(var, head, field)
 
volatile sig_atomic_t SigInt
true after SIGINT is received
 
A group of associated Mailboxes.
 
void(* adata_free)(void **ptr)
 
void * adata
Private data (for Mailbox backends)
 
String manipulation buffer.
 
The envelope/body of an email.
 
struct Envelope * env
Envelope information.
 
void * edata
Driver-specific data.
 
struct Body * body
List of MIME parts.
 
bool active
Message is not to be removed.
 
void * nm_edata
Notmuch private data.
 
bool old
Email is seen, but unread.
 
bool changed
Email has been edited.
 
struct TagList tags
For drivers that support server tagging.
 
char * path
Path of Email (for local Mailboxes)
 
bool deleted
Email is deleted.
 
int index
The absolute (unsorted) message number.
 
struct MuttThread * thread
Thread of Emails.
 
char * message_id
Message ID.
 
struct Email * email
Retrieved email.
 
void(* mdata_free)(void **ptr)
 
int msg_new
Number of new messages.
 
int msg_count
Total number of messages.
 
enum MailboxType type
Mailbox type.
 
void * mdata
Driver specific data.
 
struct Email ** emails
Array of Emails.
 
struct HashTable * id_hash
Hash Table: "message-id" -> Email.
 
struct Buffer pathbuf
Path of the Mailbox.
 
int msg_flagged
Number of flagged messages.
 
bool verbose
Display status messages?
 
int msg_unread
Number of unread messages.
 
A local copy of an email.
 
FILE * fp
pointer to the message data
 
Container for Accounts, Notifications.
 
struct CommandArray commands
NeoMutt commands.
 
struct ConfigSubset * sub
Inherited config items.
 
Notmuch-specific Account data -.
 
Notmuch-specific Email data -.
 
char * folder
Location of the Email.
 
char * virtual_id
Unique Notmuch Id.
 
Notmuch-specific Mailbox data -.
 
struct Url * db_url
Parsed view url of the Notmuch database.
 
struct Progress * progress
A progress bar.
 
struct timespec mtime
Time Mailbox was last changed.
 
enum NmQueryType query_type
Messages or Threads.
 
int db_limit
Maximum number of results to return.
 
char * db_query
Previous query.
 
int ignmsgcount
Ignored messages.
 
A parsed URL proto://user:password@host:port/path?a=1&b=2
 
struct UrlQueryList query_strings
List of query strings.
 
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
 
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
 
void nm_tag_array_free(struct NmTags *tags)
Free all memory of a NmTags.
 
struct NmTags nm_tag_str_to_tags(const char *tag_str)
Converts a comma and/or space-delimited string of tags into an array.
 
struct Url * url_parse(const char *src)
Fill in Url.
 
void url_free(struct Url **ptr)
Free the contents of a URL.
 
void url_pct_encode(char *buf, size_t buflen, const char *src)
Percent-encode a string.