NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference
#include <stddef.h>
#include <stdbool.h>
#include "core/lib.h"
#include "mx.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void nm_init (void)
 Setup feature commands. More...
 
void nm_db_debug_check (struct Mailbox *m)
 Check if the database is open. More...
 
void nm_db_longrun_done (struct Mailbox *m)
 Finish a long transaction. More...
 
void nm_db_longrun_init (struct Mailbox *m, bool writable)
 Start a long transaction. More...
 
char * nm_email_get_folder (struct Email *e)
 Get the folder for a Email. More...
 
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. More...
 
int nm_get_all_tags (struct Mailbox *m, char **tag_list, int *tag_count)
 Fill a list with all notmuch tags. More...
 
bool nm_message_is_still_queried (struct Mailbox *m, struct Email *e)
 Is a message still visible in the query? More...
 
void nm_parse_type_from_query (struct NmMboxData *mdata, char *buf)
 Parse a query type out of a query. More...
 
enum MailboxType nm_path_probe (const char *path, const struct stat *st)
 Is this a Notmuch Mailbox? - Implements MxOps::path_probe() More...
 
void nm_query_window_backward (void)
 Function to move the current search window backward in time. More...
 
void nm_query_window_forward (void)
 Function to move the current search window forward in time. More...
 
int nm_read_entire_thread (struct Mailbox *m, struct Email *e)
 Get the entire thread of an email. More...
 
int nm_record_message (struct Mailbox *m, char *path, struct Email *e)
 Add a message to the Notmuch database. More...
 
int nm_update_filename (struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
 Change the filename. More...
 
char * nm_url_from_query (struct Mailbox *m, char *buf, size_t buflen)
 Turn a query into a URL. More...
 

Variables

struct MxOps MxNotmuchOps
 Notmuch Mailbox - Implements MxOps. More...
 
char * C_NmQueryWindowCurrentSearch
 Config: (notmuch) Current search parameters. More...
 
int C_NmQueryWindowDuration
 Config: (notmuch) Time duration of the current search window. More...
 
char * C_VfolderFormat
 Config: (notmuch) printf-like format string for the browser's display of virtual folders. More...
 
bool C_VirtualSpoolFile
 Config: (notmuch) Use the first virtual mailbox as a spool file. More...
 

Detailed Description

Notmuch virtual mailbox type

Authors
  • Karel Zak

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Function Documentation

◆ nm_init()

void nm_init ( void  )

Setup feature commands.

Definition at line 91 of file notmuch.c.

92 {
94 }
+ Here is the caller graph for this function:

◆ nm_db_debug_check()

void nm_db_debug_check ( struct Mailbox m)

Check if the database is open.

Parameters
mMailbox

Definition at line 324 of file db.c.

325 {
326  struct NmAccountData *adata = nm_adata_get(m);
327  if (!adata || !adata->db)
328  return;
329 
330  mutt_debug(LL_DEBUG1, "nm: ERROR: db is open, closing\n");
331  nm_db_release(m);
332 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_longrun_done()

void nm_db_longrun_done ( struct Mailbox m)

Finish a long transaction.

Parameters
mMailbox

Definition at line 306 of file db.c.

307 {
308  struct NmAccountData *adata = nm_adata_get(m);
309 
310  if (adata)
311  {
312  adata->longrun = false; /* to force nm_db_release() released DB */
313  if (nm_db_release(m) == 0)
314  mutt_debug(LL_DEBUG2, "nm: long run deinitialized\n");
315  else
316  adata->longrun = true;
317  }
318 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_db_longrun_init()

void nm_db_longrun_init ( struct Mailbox m,
bool  writable 
)

Start a long transaction.

Parameters
mMailbox
writableRead/write?

Definition at line 291 of file db.c.

292 {
293  struct NmAccountData *adata = nm_adata_get(m);
294 
295  if (!(adata && nm_db_get(m, writable)))
296  return;
297 
298  adata->longrun = true;
299  mutt_debug(LL_DEBUG2, "nm: long run initialized\n");
300 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_email_get_folder()

char* nm_email_get_folder ( struct Email e)

Get the folder for a Email.

Parameters
eEmail
Return values
ptrFolder containing email
NULLError

Definition at line 1539 of file notmuch.c.

1540 {
1541  struct NmEmailData *edata = nm_edata_get(e);
1542  if (!edata)
1543  return NULL;
1544 
1545  return edata->folder;
1546 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_email_get_folder_rel_db()

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.

Parameters
mMailbox containing Email
eEmail
Return values
ptrFolder containing email from the same level as the notmuch db
NULLError

Instead of returning a path like /var/mail/account/Inbox, this returns account/Inbox. If wanting the full path, use nm_email_get_folder().

Definition at line 1558 of file notmuch.c.

1559 {
1560  char *full_folder = nm_email_get_folder(e);
1561  if (!full_folder)
1562  return NULL;
1563 
1564  const char *db_path = nm_db_get_filename(m);
1565  if (!db_path)
1566  return NULL;
1567 
1568  return full_folder + strlen(db_path);
1569 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_get_all_tags()

int nm_get_all_tags ( struct Mailbox m,
char **  tag_list,
int *  tag_count 
)

Fill a list with all notmuch tags.

Parameters
[in]mMailbox
[out]tag_listList of tags
[out]tag_countNumber of tags
Return values
0Success
-1Failure

If tag_list is NULL, just count the tags.

Definition at line 2046 of file notmuch.c.

2047 {
2048  struct NmMboxData *mdata = nm_mdata_get(m);
2049  if (!mdata)
2050  return -1;
2051 
2052  notmuch_database_t *db = NULL;
2053  notmuch_tags_t *tags = NULL;
2054  const char *tag = NULL;
2055  int rc = -1;
2056 
2057  if (!(db = nm_db_get(m, false)) || !(tags = notmuch_database_get_all_tags(db)))
2058  goto done;
2059 
2060  *tag_count = 0;
2061  mutt_debug(LL_DEBUG1, "nm: get all tags\n");
2062 
2063  while (notmuch_tags_valid(tags))
2064  {
2065  tag = notmuch_tags_get(tags);
2066  /* Skip empty string */
2067  if (*tag)
2068  {
2069  if (tag_list)
2070  tag_list[*tag_count] = mutt_str_dup(tag);
2071  (*tag_count)++;
2072  }
2073  notmuch_tags_move_to_next(tags);
2074  }
2075 
2076  rc = 0;
2077 done:
2078  if (tags)
2079  notmuch_tags_destroy(tags);
2080 
2081  nm_db_release(m);
2082 
2083  mutt_debug(LL_DEBUG1, "nm: get all tags done [rc=%d tag_count=%u]\n", rc, *tag_count);
2084  return rc;
2085 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_message_is_still_queried()

bool nm_message_is_still_queried ( struct Mailbox m,
struct Email e 
)

Is a message still visible in the query?

Parameters
mMailbox
eEmail
Return values
trueMessage is still in query

Definition at line 1766 of file notmuch.c.

1767 {
1768  struct NmMboxData *mdata = nm_mdata_get(m);
1769  notmuch_database_t *db = nm_db_get(m, false);
1770  char *orig_str = get_query_string(mdata, true);
1771 
1772  if (!db || !orig_str)
1773  return false;
1774 
1775  char *new_str = NULL;
1776  bool rc = false;
1777  if (mutt_str_asprintf(&new_str, "id:%s and (%s)", email_get_id(e), orig_str) < 0)
1778  return false;
1779 
1780  mutt_debug(LL_DEBUG2, "nm: checking if message is still queried: %s\n", new_str);
1781 
1782  notmuch_query_t *q = notmuch_query_create(db, new_str);
1783 
1784  switch (mdata->query_type)
1785  {
1786  case NM_QUERY_TYPE_MESGS:
1787  {
1788  notmuch_messages_t *messages = get_messages(q);
1789 
1790  if (!messages)
1791  return false;
1792 
1793  rc = notmuch_messages_valid(messages);
1794  notmuch_messages_destroy(messages);
1795  break;
1796  }
1797  case NM_QUERY_TYPE_THREADS:
1798  {
1799  notmuch_threads_t *threads = get_threads(q);
1800 
1801  if (!threads)
1802  return false;
1803 
1804  rc = notmuch_threads_valid(threads);
1805  notmuch_threads_destroy(threads);
1806  break;
1807  }
1808  }
1809 
1810  notmuch_query_destroy(q);
1811 
1812  mutt_debug(LL_DEBUG2, "nm: checking if message is still queried: %s = %s\n",
1813  new_str, rc ? "true" : "false");
1814 
1815  return rc;
1816 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_parse_type_from_query()

void nm_parse_type_from_query ( struct NmMboxData mdata,
char *  buf 
)

Parse a query type out of a query.

Parameters
mdataMailbox, used for the query_type
bufBuffer for URL

If a user writes a query for a vfolder and includes a type= statement, that type= will be encoded, which Notmuch will treat as part of the query= statement. This method will remove the type= and set it within the Mailbox struct.

Definition at line 1646 of file notmuch.c.

1647 {
1648  if (!buf)
1649  return;
1650 
1651  // The six variations of how type= could appear.
1652  const char *variants[6] = { "&type=threads", "&type=messages",
1653  "type=threads&", "type=messages&",
1654  "type=threads", "type=messages" };
1655 
1656  int variants_size = mutt_array_size(variants);
1657  for (int i = 0; i < variants_size; i++)
1658  {
1659  if (strcasestr(buf, variants[i]) != NULL)
1660  {
1661  // variants[] is setup such that type can be determined via modulo 2.
1662  mdata->query_type = ((i % 2) == 0) ? NM_QUERY_TYPE_THREADS : NM_QUERY_TYPE_MESGS;
1663 
1664  mutt_istr_remall(buf, variants[i]);
1665  }
1666  }
1667 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_path_probe()

enum MailboxType nm_path_probe ( const char *  path,
const struct stat *  st 
)

Is this a Notmuch Mailbox? - Implements MxOps::path_probe()

Definition at line 2522 of file notmuch.c.

2523 {
2524  if (!mutt_istr_startswith(path, NmUrlProtocol))
2525  return MUTT_UNKNOWN;
2526 
2527  return MUTT_NOTMUCH;
2528 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_query_window_backward()

void nm_query_window_backward ( void  )

Function to move the current search window backward in time.

Updates nm_query_window_current_position by incrementing it by 1

The higher the value of nm_query_window_current_position is, the less recent the result will be.

Definition at line 1754 of file notmuch.c.

+ Here is the caller graph for this function:

◆ nm_query_window_forward()

void nm_query_window_forward ( void  )

Function to move the current search window forward in time.

Updates nm_query_window_current_position by decrementing it by 1, or does nothing if the current window already is set to 0.

The lower the value of nm_query_window_current_position is, the more recent the result will be.

Definition at line 1738 of file notmuch.c.

1739 {
1742 
1744 }
+ Here is the caller graph for this function:

◆ nm_read_entire_thread()

int nm_read_entire_thread ( struct Mailbox m,
struct Email e 
)

Get the entire thread of an email.

Parameters
mMailbox
eEmail
Return values
0Success
-1Failure

Definition at line 1578 of file notmuch.c.

1579 {
1580  if (!m)
1581  return -1;
1582 
1583  struct NmMboxData *mdata = nm_mdata_get(m);
1584  if (!mdata)
1585  return -1;
1586 
1587  notmuch_query_t *q = NULL;
1588  notmuch_database_t *db = NULL;
1589  notmuch_message_t *msg = NULL;
1590  int rc = -1;
1591 
1592  if (!(db = nm_db_get(m, false)) || !(msg = get_nm_message(db, e)))
1593  goto done;
1594 
1595  mutt_debug(LL_DEBUG1, "nm: reading entire-thread messages...[current count=%d]\n",
1596  m->msg_count);
1597 
1598  progress_reset(m);
1599  const char *id = notmuch_message_get_thread_id(msg);
1600  if (!id)
1601  goto done;
1602 
1603  char *qstr = NULL;
1604  mutt_str_append_item(&qstr, "thread:", '\0');
1605  mutt_str_append_item(&qstr, id, '\0');
1606 
1607  q = notmuch_query_create(db, qstr);
1608  FREE(&qstr);
1609  if (!q)
1610  goto done;
1611  apply_exclude_tags(q);
1612  notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST);
1613 
1614  read_threads_query(m, q, true, 0);
1615  m->mtime.tv_sec = mutt_date_epoch();
1616  m->mtime.tv_nsec = 0;
1617  rc = 0;
1618 
1619  if (m->msg_count > mdata->oldmsgcount)
1621 done:
1622  if (q)
1623  notmuch_query_destroy(q);
1624 
1625  nm_db_release(m);
1626 
1627  if (m->msg_count == mdata->oldmsgcount)
1628  mutt_message(_("No more messages in the thread"));
1629 
1630  mdata->oldmsgcount = 0;
1631  mutt_debug(LL_DEBUG1, "nm: reading entire-thread messages... done [rc=%d, count=%d]\n",
1632  rc, m->msg_count);
1633  return rc;
1634 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_record_message()

int nm_record_message ( struct Mailbox m,
char *  path,
struct Email e 
)

Add a message to the Notmuch database.

Parameters
mMailbox
pathPath of the email
eEmail
Return values
0Success
-1Failure

Definition at line 1965 of file notmuch.c.

1966 {
1967  notmuch_database_t *db = NULL;
1968  notmuch_status_t st;
1969  notmuch_message_t *msg = NULL;
1970  int rc = -1;
1971 
1972  struct NmMboxData *mdata = nm_mdata_get(m);
1973 
1974  // If no notmuch data, fall back to the default mailbox.
1975  //
1976  // IMPORTANT: DO NOT FREE THIS MAILBOX. Two reasons:
1977  // 1) If user has default mailbox in config, we'll be removing it. That's not
1978  // good program behavior!
1979  // 2) If not in user's config, keep mailbox around for future nm_record calls.
1980  // It saves NeoMutt from allocating/deallocating repeatedly.
1981  if (!mdata)
1982  {
1983  mutt_debug(LL_DEBUG1, "nm: non-nm mailbox. trying the default nm mailbox.");
1984  m = get_default_mailbox();
1985  mdata = nm_mdata_get(m);
1986  }
1987 
1988  if (!path || !mdata || (access(path, F_OK) != 0))
1989  return 0;
1990  db = nm_db_get(m, true);
1991  if (!db)
1992  return -1;
1993 
1994  mutt_debug(LL_DEBUG1, "nm: record message: %s\n", path);
1995  int trans = nm_db_trans_begin(m);
1996  if (trans < 0)
1997  goto done;
1998 
1999 #ifdef HAVE_NOTMUCH_DATABASE_INDEX_FILE
2000  st = notmuch_database_index_file(db, path, NULL, &msg);
2001 #else
2002  st = notmuch_database_add_message(db, path, &msg);
2003 #endif
2004 
2005  if ((st != NOTMUCH_STATUS_SUCCESS) && (st != NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID))
2006  {
2007  mutt_debug(LL_DEBUG1, "nm: failed to add '%s' [st=%d]\n", path, (int) st);
2008  goto done;
2009  }
2010 
2011  if ((st == NOTMUCH_STATUS_SUCCESS) && msg)
2012  {
2013  notmuch_message_maildir_flags_to_tags(msg);
2014  if (e)
2015  {
2016  char *tags = driver_tags_get(&e->tags);
2017  update_tags(msg, tags);
2018  FREE(&tags);
2019  }
2020  if (C_NmRecordTags)
2022  }
2023 
2024  rc = 0;
2025 done:
2026  if (msg)
2027  notmuch_message_destroy(msg);
2028  if (trans == 1)
2029  nm_db_trans_end(m);
2030 
2031  nm_db_release(m);
2032 
2033  return rc;
2034 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_update_filename()

int nm_update_filename ( struct Mailbox m,
const char *  old_file,
const char *  new_file,
struct Email e 
)

Change the filename.

Parameters
mMailbox
old_fileOld filename
new_fileNew filename
eEmail
Return values
0Success
-1Failure

Definition at line 1827 of file notmuch.c.

1829 {
1830  char buf[PATH_MAX];
1831  struct NmMboxData *mdata = nm_mdata_get(m);
1832  if (!mdata || !new_file)
1833  return -1;
1834 
1835  if (!old_file && nm_edata_get(e))
1836  {
1837  email_get_fullpath(e, buf, sizeof(buf));
1838  old_file = buf;
1839  }
1840 
1841  int rc = rename_filename(m, old_file, new_file, e);
1842 
1843  nm_db_release(m);
1844  m->mtime.tv_sec = mutt_date_epoch();
1845  m->mtime.tv_nsec = 0;
1846  return rc;
1847 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nm_url_from_query()

char* nm_url_from_query ( struct Mailbox m,
char *  buf,
size_t  buflen 
)

Turn a query into a URL.

Parameters
mMailbox
bufBuffer for URL
buflenLength of buffer
Return values
ptrQuery as a URL
NULLError

Definition at line 1677 of file notmuch.c.

1678 {
1679  mutt_debug(LL_DEBUG2, "(%s)\n", buf);
1680  struct NmMboxData *mdata = nm_mdata_get(m);
1681  char url[PATH_MAX + 1024 + 32]; /* path to DB + query + URL "decoration" */
1682  int added;
1683  bool using_default_data = false;
1684 
1685  // No existing data. Try to get a default NmMboxData.
1686  if (!mdata)
1687  {
1689 
1690  // Failed to get default data.
1691  if (!mdata)
1692  return NULL;
1693 
1694  using_default_data = true;
1695  }
1696 
1698 
1699  if (get_limit(mdata) == C_NmDbLimit)
1700  {
1701  added = snprintf(url, sizeof(url), "%s%s?type=%s&query=", NmUrlProtocol,
1702  nm_db_get_filename(m), query_type_to_string(mdata->query_type));
1703  }
1704  else
1705  {
1706  added = snprintf(url, sizeof(url), "%s%s?type=%s&limit=%d&query=", NmUrlProtocol,
1707  nm_db_get_filename(m),
1708  query_type_to_string(mdata->query_type), get_limit(mdata));
1709  }
1710 
1711  if (added >= sizeof(url))
1712  {
1713  // snprintf output was truncated, so can't create URL
1714  return NULL;
1715  }
1716 
1717  url_pct_encode(&url[added], sizeof(url) - added, buf);
1718 
1719  mutt_str_copy(buf, url, buflen);
1720  buf[buflen - 1] = '\0';
1721 
1722  if (using_default_data)
1723  nm_mdata_free((void **) &mdata);
1724 
1725  mutt_debug(LL_DEBUG1, "nm: url from query '%s'\n", buf);
1726  return buf;
1727 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MxNotmuchOps

struct MxOps MxNotmuchOps

Notmuch Mailbox - Implements MxOps.

Definition at line 2560 of file notmuch.c.

◆ C_NmQueryWindowCurrentSearch

char* C_NmQueryWindowCurrentSearch

Config: (notmuch) Current search parameters.

Definition at line 44 of file config.c.

◆ C_NmQueryWindowDuration

int C_NmQueryWindowDuration

Config: (notmuch) Time duration of the current search window.

Definition at line 45 of file config.c.

◆ C_VfolderFormat

char* C_VfolderFormat

Config: (notmuch) printf-like format string for the browser's display of virtual folders.

Definition at line 50 of file config.c.

◆ C_VirtualSpoolFile

bool C_VirtualSpoolFile

Config: (notmuch) Use the first virtual mailbox as a spool file.

Definition at line 51 of file config.c.

mutt_str_append_item
void mutt_str_append_item(char **str, const char *item, char sep)
Add string to another separated by sep.
Definition: string.c:466
update_tags
static int update_tags(notmuch_message_t *msg, const char *tags)
Update the tags on a message.
Definition: notmuch.c:1154
C_NmQueryWindowCurrentPosition
int C_NmQueryWindowCurrentPosition
Config: (notmuch) Position of current search window.
Definition: config.c:43
nm_db_trans_begin
int nm_db_trans_begin(struct Mailbox *m)
Start a Notmuch database transaction.
Definition: db.c:206
_
#define _(a)
Definition: message.h:28
NT_MAILBOX_INVALID
@ NT_MAILBOX_INVALID
Email list was changed.
Definition: mailbox.h:173
get_default_mailbox
static struct Mailbox * get_default_mailbox(void)
Get Mailbox for notmuch without any parameters.
Definition: notmuch.c:1942
nm_db_get_filename
const char * nm_db_get_filename(struct Mailbox *m)
Get the filename of the Notmuch database.
Definition: db.c:55
mutt_istr_remall
int mutt_istr_remall(char *str, const char *target)
Remove all occurrences of substring, ignoring case.
Definition: string.c:1037
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
FREE
#define FREE(x)
Definition: memory.h:40
get_threads
static notmuch_threads_t * get_threads(notmuch_query_t *query)
load threads for a query
Definition: notmuch.c:1032
PATH_MAX
#define PATH_MAX
Definition: mutt.h:44
nm_mdata_get
struct NmMboxData * nm_mdata_get(struct Mailbox *m)
Get the Notmuch Mailbox data.
Definition: mdata.c:89
query_type_to_string
static const char * query_type_to_string(enum NmQueryType query_type)
Turn a query type into a string.
Definition: notmuch.c:242
nm_adata_get
struct NmAccountData * nm_adata_get(struct Mailbox *m)
Get the Notmuch Account data.
Definition: adata.c:69
get_limit
static int get_limit(struct NmMboxData *mdata)
Get the database limit.
Definition: notmuch.c:441
mutt_array_size
#define mutt_array_size(x)
Definition: memory.h:33
timespec::tv_nsec
long tv_nsec
Definition: file.h:52
email_get_id
static char * email_get_id(struct Email *e)
Get the unique Notmuch Id.
Definition: notmuch.c:213
nm_parse_type_from_query
void nm_parse_type_from_query(struct NmMboxData *mdata, char *buf)
Parse a query type out of a query.
Definition: notmuch.c:1646
url_pct_encode
void url_pct_encode(char *buf, size_t buflen, const char *src)
Percent-encode a string.
Definition: url.c:151
rename_filename
static int rename_filename(struct Mailbox *m, const char *old_file, const char *new_file, struct Email *e)
Rename the file.
Definition: notmuch.c:1402
timespec::tv_sec
time_t tv_sec
Definition: file.h:51
get_query_string
static char * get_query_string(struct NmMboxData *mdata, bool window)
builds the notmuch vfolder search string
Definition: notmuch.c:383
Mailbox::mdata
void * mdata
Driver specific data.
Definition: mailbox.h:136
get_nm_message
static notmuch_message_t * get_nm_message(notmuch_database_t *db, struct Email *e)
Find a Notmuch message.
Definition: notmuch.c:1096
nm_email_get_folder
char * nm_email_get_folder(struct Email *e)
Get the folder for a Email.
Definition: notmuch.c:1539
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
C_NmRecordTags
char * C_NmRecordTags
Config: (notmuch) Tags to apply to the 'record' mailbox (sent mail)
Definition: config.c:47
Mailbox::mtime
struct timespec mtime
Time Mailbox was last changed.
Definition: mailbox.h:107
MUTT_UNKNOWN
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:47
NmAccountData
Notmuch-specific Account data -.
Definition: adata.h:34
MUTT_NOTMUCH
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:54
C_NmDbLimit
int C_NmDbLimit
Config: (notmuch) Default limit for Notmuch queries.
Definition: config.c:37
NM_QUERY_TYPE_THREADS
@ NM_QUERY_TYPE_THREADS
Whole threads.
Definition: private.h:53
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
get_messages
static notmuch_messages_t * get_messages(notmuch_query_t *query)
load messages for a query
Definition: notmuch.c:962
nm_db_trans_end
int nm_db_trans_end(struct Mailbox *m)
End a database transaction.
Definition: db.c:228
nm_db_release
int nm_db_release(struct Mailbox *m)
Close the Notmuch database.
Definition: db.c:173
mutt_date_epoch
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
NmUrlProtocol
const char NmUrlProtocol[]
Definition: notmuch.c:85
nm_commands
static const struct Command nm_commands[]
Definition: notmuch.c:78
nm_db_get
notmuch_database_t * nm_db_get(struct Mailbox *m, bool writable)
Get the Notmuch database.
Definition: db.c:149
nm_mdata_free
void nm_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free()
Definition: mdata.c:41
nm_edata_get
struct NmEmailData * nm_edata_get(struct Email *e)
Get the Notmuch Email data.
Definition: edata.c:71
Email::edata
void * edata
Driver-specific data.
Definition: email.h:111
driver_tags_get
char * driver_tags_get(struct TagList *list)
Get tags.
Definition: tags.c:144
Email::tags
struct TagList tags
For drivers that support server tagging.
Definition: email.h:109
apply_exclude_tags
static void apply_exclude_tags(notmuch_query_t *query)
Exclude the configured tags.
Definition: notmuch.c:450
mutt_istr_startswith
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:172
NM_QUERY_TYPE_MESGS
@ NM_QUERY_TYPE_MESGS
Default: Messages only.
Definition: private.h:52
mailbox_changed
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition: mailbox.c:186
Account::adata
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
NmMboxData
Notmuch-specific Mailbox data -.
Definition: mdata.h:35
NmEmailData
Notmuch-specific Email data -.
Definition: edata.h:33
nm_get_default_data
static struct NmMboxData * nm_get_default_data(void)
Create a Mailbox with default Notmuch settings.
Definition: notmuch.c:168
mutt_message
#define mutt_message(...)
Definition: logging.h:83
mutt_str_asprintf
int mutt_str_asprintf(char **strp, const char *fmt,...)
Definition: string.c:1095
read_threads_query
static bool read_threads_query(struct Mailbox *m, notmuch_query_t *q, bool dedup, int limit)
Perform a query with threads.
Definition: notmuch.c:1060
COMMANDS_REGISTER
#define COMMANDS_REGISTER(cmds)
Definition: mutt_commands.h:77
email_get_fullpath
static char * email_get_fullpath(struct Email *e, char *buf, size_t buflen)
Get the full path of an email.
Definition: notmuch.c:229
LL_DEBUG2
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41
progress_reset
static void progress_reset(struct Mailbox *m)
Reset the progress counter.
Definition: notmuch.c:718
mutt_str_copy
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:716