question: how to change file extension generated by (notmuch-show-view-part)

2020-11-22 Thread Wenlong Dai
I've been trying to use links2 to view html part of messages.
The problem I'm encountering is that, the part would be saved as
/tmp/xxx/xxx.shtml and
passed on to links2, and it seems links2 doesn't recognise the .shtml
extension.

netsurf works well with .shtml though.

But being stubborn as I am, I would like to know if I can make notmuch
output .html file instead?
I did a bit of research on shtml, seems it's completely unnecessary in this
case? why would notmuch choose this extension anyway?
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH] python-cffi: Extract cdefs from notmuch.h

2020-11-22 Thread Floris Bruynooghe
Instead of having all the required cdefs copied in _build.py this uses
the C pre-compiler to extract them from notmuch.h itself.  To do this
we need to indroduce a few more #ifdefs in the header file since the
CFFI parser can not deal with everything the real C parser can deal
with, plus it does not want to see symbols not from notmuch.

The main downside is that we always compile in all symbols of the
library, not just those used.  Furthermore to avoid having lots of
compiler warnings about deprecated symbols this excludes all unused
deprecated functions using even more #ifdefs.

To allow this to work this also makes sure that when using the
Makefile to build notmuch the python bindings find and use the headers
and library from the build directory, before it would still link
against the system-wide libnotmuch.so.5.  I have not tested this with
out-of tree builds.
---
 .gitignore |   2 +
 bindings/Makefile.local|   8 +-
 bindings/python-cffi/README|  63 
 bindings/python-cffi/notmuch2/_build.py| 359 +++--
 bindings/python-cffi/pip-editable-build.sh |  16 +
 lib/notmuch.h  |  20 +-
 6 files changed, 159 insertions(+), 309 deletions(-)
 create mode 100644 bindings/python-cffi/README
 create mode 100755 bindings/python-cffi/pip-editable-build.sh

diff --git a/.gitignore b/.gitignore
index 3edd1768..ddc0f650 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,8 @@
 /.stamps
 /Makefile.config
 /bindings/python-cffi/build/
+/bindings/python-cffi/notmuch2/*.c
+/bindings/python-cffi/notmuch2/*.so
 /lib/libnotmuch*.dylib
 /lib/libnotmuch.so*
 /notmuch
diff --git a/bindings/Makefile.local b/bindings/Makefile.local
index bc960bbc..7523a0b5 100644
--- a/bindings/Makefile.local
+++ b/bindings/Makefile.local
@@ -16,7 +16,13 @@ endif
 python-cffi-bindings: lib/$(LINKER_NAME)
 ifeq ($(HAVE_PYTHON3_CFFI),1)
cd $(dir)/python-cffi && \
-   ${PYTHON} setup.py build --build-lib build/stage && \
+   ${PYTHON} setup.py build_ext \
+--build-lib build/stage \
+--include-dirs ../../lib \
+--library-dirs ../../lib \
+--rpath $(CURDIR)/lib  && \
+   ${PYTHON} setup.py build \
+--build-lib build/stage && \
mkdir -p build/stage/tests && cp tests/*.py build/stage/tests
 endif
 
diff --git a/bindings/python-cffi/README b/bindings/python-cffi/README
new file mode 100644
index ..2f20e17f
--- /dev/null
+++ b/bindings/python-cffi/README
@@ -0,0 +1,63 @@
+notmuch2 - python3 compatible bindings to notmuch
+
+These bindings use CFFI to generate the bindings making it work well
+with both CPython and PyPy.  They try to ensure all operations
+from within Python are safe and handle the memory management themselves.
+
+Building notmuch2
+-
+
+The provided setup.py file can be used to build and install the
+bindings.  You will need python3, setuptools and cffi installed for
+this to work.
+
+By default this will assume that the C compiler can find both
+notmuch.h and libnotmuch.so.5, if these are installed in a system-wide
+location they will normally be found there.  When building notmuch
+with make it will ensure that the C compiler finds the in-tree version
+of notmuch instead of any system-wide one which might be available.
+However the resulting python module is not relocatable and is mainly
+used by the notmuch test suite.  For installing your own notmuch
+python package it is recommended to first install libnotmuch system
+wide and than use setup.py to build and install the python package.
+
+If you really need to customise your build environment, have a look at
+the INCUDE_DIRS, LIBRARY_DIRS and EXTRA_LINK_ARGS variables in
+notmuch2/_build.py.
+
+Documentation
+-
+
+The package has extensive docstrings, these docs are also included in
+the general notmuch sphinx documentation.  See the notmuch `doc/`
+subdirectory for this.
+
+
+Development
+---
+
+An easy way to work on the bindings themselves is to create a
+virtualenv to work in.  Install the python bindings in editable mode
+using:
+
+$ cd bindings/python-cffi
+$ pip install -e .
+
+However as described above this will build against the system-wide
+notmuch installation.  If you need to work on the currently developed
+libnotmuch you can invoke pip with some extra --global-option
+arguments.  This is rather verbose, so the pip-editable-build.sh
+script does this for you:
+
+$ make
+$ cd bindings/python-cffi
+$ ./pip-editable-build.sh
+
+Tests are written using pytest and can be run using:
+
+$ pip install pytest pytest-cov
+$ pytest
+
+Individual tests can be selected:
+
+$ pytest tests/test_database.py::TestCreate::test_create
\ No newline at end of file
diff --git a/bindings/python-cffi/notmuch2/_build.py 
b/bindings/python-cffi/notmuch2/_build.py
index 

python-cffi: experiment with extracting cdefs from notmuch.h

2020-11-22 Thread Floris Bruynooghe
Hi,

This is mostly an experiment because I got tired of copying the
C function defs from notmuch.h (in other words this was yak shaving
while I intended to see if I could get notmuch_database_get_directory
supported).  I'm not convinced this is better that what we had before
to be honest, but am curious what other people think of this approach.
In deltachat we do actually use this mechanism and it works nicely,
but there we don't have to deal with deprecated functions which is
what makes this ugly here.

Independenly maybe the changes to the makefile and README are useful
anyway.  I don't think the way this was build before always used the
right lib version, I think for running T391 we probably want to
compile with an RPATH.

Cheers,
Floris

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH v2] emacs: add notmuch-expr, sexp-style queries

2020-11-22 Thread David Bremner
Tom Fitzhenry  writes:

> +(require 'ert)
> +(require 'notmuch-expr)

Any ideas (from anyone) how we can run these tests in the notmuch test
suite? I guess some kind of shim might be needed, but perhaps it can
just be wrapped in one or more test_emacs calls.

> +
> +(defmacro notmuch-expr (query)
> +  "Compile an sexp QUERY into a textual notmuch query."
> +  `(notmuch-expr--eval ,query))

Does this need to be a macro? If so I'd appreciate a brief comment as to
why. At this point optimizing performace seems pretty premature, but
maybe there are other good reasons.
> index 165aaa43..8c5843e5 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -79,6 +79,7 @@
>  (require 'notmuch-maildir-fcc)
>  (require 'notmuch-message)
>  (require 'notmuch-parser)
> +(require 'notmuch-expr)
>  

I know we have just been requiring things historically, but I really
wonder if it's the right thing to do, especially since it seems the
library is not (yet) used for anything. Perhaps an autoload cookie on
the appropriate functions would be best.

By the way, I'd eventually like the CLI to parse S-expr queries (and/or
perhaps JSON queries) to avoid passing via strings (and all the problems
that entails). I'm not sure when I'll get around to it. There are also
some design details to be worked out, but hopefully it would bne a
mostly-compatible syntax with what is provided here.


___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org