Tcl bindings for notmuch

Eric J eric at deptj.eu
Tue Mar 1 10:34:40 PST 2016


On Sun, 14 Feb 2016 13:05:28 +0100 (CET), Eric J <eric at deptj.eu> wrote:
>

Resending with additional information:

> I have been using notmuch for a while and I wanted to be able to use
> notmuch queries in some Tcl stuff I have been using for a rather longer
> while. I could have just called the notmuch CLI every time, but I thought
> "no, it's a library, there should be bindings".
> 
> Bindings made me think of SWIG, which seems to have been tried for
> notmuch in the past but abandoned. However, with some time available...
> 
> ... I can now, from Tcl, use the API functions from the library to
> create a database, close and open it, add messages, tag them, run queries
> and retrieve information about the results. I haven't tested every API
> function yet, but I will be able to go on with my own needs at least. It
> is only functions with pointer-to-pointer arguments that need special
> attention, and that is all in the SWIG interface file. You can see that at
> http://chiselapp.com/user/emj/repository/tclnotmuch/artifact/527aee944d?txt=1&ln=0
> - its about 50 lines (plus some blanks).
> 
> That's a Fossil repository, with a home page at
> http://chiselapp.com/user/emj/repository/tclnotmuch , if anyone wants
> to look further. I think it may benefit from more wrapping from the Tcl
> side, just for usability.
> 
> BTW, I have no idea if or how the interface file would have to be changed
> for other languages.

The bindings work, but for a use case where simultaneous database access
from different processes is needed (e.g. processing emails as they
arrive), lost updates are possible for the following Tcl versions:

* 8.5.18 built with threads (not the default)
* 8.6.[1-4] built with threads (default)

However, the following Tcl versions do not have this problem:

* 8.5.18 built without threads (default)
* 8.5.19 built with or without threads
* 8.6.[1-4] built without threads (not the default)
* 8.6.5 built with or without threads

Earlier 8.5.x are presumably the same as 8.5.18.

The problems, where they exist, are due to a weird interaction between
Tcl's thread implementation and Xapian's locking mechanism. The Tcl fix
in 8.5.19/8.6.5 was made for reasons unrelated to Xapian locking, but
fixes it anyway.

Eric
-- 
ms fnd in a lbry


More information about the notmuch mailing list