Notmuch query functions. More...
#include <stdbool.h>#include <stddef.h>
Include dependency graph for query.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Enumerations | |
| enum | NmQueryType { NM_QUERY_TYPE_UNKNOWN = 0 , NM_QUERY_TYPE_MESSAGES , NM_QUERY_TYPE_THREADS } |
| Notmuch Query Types. More... | |
| enum | NmTimebase { NMTB_UNKNOWN = 0 , NMTB_HOUR , NMTB_DAY , NMTB_WEEK , NMTB_MONTH , NMTB_YEAR } |
| Time periods for notmuch windowed queries. More... | |
| enum | NmWindowQueryRc { NM_WINDOW_QUERY_SUCCESS = 1 , NM_WINDOW_QUERY_INVALID_TIMEBASE , NM_WINDOW_QUERY_INVALID_DURATION } |
| Return codes for nm_windowed_query_from_query() More... | |
Functions | |
| enum NmQueryType | nm_parse_type_from_query (char *buf, enum NmQueryType fallback) |
| Parse a query type out of a query. | |
| enum NmQueryType | nm_string_to_query_type (const char *str) |
| Lookup a query type. | |
| enum NmQueryType | nm_string_to_query_type_mapper (const char *str) |
| Lookup a query type. | |
| 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 current_pos, const char *current_search, enum NmTimebase timebase, const char *or_terms) |
Windows buf with notmuch date: search term. | |
Variables | |
| const struct EnumDef | NmQueryWindowTimebaseDef |
Data for the $nm_query_window_timebase enumeration. | |
| const struct EnumDef | NmQueryTypeDef |
Data for the $nm_query_type enumeration. | |
Notmuch query functions.
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 query.h.
| enum NmQueryType |
Notmuch Query Types.
Read whole-thread or matching messages only?
| Enumerator | |
|---|---|
| NM_QUERY_TYPE_UNKNOWN | Unknown query type. Error in notmuch query. |
| NM_QUERY_TYPE_MESSAGES | Default: Messages only. |
| NM_QUERY_TYPE_THREADS | Whole threads. |
Definition at line 36 of file query.h.
| enum NmTimebase |
Time periods for notmuch windowed queries.
| Enumerator | |
|---|---|
| NMTB_UNKNOWN | Unknown timebase. |
| NMTB_HOUR | Hours. |
| NMTB_DAY | Days. |
| NMTB_WEEK | Weeks. |
| NMTB_MONTH | Months. |
| NMTB_YEAR | Years. |
| enum NmWindowQueryRc |
Return codes for nm_windowed_query_from_query()
| Enumerator | |
|---|---|
| NM_WINDOW_QUERY_SUCCESS | Query was successful. |
| NM_WINDOW_QUERY_INVALID_TIMEBASE | Invalid timebase. |
| NM_WINDOW_QUERY_INVALID_DURATION | Invalid duration. |
Definition at line 59 of file query.h.
| enum NmQueryType nm_parse_type_from_query | ( | char * | buf, |
| enum NmQueryType | fallback ) |
Parse a query type out of a query.
| buf | Buffer for URL |
| fallback | Fallback query type if buf doesn't contain a type= statement |
| enum | NmQueryType, Notmuch query type |
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 return its corresponding NmQueryType representation.
Definition at line 90 of file query.c.
Here is the call graph for this function:
Here is the caller graph for this function:| enum NmQueryType nm_string_to_query_type | ( | const char * | str | ) |
Lookup a query type.
| str | String to lookup |
| enum | NmQueryType, e.g. NM_QUERY_TYPE_MESSAGES |
If there's an unknown query type, default to NM_QUERY_TYPE_MESSAGES.
Definition at line 150 of file query.c.
Here is the call graph for this function:
Here is the caller graph for this function:| enum NmQueryType nm_string_to_query_type_mapper | ( | const char * | str | ) |
Lookup a query type.
| str | String to lookup |
| num | Query type |
| NM_QUERY_TYPE_UNKNOWN | on error |
Definition at line 169 of file query.c.
Here is the call graph for this function:
Here is the caller graph for this function:| const char * nm_query_type_to_string | ( | enum NmQueryType | query_type | ) |
Turn a query type into a string.
| query_type | Query type |
| ptr | String |
Definition at line 137 of file query.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 enum NmTimebase | timebase, | ||
| const char * | or_terms ) |
Windows buf with notmuch date: search term.
| [out] | buf | allocated string buffer to receive the modified search query |
| [in] | buflen | allocated maximum size of the buf string buffer |
| [in] | force_enable | Enables windowing for duration=0 |
| [in] | duration | Duration of time between beginning and end for notmuch date search term |
| [in] | cur_pos | Current position of vfolder window |
| [in] | cur_search | Current notmuch search |
| [in] | timebase | Timebase for date: search term |
| [in] | or_terms | Additional notmuch search terms |
| NM_WINDOW_QUERY_SUCCESS | Prepended buf with date: search term |
| NM_WINDOW_QUERY_INVALID_DURATION | Duration out-of-range for search term. buf not prepended with date: |
| NM_WINDOW_QUERY_INVALID_TIMEBASE | Timebase isn't one of hour, day, week, month, or year |
This is where the magic of windowed queries happens. Taking a vfolder search query string as parameter, it will use the following two user settings:
duration andtimebaseto amend given vfolder search window. Then using a third parameter:
cur_posit will generate a proper notmuch date: parameter. For example, given a duration of 2, a timebase set to week and a position defaulting to 0, it will prepend to the 'tag:inbox' notmuch search query the following string:
query: tag:inboxbuf: date:2week..now and tag:inboxIf the position is set to 4, with duration=3 and timebase=month:
query: tag:archivedbuf: date:12month..9month and tag:archivedThe window won't be applied:
0 this function will be disabled unless a user explicitly enables windowed queries. This returns NM_WINDOW_QUERY_INVALID_DURATIONDefinition at line 220 of file query.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
extern |
|
extern |
Data for the $nm_query_type enumeration.