summaryrefslogtreecommitdiffstats
path: root/notmuch-search.c
AgeCommit message (Collapse)Author
2020-07-18cli/search: replace deprecated notmuch_message_get_flagDavid Bremner
Our handling of errors is all or nothing here, but it's an improvement on the status quo, and it avoids rippling internal API changes.
2019-06-14cli: run uncrustifyuncrustify
This is the result of running $ uncrustify --replace --config devel/uncrustify.cfg *.c *.h in the top level source directory
2019-06-14CLI: replace some constructs with more uncrustify friendly onesDavid Bremner
In particular - use (bool) instead of !! - cuddle the opening parens of function calls - add parens in some ternery operators
2019-05-03gmime-cleanup: pass NULL arguments explicitly where GMime 3.0 expects itDaniel Kahn Gillmor
Several GMime 2.6 functions sprouted a change in the argument order in GMime 3.0. We had a compatibility layer here to be able to handle compiling against both GMime 2.6 and 3.0. Now that we're using 3.0 only, rip out the compatibility layer for those functions with changed argument lists, and explicitly use the 3.0 argument lists. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2017-12-14cli: add support for only printing the addresses in notmuch addressJani Nikula
The notmuch address output is much more useful for scripts with just the addresses printed. Support this using the --output=address option.
2017-10-09cli: convert notmuch_bool_t to stdboolJani Nikula
C99 stdbool turned 18 this year. There really is no reason to use our own, except in the library interface for backward compatibility. Convert the cli and test binaries to stdbool.
2017-10-04cli: use designated initializers for opt descJani Nikula
Several changes at once, just to not have to change the same lines several times over: - Use designated initializers to initialize opt desc arrays. - Only initialize the needed fields. - Remove arg_id (short options) as unused. - Replace opt_type and output_var with several type safe output variables, where the output variable being non-NULL determines the type. Introduce checks to ensure only one is set. The downside is some waste of const space per argument; this could be saved by retaining opt_type and using a union, but that's still pretty verbose. - Fix some variables due to the type safety. Mostly a good thing, but leads to some enums being changed to ints. This is pedantically correct, but somewhat annoying. We could also cast, but that defeats the purpose a bit. - Terminate the opt desc arrays using {}. The output variable type safety and the ability to add new fields for just some output types or arguments are the big wins. For example, if we wanted to add a variable to set when the argument is present, we could do so for just the arguments that need it. Beauty is in the eye of the beholder, but I think this looks nice when defining the arguments, and reduces some of the verbosity we have there.
2017-08-01cli/search: print total number of files matched in summary output.David Bremner
The structured output formats already have all of the filenames. This is an easy bit of UI change to make the multiple files visible.
2017-03-22lib: make notmuch_query_add_tag_exclude return a status valueDavid Bremner
Since this is an ABI breaking change, but we already bumped the SONAME for the next release
2017-03-22lib: replace deprecated n_q_count_threads with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2017-03-22lib: replace deprecated n_q_count_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name. One or two remaining uses of the (removed) non-status returning version fixed at the same time
2017-03-22lib: replace deprecated n_q_search_messages with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We re-use the name for a status returning version, and deprecate the _st name.
2017-03-22lib: replace n_query_search_threads with status returning versionDavid Bremner
This function was deprecated in notmuch 0.21. We finally remove the deprecated API, and rename the status returning version to the simpler name. The status returning is kept as a deprecated alias.
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2015-10-05cli: update to use new count APIDavid Bremner
Essentially replace each call to notmuch_count_* with the corresponding _st call, followed by print_status_query.
2015-09-26cli: do not sort addresses on --output=count or --deduplicate=addressJani Nikula
The order of the results with --output=count and --deduplicate=address are unspecified as they're based on a hash table traversal. This being the case, optimize the query by explicitly requesting unsorted results. Clarify the documentation accordingly.
2015-09-26cli: add support for deduplicating based on case insensitive addressJani Nikula
Consider all variants of an email address as one, and print the most common variant.
2015-09-26cli: change the data structure for notmuch address deduplicationJani Nikula
Currently we key the address hash table with the case sensitive "name <address>". Switch to case insensitive keying with just address, and store the case sensitive name and address in linked lists. This will be helpful in adding support for different deduplication schemes in the future. There will be a slight performance penalty for the current full case sensitive name + address deduplication, but this is simpler as a whole when other deduplication schemes are added, and I expect the schemes to be added to become more popular than the current default. Aparet from the possible performance penalty, the only user visible change should be the change in the output ordering for --output=count. The order is not guaranteed (and is based on hash table traversal) currently anyway, so this should be of no consequence.
2015-09-24cli: add support for not deduplicating notmuch address resultsJani Nikula
Make it possible to use notmuch address as part of a | sort | uniq -c pipe instead of forcing --output=count. This is useful for combining results from multiple notmuch address queries.
2015-09-23cli: convert remainder of CLI to n_q_search_{messages,threads}_stDavid Bremner
I think it would be no real problem to cut and paste the gdb based error message test from count to the other clients modified here, but I'm not currently convinced it's worth the trouble since the code path being tested is almost the the same, and the tests are relatively heavyweight.
2015-09-07cli: abstract new mailbox creationJani Nikula
We'll be needing more mailbox creation soon, so abstract it away. While at it, check for allocation failures. No other functional changes.
2015-09-07cli: g_hash_table_lookup_extended is overkillJani Nikula
Switch to normal glib hash table lookup. The extended version is only required if the values may contain NULL.
2015-08-14cli: add global option "--uuid"David Bremner
The function notmuch_exit_if_unmatched_db_uuid is split from notmuch_process_shared_options because it needs an open notmuch database. There are two exceptional cases in uuid handling. 1) notmuch config and notmuch setup don't currently open the database, so it doesn't make sense to check the UUID. 2) notmuch compact opens the database inside the library, so we either need to open the database just to check uuid, or change the API.
2015-06-01cli: define shared options, use for --help and --versionDavid Bremner
Unfortunately it seems trickier to support --config globally The non-trivial changes are in notmuch.c; most of the other changes consists of blindly inserting two lines into every subcommand.
2015-03-29lib: add "verbose" versions of notmuch_database_{open,create}David Bremner
The compatibility wrapper ensures that clients calling notmuch_database_open will receive consistent output for now. The changes to notmuch-{new,search} and test/symbol-test are just to make the test suite pass. The use of IGNORE_RESULT is justified by two things. 1) I don't know what else to do. 2) asprintf guarantees the output string is NULL if an error occurs, so at least we are not passing garbage back.
2015-02-25cli: fix clang build warningsJani Nikula
Fix the following warning produced by clang 3.5.0: notmuch-search.c:730:25: warning: initializing 'void *' with an expression of type 'const notmuch_opt_desc_t (*)[4]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] { NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 }, ^~~~~~~~~~~~~~~ 1 warning generated.
2014-11-09cli: notmuch address option defaults updateTomi Ollila
When no --output option were given, change default to display senders only. When only --count option is given, display senders (in contrary to not displaying anything). Document that --count with --sort=**order** is not supported option combination. Clean up some whitespace in the documentation. One test updated to have --output=count without sender nor recipient output option.
2014-11-05cli: address: Add --output=countMichal Sojka
This output prints how many times was each address encountered during search.
2014-11-05cli: address: Do not output duplicate addressesMichal Sojka
This filters out duplicate addresses from address command output. It also also adds tests for the address command. The code here is an extended version of a patch from Jani Nikula.
2014-11-05cli: search: Convert --output to keyword argumentMichal Sojka
Now, when address related outputs are in a separate command, it makes no sense to combine multiple --output options in search command line. Using switch statement to handle different outputs is more readable than a series of if statements.
2014-11-05cli: Introduce "notmuch address" commandMichal Sojka
This moves address-related functionality from search command to the new address command. The implementation shares almost all code and some command line options. Options --offset and --limit were intentionally not included in the address command, because they refer to messages numbers, which users do not see in the output. This could confuse users because, for example, they could see more addresses in the output that what was specified with --limit. This functionality can be correctly reimplemented for address subcommand later. Also useless values of --exclude flag were not included in the address command. This was inspired by a patch from Jani Nikula.
2014-11-05cli: search: Split notmuch_search_command to smaller functionsMichal Sojka
In a subsequent commit, these functions will be used to share some functionality between search and address commands.
2014-11-05cli: search: Convert ctx. to ctx->Michal Sojka
In the next commit, notmuch_search_command will be refactored to several smaller functions. In order to simplify the next commit to verbatim move of several lines to new functions with search_context_t* argument, we convert all references to this structure to pointer dereferences. To do so we rename the context variable and use the original name ctx as the pointer to the renamed structure.
2014-11-05cli: search: Move more variables into search_context_tMichal Sojka
In order to share some command line options between search and address subcommands we need to add corresponding variables to the context structure. While we are at it, we also add notmuch_database_t to unify parameters of all do_search_* functions and to simplify subsequent commits. Otherwise, there are no functional changes.
2014-11-05cli: search: Rename options to contextMichal Sojka
In the next commit the options structure will be extended by non-option variables. Therefore we need a more generic name. Just text replacement, no other changes.
2014-11-02cli: add support for notmuch search --duplicate=N with --output=messagesJani Nikula
Print the message IDs of all messages matching the search terms that have at least N files associated with them.
2014-11-01cli: search: Add --output={sender,recipients}Michal Sojka
The new outputs allow printing senders, recipients or both of matching messages. To print both, the user can use --output=sender and --output=recipients simultaneously. Currently, the same address can appear multiple times in the output. The next commit will change this. For this reason, tests are introduced there. We use mailbox_t rather than InternetAddressMailbox because we will need to extend it in a following commit. This code is based on a patch from Jani Nikula.
2014-11-01cli: search: Convert --output to keyword-flag argumentMichal Sojka
This converts "notmuch search" to use the recently introduced keyword-flag argument parser. At this point, it only makes the code slightly less readable but following commits that add new --output keywords will profit from this.
2014-11-01cli: search: Refactor passing of command line optionsMichal Sojka
Many functions that implement the search command need to access command line options. Instead of passing each option in a separate variable, put them in a structure and pass only this structure. This will become handy in the following commits.
2014-03-09util: make sanitize string available in string util for reuseJani Nikula
No functional changes.
2014-03-09cli: sanitize tabs and newlines to spaces in notmuch searchJani Nikula
Sanitize tabs and newlines to spaces rather than question marks in --output=summary --format=text output. This will also hide any difference in unfolding a header that has been folded with a tab. Our own header parser replaces tabs with spaces, while gmime would retain the tab.
2014-01-18cli: clean up exit status code returned by the cli commandsJani Nikula
Apart from the status codes for format mismatches, the non-zero exit status codes have been arbitrary. Make the cli consistently return either EXIT_SUCCESS or EXIT_FAILURE.
2013-11-08search: Add stable queries to thread search resultsAustin Clements
These queries will match exactly the set of messages currently in the thread, even if more messages later arrive. Two queries are provided: one for matched messages and one for unmatched messages. This can be used to fix race conditions with tagging threads from search results. While tagging based on a thread: query can affect messages that arrived after the search, tagging based on stable queries affects only the messages the user was shown in the search UI. Since we want clients to be able to depend on the presence of these queries, this ushers in schema version 2.
2013-08-24cli: add --duplicate=N option to notmuch searchJani Nikula
Effective with --output=files, output the Nth filename associated with each message matching the query (N is 1-based). If N is greater than the number of files associated with the message, don't print anything.
2013-06-24cli: use notmuch_exclude_t in option parserPeter Wang
Use notmuch_exclude_t constants directly instead of a redundant enumeration while parsing search --exclude keyword arguments.
2013-06-24lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_tMark Walters
Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can cover all four values of search --exclude in the cli. Previously the way to avoid any message being marked excluded was to pass in an empty list of excluded tags: since we now have an explicit option we might as well honour it. The enum is in a slightly strange order as the existing FALSE/TRUE options correspond to the new NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options so this means we do not need to bump the version number. Indeed, an example of this is that the cli count and show still use FALSE/TRUE and still work.
2013-05-13cli: add --exclude=all option to notmuch-search.cMark Walters
Add a --exclude=all option to notmuch search.
2013-03-08cli: move config open/close to main() from subcommandsJani Nikula
This allows specifying config file as a top level argument to notmuch, and generally makes it possible to override config file options in main(), without having to touch the subcommands. If the config file does not exist, one will be created for the notmuch main command and setup and help subcommands. Help is special in this regard; the config is created just to avoid errors about missing config, but it will not be saved. This also makes notmuch config the talloc context for subcommands.
2013-03-07cli: config: make notmuch_config_open() "is new" parameter input onlyJani Nikula
We now have a notmuch_config_is_new() function to query whether a config was created or not. Change the notmuch_config_open() is_new parameter into boolean create_new to determine whether the function should create a new config if one doesn't exist. This reduces the complexity of the API.
2012-12-18cli: add --format=text0 to notmuch searchJani Nikula
Add new format text0, which is otherwise the same as text, but use the null character as separator instead of the newline character. This is similar to find(1) -print0 option, and works together with the xargs(1) -0 option.