Commit graph

228 commits

Author SHA1 Message Date
Lars Kotthoff
d34720e7b3 config: allow custom separators in author lists
Allow distinguishing between commas separating authors and separating
first and last names.

Amended by db: reformat NEWS entry and commit message. Tweaked
whitespace in lib/thread.cc.
2024-07-26 15:59:11 +09:00
David Bremner
a62b8a95c0 doc/lib: clarify ownership for notmuch_database_get_revision
The ownership is implicit in the const declaration (I think!), but
that does not show up in the doxygen generated API docs.
2023-07-09 12:08:28 -03:00
David Bremner
c6733a45c8 lib: add config key INDEX_AS_TEXT
Higher level processing as a list of regular expressions and
documentation will follow.
2023-04-02 19:21:37 -03:00
Kevin Boulain
d86e03c786 lib/notmuch: update example
Likely missed in 86cbd215e, when notmuch_query_search_messages_st was
renamed to notmuch_query_search_messages.
2023-02-27 08:34:38 -04:00
David Bremner
09f2ad8e85 lib: add better diagnostics for over long filenames.
Previously we just crashed with an internal error. With this change,
the caller can handle it better. Update notmuch-new so that it doesn't
crash with "unknown error code" because of this change.
2023-02-20 09:22:32 -04:00
David Bremner
3f27cce71f lib: add NOTMUCH_STATUS_CLOSED_DATABASE, use in _n_d_ensure_writable
In order for a database to actually be writeable, it must be the case that it
is open, not just the correct type of Xapian object. By explicitely
checking, we are able to provide better error reporting, in particular
for the previously broken test in T566-lib-message.
2022-06-25 16:06:18 -03:00
David Bremner
e70df92085 lib/tag: handle NULL argument to notmuch_tags_valid
Make the behaviour when passed NULL consistent with
notmuch_filenames_valid. The library already passes the result of
notmuch_message_get_tags without checking for NULL, so it should be
handled.
2022-06-25 16:05:45 -03:00
David Bremner
7f8af14bdc lib: bump minor version to 6.
One new status value and one configuration value added.
2022-01-29 18:13:26 -04:00
David Bremner
79936ac93e lib/config: add known config key "show.extra_headers"
Used in a following commit to enable including extra headers beyond
the default in structured output.
2022-01-18 08:09:14 -04:00
David Bremner
fad2e7540b lib/open: no default mail root in split configurations
If we know the configuration is split, but there is no mail root
defined, this indicates a (lack of) configuration error. Currently
this can only arise in XDG configurations.
2022-01-15 15:59:39 -04:00
David Bremner
e7bb7919a2 Merge branch 'release' 2021-10-30 15:01:01 -03:00
David Bremner
8f0b84789d lib/load_config: document expectations for db on error, add tests
This is a bit different than n_d_{open,create}_with_config, since
there are several non-zero status codes where we do want to return a
non-NULL database structure.
2021-10-30 13:49:37 -03:00
David Bremner
f3fcdd2dda lib/create: document expectations for db on error, add tests
It seems sensible to harmonize the behaviour with
n_d_open_with_config. In this commit we just assert the desired
behaviour.
2021-10-30 13:45:40 -03:00
David Bremner
fb02817943 lib: document n_o_w_config can return NOTMUCH_STATUS_NO_CONFIG
This should be treated as fatal by callers, since we didn't succeed in
opening a Xapian database.
2021-10-30 13:41:57 -03:00
Jani Nikula
6987286a5b lib: remove enum names from typedefs
There are some enum typedefs with the enum name:

    typedef enum _name_t { ... } name_t;

We don't need or use the enum names _name_t for anything, and not all
of the enum typedefs have them. We have the typedefs specifically to
use the typedef name.

Use the anonymous enum in the typedefs:

    typedef enum { ... } name_t;
2021-10-23 08:38:53 -03:00
Jani Nikula
e0834e376a lib: fix commented out NOTMUCH_DEPRECATED()
Remove the comment markers from the placeholder NOTMUCH_DEPRECATED(),
added in commit e5f3c3ed50 ("lib: add stub for
notmuch_database_open_with_config").
2021-10-23 08:34:06 -03:00
David Bremner
8383b6cb3a lib: bump lib minor version to 5
One new function (and an enum) was added to the API/ABI.
2021-10-15 08:34:39 -03:00
David Bremner
9ae4188610 lib: add new status code for query syntax errors.
This will help provide more meaningful error messages without special
casing on the client side.
2021-09-04 17:07:19 -07:00
David Bremner
c4f2f33a50 lib: define notmuch_query_create_with_syntax
Set the parsing syntax when the (notmuch) query object is
created. Initially the library always returns a trivial query that
matches all messages when using s-expression syntax.

It seems better to select the syntax at query creation time because
the lazy parsing is an implementation detail.
2021-09-04 17:07:19 -07:00
David Bremner
3df2281746 notmuch release 0.32.3-1 for unstable (sid) [dgit]
[dgit distro=debian no-split --quilt=linear]
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEkiyHYXwaY0SiY6fqA0U5G1WqFSEFAmEclwwACgkQA0U5G1Wq
 FSEdBw//cF+LAJy9qyWX8axQcSwo1/ixZkyxSCc0JVaDhhAal5GdVd3E+vDKZp3Q
 KWExBKncTAciB1CooKNurnvFr30s9MX+SrDK0rPCqXtObMRYS96AEDCvul9Z9mBT
 eE6thb66Y2Mrr2dyHiyG/GHrp9wces+sSnB6xM6bqO16c9UsMuqjTIIqlb0A7oP8
 eN/LLPAcVoXIMry3hVQWzv6bJWfqQK9Ho66p1fH+QswgeeKIzh5HR3ZnGdsBhnyN
 n3l9QPYuhN7/85cjWH4AE0/2EQLIF/Ewu86qYHzvOufc7oiNXRGpzQtMNqqur/da
 JIOizaylhLkFP39i/7CHvldCTx0FOCVhbHtFwb1Hm7rPqr8DhOvXyZbDHK/LkWtg
 jBKVFld4nNv/zm1uz6S3E5rDFsxuvpMVuesWKj6Yb051QvfGqVTnwRHP3EFxMyk8
 CVle5a3mMg8bnlN9o/WchB3z3ybijK4HLjGB+FWDZMUvhKXkfZL6GUeo/EQ8byaX
 mDEx5u56euqgNQS1PnIF/nTaOCbu75IqYAUSqwVXBcICi7LfYKDwGezBiEhoRiKt
 RQoulN9FNS+HuL+85LN4TdZyJOvD1Rc9xdT9TwuLr47nIc/KdAWUxyYSEo4PMiZ+
 NNiCatI5kPJrp0q1A5xDRkpFavLu5Mtu9ore+Cf1nA18iEFNQwc=
 =cECE
 -----END PGP SIGNATURE-----

Merge tag 'debian/0.32.3-1'

notmuch release 0.32.3-1 for unstable (sid) [dgit]

[dgit distro=debian no-split --quilt=linear]
2021-08-18 21:46:42 -07:00
Austin Ray
f1a310b3a9 lib: bump libnotmuch minor version
Notmuch 0.32 corresponds to libnotmuch 5.4 as indicated by docstrings;
however, the minor number wasn't bumped. Any libnotmuch downstream
consumer using the LIBNOTMUCH_CHECK_VERSION macro to support multiple
versions won't be able to access the new 5.4 functions.

Signed-off-by: Austin Ray <austin@austinray.io>
2021-08-17 16:30:22 -07:00
Austin Ray
414ba75c81 lib: correct deprecated db open functions' docs
Both notmuch_database_open() and notmuch_database_open_verbose()'s
documentation state they call notmuch_database_open_with_config() with
config_path=NULL; however, their implementations pass an empty string.
The empty string is the correct value to maintain their original
behavior of not loading the user's configuration so their documentation
is incorrect.
2021-08-17 16:30:05 -07:00
David Bremner
6e7365fb20 lib: update transaction documentation
Partly this is to recognize the semantics we inherit from Xapian,
partly to mention the new autocommit feature.
2021-06-27 14:06:30 -03:00
David Bremner
2f608d2a94 lib/config: add NOTMUCH_CONFIG_AUTOCOMMIT
This will be used to control how often atomic transactions are
committed.
2021-06-27 13:59:42 -03:00
David Bremner
f5d4349921 lib: provide notmuch_config_path
Since the library searches in several locations for a config file, the
caller does not know which of these is chosen in the usual case of
passing NULL as a config file. This changes provides an API for the
caller to retrieve the name of the config file chosen. It will be
tested in a following commit.
2021-03-27 09:26:14 -03:00
David Bremner
2e39ce6eb5 lib: add NOTMUCH_STATUS_NO_DATABASE
This will allow more precise return values from various open related functions.
2021-03-27 09:26:14 -03:00
David Bremner
863b243185 lib/config: add config_pairs iterators
The layer of shims here seems a bit wasteful compared to just calling
the corresponding string map functions directly, but it allows control
over the API (calling with notmuch_database_t *) and flexibility for
future changes.
2021-03-27 09:26:14 -03:00
David Bremner
0c6db22930 lib/config: add notmuch_config_get_values_string
This is to support the less common (at least in the notmuch codebase)
case of accessing a ;-delimited list config value with an arbitrary
string key.
2021-03-27 09:26:14 -03:00
David Bremner
2fc40e24de lib: provide notmuch_database_load_config
This is mainly targetted at notmuch-config.c, or similar applications
that don't necessarily need both a configuration file and a database
to exist.
2021-03-27 09:26:14 -03:00
David Bremner
a7873df331 lib/config: add configuration variable for backup directory
Like the hook directory, we primarily need a way to communicate this
directory between various components, but we may as well let the user
configure it.

Most of the diff is generalizing choose_hook_dir to work for both
backup and hook directories.
2021-03-20 07:51:36 -03:00
David Bremner
e823d05ae6 lib: support splitting mail from database location.
Introduce a new configuration value for the mail root, and use it to
locate mail messages in preference to the database.path (which
previously implied the mail messages were also in this location.

Initially only a subset of the CLI is tested in a split
configuration. Further changes will be needed for the remainder of the
CLI to work in split configurations.
2021-03-20 07:39:12 -03:00
David Bremner
13efbd0e1c lib: support reopening databases for write access.
In the future Xapian will apparently support this more conveniently
for the cases other than READ_ONLY => READ_ONLY

Conceptually this function seems to fit better in lib/open.cc;
database.cc is still large enough that moving the function makes
sense.
2021-03-18 08:04:06 -03:00
David Bremner
1121299905 lib: publish API for notmuch_database_reopen
Include the (currently unused) mode argument which will specify which
mode to re-open the database in. Functionality and docs to be
finalized in a followup commit.
2021-03-18 08:03:36 -03:00
uncrustify
8aeba1228a lib: run uncrustify
This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h *.cc

in the lib directory
2021-03-13 08:45:34 -04:00
David Bremner
4922416ccc lib/config: add HOOK_DIR
The hook directory configuration needs to be kept in synch with the
other configuration information, so add scaffolding to support this at
database opening time.
2021-02-06 19:54:09 -04:00
David Bremner
ac67cd84ee lib: introduce notmuch_database_create_with_config
This takes a config path parameter, and can use that to decide the
new database location.
2021-02-06 19:48:34 -04:00
David Bremner
55f5e87096 lib: add NOTMUCH_STATUS_DATABASE_EXISTS
It is desirable to distinguish between attempting to create a database
that already exists, and more fatal errors like permission problems.
2021-02-06 19:46:46 -04:00
David Bremner
eea258c0c9 lib: add NOTMUCH_STATUS_NO_CONFIG
This will allow client code to provide more meaningful diagnostics. In
particular it will enable "notmuch new" to continue suggsting the user
run "notmuch setup" to create a config after "notmuch new" is
transitioned to the new  configuration framework.
2021-02-06 19:43:11 -04:00
David Bremner
b860be6a76 lib/config: add NOTMUCH_CONFIG_NEW_IGNORE
This will be needed by (at least) the conversion of notmuch-new.c to
the new config framework
2021-02-06 19:39:33 -04:00
David Bremner
5232462dcf lib: split notmuch_database_compact
The "back end" function takes an open notmuch database, which should
know its own path (i.e. the path needs to be cached in the
configuration data).
2021-02-06 19:34:17 -04:00
David Bremner
a4af7a2a1b lib: add notmuch_config_get_bool
Booleans have no out of band values, so return a status for errors.
2021-02-06 19:14:11 -04:00
David Bremner
d071828bd5 lib/config: make values iterators restartable
This is relatively cheap, and makes it easier to transform existing
code which uses arrays of pointers to store configuration lists.
2021-02-06 19:09:39 -04:00
David Bremner
fd6f8e6c30 lib/config: add config values iterator
This is intended to avoid duplicating the string splitting and
traversal code for all clients of the config API.
2021-02-06 19:08:12 -04:00
David Bremner
d6bd87a712 lib/config: add notmuch_config_key_{get,set}
By using an enum we can have better error detection than copy pasting
key strings around.

The question of what layer this belongs in is a bit
tricky. Historically most of the keys are defined by the CLI. On the
other hand features like excludes are supported in the
library/bindings, and it makes sense to configure them from the
library as well.

The somewhat long prefix for notmuch_config_t is to avoid collisions
with the existing usage in notmuch-client.h.
2021-02-06 19:02:00 -04:00
David Bremner
e5f3c3ed50 lib: add stub for notmuch_database_open_with_config
Initially document the intended API and copy the code from
notmuch_database_open_verbose. Most of the documented functionality is
not there yet.
2021-02-06 18:57:35 -04:00
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
David Bremner
e3f88436b7 test: regression test for traversing config list with closed db
Also mention error return in API docs
2020-08-03 21:03:43 -03:00
David Bremner
337665e26a lib: catch exceptions in n_directory_get_child_files
Also clarify API in error case.
2020-08-03 20:56:09 -03:00
David Bremner
9668583a49 lib: catch exceptions in n_directory_get_child_directories
Also clarify API in error case.
2020-08-03 20:53:04 -03:00
David Bremner
31dab9b1cd lib: return NULL from n_d_get_default_indexopts on error
This is a rare and probably serious programming error, so better not
to silently return a default value.
2020-08-03 20:45:58 -03:00