aboutsummaryrefslogtreecommitdiffhomepage
path: root/notmuch-tag.c
Commit message (Collapse)AuthorAge
* cli: clean up exit status code returned by the cli commandsGravatar Jani Nikula2014-01-18
| | | | | | 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.
* tag-util: move out 'tag' command-line checkGravatar Peter Wang2013-06-29
| | | | | | Move an error condition specific to the 'tag' command out of parse_tag_command_line so that parse_tag_command_line can be used for the forthcoming 'insert' command.
* cli: add --remove-all option to "notmuch tag"Gravatar Jani Nikula2013-03-30
| | | | | | | | | | | | | | | | | | Add --remove-all option to "notmuch tag" to remove all tags from the messages matching query before applying the tag changes. This allows removal of all tags and unconditional setting of the tags of a message: $ notmuch tag --remove-all id:foo@example.com $ notmuch tag --remove-all +foo +bar id:foo@example.com without having to resort to the complicated (and still quoting broken): $ notmuch tag $(notmuch search --output=tags '*' | sed 's/^/-/') \ id:foo@example.com $ notmuch tag $(notmuch search --output=tags '*' | sed 's/^/-/') \ +foo +bar id:foo@example.com
* cli: make caller check tag count in parse_tag_command_lineGravatar Jani Nikula2013-03-30
|
* cli: move config open/close to main() from subcommandsGravatar Jani Nikula2013-03-08
| | | | | | | | | | | | | 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.
* cli: config: make notmuch_config_open() "is new" parameter input onlyGravatar Jani Nikula2013-03-07
| | | | | | | | 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.
* notmuch-tag: initialize with enum instead of 0Gravatar David Bremner2013-01-19
| | | | This is just a cosmetic fix to make the "type" of ret more clear.
* cli: propagate batch tagging warnings to exit valueGravatar Tomi Ollila2013-01-14
| | | | | | | | In case last input for batch tagging was either invalid or skippable line, notmuch command exited with non-zero value. After this change if there is at least one invalid line, notmuch command will exit with non-zero value. Additionally, skipped lines (last or other) doesn't cause non-zero value to be returned.
* cli: bail out and propagate tagging errors in notmuch tagGravatar Jani Nikula2013-01-09
| | | | | | | | | Checking and propagating tag_op_list_apply() errors is especially important with batch tagging, as the processing of the batch input would not stop otherwise. Additionally this sets the exit code, which is useful in scripts. Amended by: David Bremner
* cli: add support for batch tagging operations to "notmuch tag"Gravatar Jani Nikula2013-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for batch tagging operations through stdin to "notmuch tag". This can be enabled with the new --batch command line option to "notmuch tag". The input must consist of lines of the format: +<tag>|-<tag> [...] [--] <query> [...] Each line is interpreted similarly to "notmuch tag" command line arguments. The delimiter is one or more spaces ' '. Any characters in <tag> MAY be hex encoded with %NN where NN is the hexadecimal value of the character. Any ' ' and '%' characters in <tag> and MUST be hex encoded (using %20 and %25, respectively). For future-proofing, any '"' characters in <tag> SHOULD be hex-encoded. Any characters that are not part of <tag> or MUST NOT be hex encoded. <query> is passed verbatim to Xapian Leading and trailing space ' ' is ignored. Empty lines and lines beginning with '#' are ignored. Signed-off-by: Jani Nikula <jani@nikula.org> Hacked-like-crazy-by: David Bremner <david@tethera.net>
* notmuch-tag.c: convert to use tag-utilGravatar David Bremner2013-01-07
| | | | | | | | | Command line parsing is factored out into a function parse_tag_command_line in tag-util.c. There is some duplicated code eliminated in tag_query, and a bunch of translation from using the bare tag_op structs to using that tag-utils API.
* util: Factor out boolean term quoting routineGravatar Austin Clements2013-01-06
| | | | | | | | | | | | | | | | | This is now a generic boolean term quoting function. It performs minimal quoting to produce user-friendly queries. This could live in tag-util as well, but it is really nothing specific to tags (although the conventions are specific to Xapian). The API is changed from "caller-allocates" to "readline-like". The scan for max tag length is pushed down into the quoting routine. Furthermore, this now combines the term prefix with the quoted term; arguably this is just as easy to do in the caller, but this will nicely parallel the boolean term parsing function to be introduced shortly. This is an amalgamation of code written by David Bremner and myself.
* notmuch-tag: tidy formattingGravatar David Bremner2012-11-16
| | | | This is just the result of running uncrustify.
* tag: Disallow adding malformed tags to messagesGravatar Austin Clements2012-10-27
| | | | | | | | | | | | This disallows adding empty tags, since nothing but confusion follows in their wake, and disallows adding tags that begin with "-" because they are also confusing, the tag "-" is impossible to remove using the CLI, and because the syntax for removing such tags conflicts with long argument syntax. This does not place any restrictions on what tags can be removed, as that would make it difficult for people who have the misfortune of already having malformed tags to remove these tags.
* lib/cli: Make notmuch_database_open return a status codeGravatar Austin Clements2012-05-05
| | | | | | | | | | | | It has been a long-standing issue that notmuch_database_open doesn't return any indication of why it failed. This patch changes its prototype to return a notmuch_status_t and set an out-argument to the database itself, like other functions that return both a status and an object. In the interest of atomicity, this also updates every use in the CLI so that notmuch still compiles. Since this patch does not update the bindings, the Python bindings test fails.
* Use notmuch_database_destroy instead of notmuch_database_closeGravatar Justus Winter2012-04-28
| | | | | | Adapt the notmuch binaries source to the notmuch_database_close split. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* cli: refactor "notmuch tag" query tagging into a separate functionGravatar Jani Nikula2012-03-30
| | | | | | | Refactor to make tagging code easier to reuse in the future. No functional changes. Signed-off-by: Jani Nikula <jani@nikula.org>
* cli: refactor "notmuch tag" data structures for tagging operationsGravatar Jani Nikula2012-03-30
| | | | | | | | | | | | | | To simplify code, keep all tagging operations in a single array instead of separate add and remove arrays. Apply tag changes in the order specified on the command line, instead of first removing and then adding the tags. This results in a minor functional change: If a tag is both added and removed, the last specified operation is now used. Previously the tag was always added. Change the relevant test to reflect the new behaviour. Signed-off-by: Jani Nikula <jani@nikula.org>
* tag: remove unused attribute from notmuch_tag_command() argumentsGravatar Dmitry Kurochkin2012-02-08
| | | | | Argc and argv arguments are used in notmuch_tag_command() function. So unused attribute is not appropriate for them.
* Silence buildbot warnings about unused resultsGravatar Austin Clements2012-01-21
| | | | | | | | | | | This ignores the results of the two writes in sigint handlers even harder than before. While my libc lacks the declarations that trigger these warnings, this can be tested by adding the following to notmuch.h: __attribute__((warn_unused_result)) ssize_t write(int fd, const void *buf, size_t count);
* notmuch: Quiet buildbot warnings.Gravatar David Edmondson2011-12-21
| | | | | Cast away the result of various *write functions. Provide a default value for some variables to avoid "use before set" warnings.
* tag: Automatically limit to messages whose tags will actually change.Gravatar Austin Clements2011-11-28
| | | | | | | | | | | | | | | This optimizes the user's tagging query to exclude messages that won't be affected by the tagging operation, saving computation and IO for redundant tagging operations. For example, notmuch tag +notmuch to:notmuch@notmuchmail.org will now use the query ( to:notmuch@notmuchmail.org ) and (not tag:"notmuch") In the past, we've often suggested that people do this exact transformation by hand for slow tagging operations. This makes that unnecessary.
* cli: change argument parsing convention for subcommandsGravatar David Bremner2011-10-22
| | | | | | | | | previously we deleted the subcommand name from argv before passing to the subcommand. In this version, the deletion is done in the actual subcommands. Although this causes some duplication of code, it allows us to be more flexible about how we parse command line arguments in the subcommand, including possibly using off-the-shelf routines like getopt_long that expect the name of the command in argv[0].
* Remove some variables which were set but not used.Gravatar Carl Worth2011-05-11
| | | | | | | | | | | | gcc (at least as of version 4.6.0) is kind enough to point these out to us, (when given -Wunused-but-set-variable explicitly or implicitly via -Wunused or -Wall). One of these cases was a legitimately unused variable. Two were simply variables (named ignored) we were assigning only to squelch a warning about unused function return values. I don't seem to be getting those warnings even without setting the ignored variable. And the gcc docs. say that the correct way to squelch that warning is with a cast to (void) anyway.
* lib: Rework interface for maildir_flags synchronizationGravatar Carl Worth2010-11-11
| | | | | | | | | | | | | Instead of having an API for setting a library-wide flag for synchronization (notmuch_database_set_maildir_sync) we instead implement maildir synchronization with two new library functions: notmuch_message_maildir_flags_to_tags and notmuch_message_tags_to_maildir_flags These functions are nicely documented here, (though the implementation does not quite match the documentation yet---as plainly evidenced by the current results of the test suite).
* Avoid abbreviation, preferring notmuch_config_get_maildir_synchronize_flagsGravatar Carl Worth2010-11-11
| | | | | | | | | | | | | Since the name of the configuration parameter here is: maildir.synchronize_flags the convention is that the functions to get and set this parameter should match it in name. Hence: notmuch_config_get_maildir_synchronize_flags etc. (as opposed to notmuch_config_get_maildir_sync).
* Make maildir synchronization configurableGravatar Michal Sojka2010-11-10
| | | | | | | This adds group [maildir] and key 'synchronize_flags' to the configuration file. Its value enables (true) or diables (false) the synchronization between notmuch tags and maildir flags. By default, the synchronization is disabled.
* notmuch-tag: don't sort messages before applying tag changesGravatar Sebastian Spaeth2010-04-21
| | | | | | | | | It's not neccessary to sort the results before we apply tags. Xapian contributor Olly Betts says that savings might be bigger with a cold file cache and (as unsorted implies really sorted by document id) a better cache locality when applying tags to messages. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* lib: Rename iterator functions to prepare for reverse iteration.Gravatar Carl Worth2010-03-09
| | | | | | | | We rename 'has_more' to 'valid' so that it can function whether iterating in a forward or reverse direction. We also rename 'advance' to 'move_to_next' to setup parallel naming with the proposed functions 'move_to_first', 'move_to_last', and 'move_to_previous'.
* Avoid compiler warnings due to ignored write return valuesGravatar Dirk-Jan C. Binnema2009-12-01
| | | | | | | | | | | | | Glibc (at least) provides the warn_unused_result attribute on write, (if optimizing and _FORTIFY_SOURCE is defined). So we explicitly ignore the return value in our signal handler, where we couldn't do anything anyway. Compile with: make CFLAGS="-O -D_FORTIFY_SOURCE" before this commit to see the warning.
* lib/query: Drop the first and max_messages arguments from search_messages.Gravatar Carl Worth2009-11-23
| | | | | These only existed to support the chunky-searching hack, but that was recently dropped anyway.
* Rename NOTMUCH_DATABASE_MODE_WRITABLE to NOTMUCH_DATABASE_MODE_READ_WRITEGravatar Carl Worth2009-11-21
| | | | And correspondingly, READONLY to READ_ONLY.
* Permit opening the notmuch database in read-only mode.Gravatar Chris Wilson2009-11-21
| | | | | | | | | We only rarely need to actually open the database for writing, but we always create a Xapian::WritableDatabase. This has the effect of preventing searches and like whilst updating the index. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Carl Worth <cworth@cworth.org>
* Make reply/show/tag all require at least one search termGravatar Keith Packard2009-11-18
| | | | | | | | In particular, notmuch tag -inbox "" tended to take a long time to run, happened if you hit 'a' on a blank line in the search view and probably didn't have the desired effect. Signed-off-by: Keith Packard <keithp@keithp.com>
* notmuch new/tag: Flush all changes to database when interrupted.Gravatar Keith Packard2009-11-13
| | | | | | By installing a signal handler for SIGINT we can ensure that no work that is already complete will be lost if the user interrupts a "notmuch new" run with Control-C.
* libnotmuch: Underlying support for doing partial-results searches.Gravatar Carl Worth2009-11-12
| | | | | | The library interface now allows the caller to do incremental searches, (such as one page of results at a time). Next we'll just need to hook this up to "notmuch search" and the emacs interface.
* Unbreak several notmuch commands after the addition of configuration.Gravatar Carl Worth2009-11-11
| | | | | | | | | | | | | | | | | | | | | | All of the following commands: notmuch dump notmuch reply notmuch restore notmuch search notmuch show notmuch tag were calling notmuch_database_open with an argument of NULL. This was a legitimate call until the recent addition of configuration, after which it is expected that all commands will lookup the correct path in the configuration file. So fix all these commands to do that. Also, while touching all of these commands, we fix them to use the talloc context that is passed in rather than creating a local talloc context. We also switch from using goto for return values, to doing direct returns as soon as an error is detected, (which can be leak free thanks to talloc).
* notmuch: Break notmuch.c up into several smaller files.Gravatar Carl Worth2009-11-10
Now that the client sources are alone here in their own directory, (with all the library sources down inside the lib directory), we can break the client up into multiple files without mixing the files up. The hope is that these smaller files will be easier to manage and maintain.