From: David Bremner Date: Tue, 19 Jul 2016 12:03:19 +0000 (-0300) Subject: Merge branch 'release' X-Git-Url: http://rtime.felk.cvut.cz/gitweb/notmuch.git/commitdiff_plain/92d8eae8f182e4eebc87d76f8d4f37e6c018883a?hp=8fe58226ef81e9600c97675e62d4a78e0f6eeefe Merge branch 'release' --- diff --git a/COPYING b/COPYING index 6dea6939..4e744d26 100644 --- a/COPYING +++ b/COPYING @@ -12,4 +12,4 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program, (in the COPYING-GPL-3 file in this -directory). If not, see http://www.gnu.org/licenses/ +directory). If not, see https://www.gnu.org/licenses/ diff --git a/COPYING-GPL-3 b/COPYING-GPL-3 index 44325404..4c493545 100644 --- a/COPYING-GPL-3 +++ b/COPYING-GPL-3 @@ -2,7 +2,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -646,7 +646,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -665,12 +665,12 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/INSTALL b/INSTALL index b1b9cd55..6099ed01 100644 --- a/INSTALL +++ b/INSTALL @@ -30,7 +30,7 @@ Talloc, and zlib which are each described below: It provides all the real machinery of indexing and searching, (including the very nice parsing of the query string). - Xapian is available from http://xapian.org + Xapian is available from https://xapian.org Note: Notmuch will work best with Xapian 1.0.18 (or later) or Xapian 1.1.4 (or later). Previous versions of Xapian (whether @@ -58,7 +58,7 @@ Talloc, and zlib which are each described below: made development of Notmuch much easier and much less prone to memory leaks. - Talloc is available from http://talloc.samba.org/ + Talloc is available from https://talloc.samba.org/ zlib ---- diff --git a/Makefile.local b/Makefile.local index 066ecf23..f2ad0c12 100644 --- a/Makefile.local +++ b/Makefile.local @@ -10,7 +10,7 @@ # repository), we let git append identification of the actual commit. PACKAGE=notmuch -IS_GIT=$(shell if [ -d ${srcdir}/.git ] ; then echo yes ; else echo no; fi) +IS_GIT=$(shell if [ -d ${srcdir}/.git -o -f ${srcdir}/.git ] ; then echo yes ; else echo no; fi) ifeq ($(IS_GIT),yes) DATE:=$(shell git --git-dir=${srcdir}/.git log --date=short -1 --pretty=format:%cd) @@ -35,7 +35,7 @@ DEB_TAG=debian/$(UPSTREAM_TAG)-1 RELEASE_HOST=notmuchmail.org RELEASE_DIR=/srv/notmuchmail.org/www/releases -RELEASE_URL=http://notmuchmail.org/releases +RELEASE_URL=https://notmuchmail.org/releases TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz DEB_TAR_FILE=$(PACKAGE)_$(VERSION).orig.tar.gz SHA1_FILE=$(TAR_FILE).sha1 @@ -191,7 +191,7 @@ release-message: @echo "the Xapian library to provide fast, full-text search with a convenient" @echo "search syntax." @echo "" - @echo "For more about notmuch, see http://notmuchmail.org" + @echo "For more about notmuch, see https://notmuchmail.org" # This is a chain of dependencies rather than a simple list simply to # avoid the messages getting interleaved in the case of a parallel diff --git a/NEWS b/NEWS index 3db6aba9..ab661d4d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Notmuch 0.23 (UNRELEASED) +========================= + +Ruby Bindings +------------- + +Add support for `notmuch_database_get_all_tags` + Notmuch 0.22.1 (2016-07-19) =========================== @@ -2384,7 +2392,7 @@ Ruby bindings are now much more complete Python bindings have been updated and extended - (docs online at http://packages.python.org/notmuch/) + (docs online at https://notmuch.readthedocs.io/) New bindings: diff --git a/README b/README index d92fcfdf..0aa9a080 100644 --- a/README +++ b/README @@ -58,7 +58,7 @@ Contacting users and developers ------------------------------- The website for Notmuch is: - http://notmuchmail.org + https://notmuchmail.org The mailing list address for the notmuch community is: diff --git a/README.rst b/README.rst index 7417ddcb..7ff3198c 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,11 @@ -If you're reading this on http://github.com/notmuch/notmuch, this is a +If you're reading this on https://github.com/notmuch/notmuch, this is a read-only mirror of the notmuch project. -For more information about the project, see http://notmuchmail.org. +For more information about the project, see https://notmuchmail.org. Please don't send us pull requests on github. If you have a feature branch that you want us to look at, use ``git send-email`` to send it to notmuch@notmuchmail.org. For more information about contributing to the project, see -http://notmuchmail.org/contributing/. +https://notmuchmail.org/contributing/. diff --git a/bindings/go/README b/bindings/go/README index 18a54b60..1825ae03 100644 --- a/bindings/go/README +++ b/bindings/go/README @@ -13,4 +13,4 @@ todo - improve notmuch-addrlookup regexp -[1] http://notmuchmail.org/ \ No newline at end of file +[1] https://notmuchmail.org/ diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go index 0fff1ab6..4d8c2ceb 100644 --- a/bindings/go/src/notmuch/notmuch.go +++ b/bindings/go/src/notmuch/notmuch.go @@ -351,7 +351,7 @@ func (self *Database) GetAllTags() *Tags { * completely in the future, but it's likely to be a specialized * version of the general Xapian query syntax: * - * http://xapian.org/docs/queryparser.html + * https://xapian.org/docs/queryparser.html * * As a special case, passing either a length-zero string, (that is ""), * or a string consisting of a single asterisk (that is "*"), will diff --git a/bindings/python/README b/bindings/python/README index b20ae071..fe7a2181 100644 --- a/bindings/python/README +++ b/bindings/python/README @@ -2,7 +2,7 @@ notmuch -- The python interface to notmuch ========================================== This module makes the functionality of the notmuch library -(`http://notmuchmail.org`_) available to python. Successful import of +(`https://notmuchmail.org`_) available to python. Successful import of this modul depends on a libnotmuch.so|dll being available on the user's system. @@ -10,7 +10,7 @@ If you have downloaded the full source tarball, you can create the documentation with sphinx installed, go to the docs directory and "make html". A static version of the documentation is available at: - https://notmuch.readthedocs.org/projects/notmuch-python/ + https://notmuch.readthedocs.io/projects/notmuch-python/ To build the python bindings, do diff --git a/bindings/python/docs/COPYING b/bindings/python/docs/COPYING index 94a9ed02..2a000655 100644 --- a/bindings/python/docs/COPYING +++ b/bindings/python/docs/COPYING @@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found. GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see -. +. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. diff --git a/bindings/python/docs/source/index.rst b/bindings/python/docs/source/index.rst index 1cece5f7..bef7e60d 100644 --- a/bindings/python/docs/source/index.rst +++ b/bindings/python/docs/source/index.rst @@ -4,7 +4,7 @@ Welcome to :mod:`notmuch`'s documentation .. currentmodule:: notmuch The :mod:`notmuch` module provides an interface to the `notmuch -`_ functionality, directly interfacing to a +`_ functionality, directly interfacing to a shared notmuch library. Within :mod:`notmuch`, the classes :class:`Database`, :class:`Query` provide most of the core functionality, returning :class:`Threads`, :class:`Messages` and diff --git a/bindings/python/notmuch/__init__.py b/bindings/python/notmuch/__init__.py index 29416a5b..cf627ffa 100644 --- a/bindings/python/notmuch/__init__.py +++ b/bindings/python/notmuch/__init__.py @@ -47,7 +47,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010-2011 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/compat.py b/bindings/python/notmuch/compat.py index daa268c1..c931329e 100644 --- a/bindings/python/notmuch/compat.py +++ b/bindings/python/notmuch/compat.py @@ -16,7 +16,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth Copyright 2012 Justus Winter <4winter@informatik.uni-hamburg.de> diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py index f3045334..67fb1c41 100644 --- a/bindings/python/notmuch/database.py +++ b/bindings/python/notmuch/database.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/directory.py b/bindings/python/notmuch/directory.py index 3b0a525d..7f86b1ac 100644 --- a/bindings/python/notmuch/directory.py +++ b/bindings/python/notmuch/directory.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/errors.py b/bindings/python/notmuch/errors.py index abca51d7..b7684ef6 100644 --- a/bindings/python/notmuch/errors.py +++ b/bindings/python/notmuch/errors.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/filenames.py b/bindings/python/notmuch/filenames.py index f8f383e4..29f4fdf6 100644 --- a/bindings/python/notmuch/filenames.py +++ b/bindings/python/notmuch/filenames.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py index 6872a291..b1eec2cf 100644 --- a/bindings/python/notmuch/globals.py +++ b/bindings/python/notmuch/globals.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index d1c1b58c..bf809008 100644 --- a/bindings/python/notmuch/message.py +++ b/bindings/python/notmuch/message.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth Jesse Rosenthal diff --git a/bindings/python/notmuch/messages.py b/bindings/python/notmuch/messages.py index 76100ffb..e17f1507 100644 --- a/bindings/python/notmuch/messages.py +++ b/bindings/python/notmuch/messages.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth Jesse Rosenthal diff --git a/bindings/python/notmuch/query.py b/bindings/python/notmuch/query.py index 43270072..a0f4f64b 100644 --- a/bindings/python/notmuch/query.py +++ b/bindings/python/notmuch/query.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py index 1d523457..3b4a56ac 100644 --- a/bindings/python/notmuch/tag.py +++ b/bindings/python/notmuch/tag.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/thread.py b/bindings/python/notmuch/thread.py index 0454dbd4..cc151f7e 100644 --- a/bindings/python/notmuch/thread.py +++ b/bindings/python/notmuch/thread.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/notmuch/threads.py b/bindings/python/notmuch/threads.py index a550523f..86f1f2cc 100644 --- a/bindings/python/notmuch/threads.py +++ b/bindings/python/notmuch/threads.py @@ -12,7 +12,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ diff --git a/bindings/python/setup.py b/bindings/python/setup.py index f4c338e3..d986f0c6 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -14,7 +14,7 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with notmuch. If not, see . +along with notmuch. If not, see . Copyright 2010 Sebastian Spaeth """ @@ -34,21 +34,21 @@ setup(name='notmuch', description='Python binding of the notmuch mail search and indexing library.', author='Sebastian Spaeth', author_email='Sebastian@SSpaeth.de', - url='http://notmuchmail.org/', - download_url='http://notmuchmail.org/releases/notmuch-%s.tar.gz' % __VERSION__, + url='https://notmuchmail.org/', + download_url='https://notmuchmail.org/releases/notmuch-%s.tar.gz' % __VERSION__, packages=['notmuch'], keywords=['library', 'email'], long_description='''Overview ======== The notmuch module provides an interface to the `notmuch -`_ functionality, directly interfacing with a +`_ functionality, directly interfacing with a shared notmuch library. Notmuch provides a maildatabase that allows for extremely quick searching and filtering of your email according to various criteria. The documentation for the latest notmuch release can be `viewed -online `_. +online `_. Requirements ------------ @@ -66,5 +66,5 @@ python >= 2.5. It will not work on earlier python versions. 'Topic :: Software Development :: Libraries' ], platforms='', - license='http://www.gnu.org/licenses/gpl-3.0.txt', + license='https://www.gnu.org/licenses/gpl-3.0.txt', ) diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index c03d7011..12e6bab7 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ @@ -374,6 +374,30 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv) return Qnil; } +/* + * call-seq: DB.get_all_tags() => TAGS + * + * Returns a list of all tags found in the database. + */ +VALUE +notmuch_rb_database_get_all_tags (VALUE self) +{ + notmuch_database_t *db; + notmuch_tags_t *tags; + + Data_Get_Notmuch_Database (self, db); + + tags = notmuch_database_get_all_tags (db); + if (!tags) { + const char *msg = notmuch_database_status_string (db); + if (!msg) + msg = "Unknown notmuch error"; + + rb_raise (notmuch_rb_eBaseError, "%s", msg); + } + return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); +} + /* * call-seq: DB.query(query) => QUERY * diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index f4901a04..48544ca2 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ @@ -177,6 +177,9 @@ notmuch_rb_database_find_message (VALUE self, VALUE idv); VALUE notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv); +VALUE +notmuch_rb_database_get_all_tags (VALUE self); + VALUE notmuch_rb_database_query_create (VALUE self, VALUE qstrv); diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c index 303523c2..0f37b391 100644 --- a/bindings/ruby/directory.c +++ b/bindings/ruby/directory.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/filenames.c b/bindings/ruby/filenames.c index e2785903..656c58e6 100644 --- a/bindings/ruby/filenames.c +++ b/bindings/ruby/filenames.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index ab3f22df..5556b43e 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ @@ -229,6 +229,7 @@ Init_notmuch (void) notmuch_rb_database_find_message, 1); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "find_message_by_filename", notmuch_rb_database_find_message_by_filename, 1); /* in database.c */ + rb_define_method (notmuch_rb_cDatabase, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */ rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */ /* diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c index 4ff6097f..c55cf6e2 100644 --- a/bindings/ruby/message.c +++ b/bindings/ruby/message.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/messages.c b/bindings/ruby/messages.c index 443a30c9..a337feeb 100644 --- a/bindings/ruby/messages.c +++ b/bindings/ruby/messages.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 8cbc73f2..ce66926c 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/status.c b/bindings/ruby/status.c index b11fb9fb..a0f88633 100644 --- a/bindings/ruby/status.c +++ b/bindings/ruby/status.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/tags.c b/bindings/ruby/tags.c index e8226ad7..db8b4cfc 100644 --- a/bindings/ruby/tags.c +++ b/bindings/ruby/tags.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c index 56616d9f..9b295981 100644 --- a/bindings/ruby/thread.c +++ b/bindings/ruby/thread.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/bindings/ruby/threads.c b/bindings/ruby/threads.c index 3e1fbf5d..ed403a8f 100644 --- a/bindings/ruby/threads.c +++ b/bindings/ruby/threads.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ali Polatel */ diff --git a/compat/compat.h b/compat/compat.h index 634d505b..88bc4df4 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/compat/function-attributes.h b/compat/function-attributes.h index 8450a17d..1945b5bf 100644 --- a/compat/function-attributes.h +++ b/compat/function-attributes.h @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . */ #ifndef FUNCTION_ATTRIBUTES_H diff --git a/completion/README b/completion/README index e200c189..89805c72 100644 --- a/completion/README +++ b/completion/README @@ -9,7 +9,7 @@ notmuch-completion.bash bash-completion package [1] version 2.0, which depends on bash version 3.2 or later. - [1] http://bash-completion.alioth.debian.org/ + [1] https://github.com/scop/bash-completion notmuch-completion.zsh diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index cc583924..78047b5f 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -3,7 +3,7 @@ # Copyright © 2013 Jani Nikula # # Based on the bash-completion package: -# http://bash-completion.alioth.debian.org/ +# https://github.com/scop/bash-completion # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . # # Author: Jani Nikula # diff --git a/configure b/configure index 4fc31ccf..ae0a0270 100755 --- a/configure +++ b/configure @@ -1,5 +1,7 @@ #! /bin/sh +set -u + # Test whether this shell is capable of parameter substring processing. ( option='a/b'; : ${option#*/} ) 2>/dev/null || { echo " @@ -70,6 +72,7 @@ WITH_EMACS=1 WITH_BASH=1 WITH_RUBY=1 WITH_ZSH=1 +WITH_RETRY_LOCK=1 usage () { @@ -138,6 +141,7 @@ Some features can be disabled (--with-feature=no is equivalent to --without-emacs Do not install lisp file --without-ruby Do not install ruby bindings --without-zsh-completion Do not install zsh completions files + --without-retry-lock Do not use blocking xapian opens, even if available Additional options are accepted for compatibility with other configure-script calling conventions, but don't do anything yet: @@ -209,6 +213,14 @@ for option; do fi elif [ "${option}" = '--without-ruby' ] ; then WITH_RUBY=0 + elif [ "${option%%=*}" = '--with-retry-lock' ]; then + if [ "${option#*=}" = 'no' ]; then + WITH_RETRY_LOCK=0 + else + WITH_RETRY_LOCK=1 + fi + elif [ "${option}" = '--without-retry-lock' ] ; then + WITH_RETRY_LOCK=0 elif [ "${option%%=*}" = '--with-zsh-completion' ]; then if [ "${option#*=}" = 'no' ]; then WITH_ZSH=0 @@ -250,7 +262,7 @@ if [ -z "$LIBDIR" ] ; then libdir_expanded="${PREFIX}/lib" else # very non-general variable expansion - libdir_expanded=`echo "$LIBDIR" | sed "s|\\${prefix}|${PREFIX}|g; s|\\$prefix/|${PREFIX}/|; s|//*|/|g"` + libdir_expanded=$(echo "$LIBDIR" | sed "s|\\${prefix}|${PREFIX}|g; s|\\$prefix/|${PREFIX}/|; s|//*|/|g") fi cat < 1.2.6 have_xapian_compact=0 +have_xapian_field_processor=0 if [ ${have_xapian} = "1" ]; then printf "Checking for Xapian compaction support... " - case "${xapian_version}" in - 0.*|1.[01].*|1.2.[0-5]) - printf "No (only available with Xapian > 1.2.6).\n" ;; - [1-9]*.[0-9]*.[0-9]*) - have_xapian_compact=1 - printf "Yes.\n" ;; - *) - printf "Unknown version.\n" ;; - esac -fi + cat>_compact.cc< +class TestCompactor : public Xapian::Compactor { }; +EOF + if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _compact.cc -o _compact.o > /dev/null 2>&1 + then + have_xapian_compact=1 + printf "Yes.\n" + else + printf "No.\n" + fi + + rm -f _compact.o _compact.cc + + printf "Checking for Xapian FieldProcessor API... " + cat>_field_processor.cc< +class TitleFieldProcessor : public Xapian::FieldProcessor { }; +EOF + if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _field_processor.cc -o _field_processor.o > /dev/null 2>&1 + then + have_xapian_field_processor=1 + printf "Yes.\n" + else + printf "No. (optional)\n" + fi + + rm -f _field_processor.o _field_processor.cc + + default_xapian_backend="" + # DB_RETRY_LOCK is only supported on Xapian > 1.3.2 + have_xapian_db_retry_lock=0 + if [ $WITH_RETRY_LOCK = "1" ]; then + printf "Checking for Xapian lock retry support... " + cat>_retry.cc< +int flag = Xapian::DB_RETRY_LOCK; +EOF + if ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} -c _retry.cc -o _retry.o > /dev/null 2>&1 + then + have_xapian_db_retry_lock=1 + printf "Yes.\n" + else + printf "No. (optional)\n" + fi + rm -f _retry.o _retry.cc + fi -default_xapian_backend="" -if [ ${have_xapian} = "1" ]; then printf "Testing default Xapian backend... " cat >_default_backend.cc < @@ -380,16 +427,17 @@ int main(int argc, char** argv) { Xapian::WritableDatabase db("test.db",Xapian::DB_CREATE_OR_OPEN); } EOF - ${CXX} ${CXXLAGS} ${xapian_cxxflags} _default_backend.cc -o _default_backend ${xapian_ldflags} + ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} _default_backend.cc -o _default_backend ${xapian_ldflags} ./_default_backend if [ -f test.db/iamglass ]; then default_xapian_backend=glass else default_xapian_backend=chert fi - printf "${default_xapian_backend}\n"; + printf "%s\n" "${default_xapian_backend}"; rm -rf test.db _default_backend _default_backend.cc fi + # we need to have a version >= 2.6.5 to avoid a crypto bug. We need # 2.6.7 for permissive "From " header handling. GMIME_MINVER=2.6.7 @@ -413,8 +461,9 @@ have_glib=0 if pkg-config --exists 'glib-2.0 >= 2.22'; then printf "Yes.\n" have_glib=1 - glib_cflags=$(pkg-config --cflags glib-2.0) - glib_ldflags=$(pkg-config --libs glib-2.0) + # these are included in gmime cflags and ldflags + # glib_cflags=$(pkg-config --cflags glib-2.0) + # glib_ldflags=$(pkg-config --libs glib-2.0) else printf "No.\n" errors=$((errors + 1)) @@ -461,7 +510,7 @@ for name in ${PYTHON} python python2 python3; do if command -v $name > /dev/null; then have_python=1 python=$name - printf "Yes ($name).\n" + printf "Yes (%s).\n" "$name" break fi done @@ -479,6 +528,7 @@ if pkg-config --exists valgrind; then else printf "No (but that's fine).\n" have_valgrind=0 + valgrind_cflags= fi printf "Checking for bash-completion (>= 1.90)... " @@ -489,12 +539,12 @@ else WITH_BASH=0 fi -if [ -z "${EMACSLISPDIR}" ]; then - EMACSLISPDIR='$(prefix)/share/emacs/site-lisp' +if [ -z "${EMACSLISPDIR-}" ]; then + EMACSLISPDIR="\$(prefix)/share/emacs/site-lisp" fi -if [ -z "${EMACSETCDIR}" ]; then - EMACSETCDIR='$(prefix)/share/emacs/site-lisp' +if [ -z "${EMACSETCDIR-}" ]; then + EMACSETCDIR="\$(prefix)/share/emacs/site-lisp" fi printf "Checking if emacs is available... " @@ -542,7 +592,7 @@ fi libdir_in_ldconfig=0 printf "Checking which platform we are on... " -uname=`uname` +uname=$(uname) if [ $uname = "Darwin" ] ; then printf "Mac OS X.\n" platform=MACOSX @@ -560,11 +610,11 @@ elif [ $uname = "OpenBSD" ] ; then platform=OPENBSD linker_resolves_library_dependencies=0 elif [ $uname = "Linux" ] || [ $uname = "GNU" ] ; then - printf "$uname\n" + printf "%s\n" "$uname" platform="$uname" linker_resolves_library_dependencies=1 - printf "Checking for $libdir_expanded in ldconfig... " + printf "Checking for %s in ldconfig... " "$libdir_expanded" ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p') # Separate ldconfig_paths only on newline (not on any potential # embedded space characters in any filenames). Note, we use a @@ -621,7 +671,7 @@ EOF fi if [ $have_xapian -eq 0 ]; then echo " Xapian library (including development files such as headers)" - echo " http://xapian.org/" + echo " https://xapian.org/" fi if [ $have_zlib -eq 0 ]; then echo " zlib library (>= version 1.2.5.2, including development files such as headers)" @@ -641,7 +691,7 @@ EOF fi if [ $have_talloc -eq 0 ]; then echo " The talloc library (including development files such as headers)" - echo " http://talloc.samba.org/" + echo " https://talloc.samba.org/" echo fi cat < sh.config <. notmuch-mutt is released under the terms of the GNU General Public License (GPL), version 3 or above. A copy of the license is available online at -. +. diff --git a/contrib/notmuch-mutt/notmuch-mutt b/contrib/notmuch-mutt/notmuch-mutt index 97fb2d85..0e46a8c1 100755 --- a/contrib/notmuch-mutt/notmuch-mutt +++ b/contrib/notmuch-mutt/notmuch-mutt @@ -91,7 +91,7 @@ sub get_message_id() { $mid = $1; } else { # Message-ID header not found, synthesize a message id # based on SHA1, as notmuch would do. See: - # http://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c + # https://git.notmuchmail.org/git/notmuch/blob/HEAD:/lib/sha1.c my $sha = Digest::SHA->new(1); $sha->add($_) foreach(@headers); $sha->addfile(\*STDIN); diff --git a/contrib/notmuch-vim/plugin/notmuch.vim b/contrib/notmuch-vim/plugin/notmuch.vim index 8f27fb92..eaa984bc 100644 --- a/contrib/notmuch-vim/plugin/notmuch.vim +++ b/contrib/notmuch-vim/plugin/notmuch.vim @@ -15,7 +15,7 @@ " General Public License for more details. " " You should have received a copy of the GNU General Public License -" along with Notmuch. If not, see . +" along with Notmuch. If not, see . " " Authors: Bart Trojanowski " Contributors: Felipe Contreras , @@ -1198,7 +1198,7 @@ function! s:NM_shell_escape(word) endfunction " this function was taken from git.vim, then fixed up -" http://github.com/motemen/git-vim +" https://github.com/motemen/git-vim function! s:NM_shell_split(cmd) let l:split_cmd = [] let cmd = a:cmd diff --git a/crypto.c b/crypto.c index 3dabc97b..3e8ce7ca 100644 --- a/crypto.c +++ b/crypto.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Authors: Jameson Rollins */ diff --git a/debian/control b/debian/control index 2cd24213..4027a79b 100644 --- a/debian/control +++ b/debian/control @@ -27,9 +27,9 @@ Build-Depends: gnupg , bash-completion (>=1.9.0~) Standards-Version: 3.9.6 -Homepage: http://notmuchmail.org/ +Homepage: https://notmuchmail.org/ Vcs-Git: git://notmuchmail.org/git/notmuch -Vcs-Browser: http://git.notmuchmail.org/git/notmuch +Vcs-Browser: https://git.notmuchmail.org/git/notmuch Package: notmuch Architecture: any diff --git a/debugger.c b/debugger.c index e8b9378e..0fa0fb6b 100644 --- a/debugger.c +++ b/debugger.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Chris Wilson */ diff --git a/devel/man-to-mdwn.pl b/devel/man-to-mdwn.pl index ea284d08..a3c40695 100755 --- a/devel/man-to-mdwn.pl +++ b/devel/man-to-mdwn.pl @@ -66,7 +66,7 @@ while (my ($k, $v) = each %fhash) my @lines; open I, '-|', qw/env -i/, "PATH=$ENV{PATH}", - qw/TERM=vt100 LANG=en_US.utf8 LC_ALL=en_US.utf8/, + qw/TERM=vt100 LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8/, qw/GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 MANWIDTH=80/, qw/man/, $v or die "$!"; binmode I, ':utf8'; @@ -200,6 +200,6 @@ foreach (sort srt values %fhash) print <<'EOF'; The manual pages are licensed under -[the GNU General Public License](http://www.gnu.org/licenses/gpl.txt), +[the GNU General Public License](https://www.gnu.org/licenses/gpl.txt), either version 3.0 or at your option any later version. EOF diff --git a/devel/nmbug/doc/man5/notmuch-report.json.5.rst b/devel/nmbug/doc/man5/notmuch-report.json.5.rst index 4b5f84a8..1207a4aa 100644 --- a/devel/nmbug/doc/man5/notmuch-report.json.5.rst +++ b/devel/nmbug/doc/man5/notmuch-report.json.5.rst @@ -92,7 +92,7 @@ EXAMPLE { "meta": { "title": "Notmuch Patches", - "blurb": "For more information see nmbug", + "blurb": "For more information see nmbug", "header": "

{title}

{blurb}

Views

", "footer": "

Generated: {datetime}

", "message-url": "http://mid.gmane.org/{message-id}" diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug index 0787b2ba..1dd5f14f 100755 --- a/devel/nmbug/nmbug +++ b/devel/nmbug/nmbug @@ -14,7 +14,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . """ Manage notmuch tags with Git @@ -80,7 +80,7 @@ except AttributeError: # Python < 3.2 See PEP 343 for details on context managers [1]. - [1]: http://legacy.python.org/dev/peps/pep-0343/ + [1]: https://www.python.org/dev/peps/pep-0343/ """ def __init__(self, **kwargs): self.name = _tempfile.mkdtemp(**kwargs) @@ -119,9 +119,9 @@ def _xapian_quote(string): Xapian uses double-quotes for quoting strings. You can escape internal quotes by repeating them [1,2,3]. - [1]: http://trac.xapian.org/ticket/128#comment:2 - [2]: http://trac.xapian.org/ticket/128#comment:17 - [3]: http://trac.xapian.org/changeset/13823/svn + [1]: https://trac.xapian.org/ticket/128#comment:2 + [2]: https://trac.xapian.org/ticket/128#comment:17 + [3]: https://trac.xapian.org/changeset/13823/svn """ return '"{0}"'.format(string.replace('"', '""')) diff --git a/devel/nmbug/notmuch-report b/devel/nmbug/notmuch-report index 87390c1e..a9c2a6ec 100755 --- a/devel/nmbug/notmuch-report +++ b/devel/nmbug/notmuch-report @@ -17,7 +17,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . """Generate text and/or HTML for one or more notmuch searches. diff --git a/devel/nmbug/notmuch-report.json b/devel/nmbug/notmuch-report.json index 48b6f19f..c5b35b17 100644 --- a/devel/nmbug/notmuch-report.json +++ b/devel/nmbug/notmuch-report.json @@ -1,7 +1,7 @@ { "meta": { "title": "Notmuch Patches", - "blurb": "For more information see nmbug" + "blurb": "For more information see nmbug" }, "views": [ diff --git a/devel/try-emacs-mua b/devel/try-emacs-mua index b0a62c25..041f6216 100755 --- a/devel/try-emacs-mua +++ b/devel/try-emacs-mua @@ -7,7 +7,7 @@ ;; ;; Authors: Tomi Ollila ;; -;; http://www.emacswiki.org/emacs/EmacsScripts was a useful starting point... +;; https://www.emacswiki.org/emacs/EmacsScripts was a useful starting point... ;; ;; Licence: GPLv3+ ;; diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg index c033f344..2ca15d41 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -177,7 +177,7 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES USE_MATHJAX = NO MATHJAX_FORMAT = HTML-CSS -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = https://cdn.mathjax.org/mathjax/latest MATHJAX_EXTENSIONS = MATHJAX_CODEFILE = SEARCHENGINE = YES diff --git a/doc/index.rst b/doc/index.rst index 3f0e6e65..344606d9 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -14,6 +14,7 @@ Contents: man1/notmuch-count man1/notmuch-dump notmuch-emacs + man1/notmuch-emacs-mua man5/notmuch-hooks man1/notmuch-insert man1/notmuch-new diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst index 40c12721..5a517ebd 100644 --- a/doc/man1/notmuch-config.rst +++ b/doc/man1/notmuch-config.rst @@ -132,6 +132,17 @@ The available configuration items are described below. Default: ``gpg``. + **built_with.** + + Compile time feature . Current possibilities include + "compact" (see **notmuch-compact(1)**) + and "field_processor" (see **notmuch-search-terms(7)**). + + **query.** + + Expansion for named query called . See + **notmuch-search-terms(7)** for more information about named + queries. ENVIRONMENT =========== diff --git a/doc/man1/notmuch-dump.rst b/doc/man1/notmuch-dump.rst index a37c337c..94986a86 100644 --- a/doc/man1/notmuch-dump.rst +++ b/doc/man1/notmuch-dump.rst @@ -71,6 +71,31 @@ Supported options for **dump** include characters. Note also that tags with spaces will not be correctly restored with this format. + ``--include=(config|tags)`` + + Control what kind of metadata is included in the output. + + **config** + + Output configuration data stored in the database. Each line + starts with "#@ ", followed by a space seperated key-value + pair. Both key and value are hex encoded if needed. + + **tags** + + Output per-message metadata, namely tags. See *format* above + for description of the output. + + The default is to include both tags and configuration + information. As of version 2 of the dump format, there is a + header line of the following form + + | + | #notmuch-dump <*format*>:<*version*> <*included*> + + where <*included*> is a comma separated list of the above + options. + ``--output=``\ Write output to given file instead of stdout. diff --git a/doc/man1/notmuch-restore.rst b/doc/man1/notmuch-restore.rst index 362e2629..87fa22ef 100644 --- a/doc/man1/notmuch-restore.rst +++ b/doc/man1/notmuch-restore.rst @@ -50,6 +50,24 @@ Supported options for **restore** include format, this heuristic, based the fact that batch-tag format contains no parentheses, should be accurate. + ``--include=(config|tags)`` + + Control what kind of metadata is restored. + + **config** + + Restore configuration data to the database. Each configuration line starts + with "#@ ", followed by a space seperated key-value pair. + Both key and value are hex encoded if needed. + + **tags** + + Output per-message metadata, namely tags. See *format* above + for more details. + + The default is to restore both tags and configuration + information + ``--input=``\ Read input from given file instead of stdin. diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst index 3acfbdb4..edd04efb 100644 --- a/doc/man1/notmuch.rst +++ b/doc/man1/notmuch.rst @@ -29,7 +29,7 @@ While the command-line program ``notmuch`` provides powerful functionality, it does not provide the most convenient interface for that functionality. More sophisticated interfaces are expected to be built on top of either the command-line interface, or more likely, on -top of the notmuch library interface. See http://notmuchmail.org for +top of the notmuch library interface. See https://notmuchmail.org for more about alternate interfaces to notmuch. The emacs-based interface to notmuch (available under **emacs/** in the Notmuch source distribution) is probably the most widely used at this time. @@ -144,7 +144,7 @@ SEE ALSO **notmuch-search-terms(7)**, **notmuch-show(1)**, **notmuch-tag(1)**, **notmuch-address(1)** -The notmuch website: **http://notmuchmail.org** +The notmuch website: **https://notmuchmail.org** CONTACT ======= diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst index 2fbc16d1..075f88c8 100644 --- a/doc/man7/notmuch-search-terms.rst +++ b/doc/man7/notmuch-search-terms.rst @@ -56,6 +56,8 @@ indicate user-supplied values): - lastmod:.. +- query: + The **from:** prefix is used to match the name or address of the sender of an email message. @@ -132,6 +134,11 @@ were added/removed or filenames changed). This is usually used in conjunction with the **--uuid** argument to **notmuch search** to find messages that have changed since an earlier query. +The **query:** prefix allows queries to refer to previously saved +queries added with **notmuch-config(1)**. Named queries are only +available if notmuch is built with **Xapian Field Processors** (see +below). + Operators --------- @@ -208,15 +215,11 @@ Boolean and Probabilistic Prefixes Xapian (and hence notmuch) prefixes are either **boolean**, supporting exact matches like "tag:inbox" or **probabilistic**, supporting a more flexible **term** based searching. The prefixes currently supported by notmuch are as follows. -+------------------+-----------------------+ -|Boolean |Probabilistic | -+------------------+-----------------------+ -| **tag:** **id:** | **from:** **to:** | -|**thread:** |**subject:** | -|**folder:** |**attachment:** | -|**path:** |**mimetype:** | -| | | -+------------------+-----------------------+ + +Boolean + **tag:**, **id:**, **thread:**, **folder:**, **path:** +Probabilistic + **from:**, **to:**, **subject:**, **attachment:**, **mimetype:** Terms and phrases ----------------- @@ -281,9 +284,10 @@ matches from the beginning of January to the end of February. date:..! can be used as a shorthand for date:... The expansion takes place before interpretation, and thus, for example, date:monday..! matches from the beginning of Monday until the end of -Monday. (Note that entering date: without "..", for example -date:yesterday, won't work, as it's not interpreted as a range -expression at all. Again, use date:yesterday..!) +Monday. +With **Xapian Field Processor** support (see below), non-range +date queries such as date:yesterday will work, but otherwise +will give unexpected results; if in doubt use date:yesterday..! Currently, we do not support spaces in range expressions. You can replace the spaces with '\_', or (in most cases) '-', or (in some cases) @@ -370,6 +374,22 @@ Time zones Some time zone codes, e.g. UTC, EET. +XAPIAN FIELD PROCESSORS +======================= + +Certain optional features of the notmuch query processor rely on the +presence of the Xapian field processor API. You can determine if your +notmuch was built against a sufficiently recent version of Xapian by running + +:: + + % notmuch config get built_with.field_processor + +Currently the following features require field processor support: + +- non-range date queries, e.g. "date:today" +- named queries e.g. "query:my_special_query" + SEE ALSO ======== diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index 6f2f61e9..d68542d3 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -42,11 +42,8 @@ a mouse or by positioning the cursor and pressing ```` | | All tags: **[show]** | -| Type a search query and hit RET to view matching threads. -| Edit saved searches with the ``edit`` button. -| Hit RET or click on a saved search or tag name to view matching threads. -| ``=`` to refresh this screen. ``s`` to search messages. ``q`` to quit. -| **Customize** this page. +| Hit \`?' for context-sensitive help in any Notmuch screen. +| Customize Notmuch or this page. You can change the overall appearance of the notmuch-hello screen by customizing the variable :index:`notmuch-hello-sections`. diff --git a/emacs/coolj.el b/emacs/coolj.el index 77550602..350d537f 100644 --- a/emacs/coolj.el +++ b/emacs/coolj.el @@ -21,7 +21,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . +;; along with GNU Emacs. If not, see . ;;; Commentary: diff --git a/emacs/make-deps.el b/emacs/make-deps.el index 24c1a457..5b6db698 100644 --- a/emacs/make-deps.el +++ b/emacs/make-deps.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Austin Clements diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index aafbe5fb..d372fbaf 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Edmondson @@ -249,6 +249,25 @@ called when harvesting finishes." ;; +(defun notmuch-address-from-minibuffer (prompt) + (if (not notmuch-address-command) + (read-string prompt) + (let ((rmap (copy-keymap minibuffer-local-map)) + (omap minibuffer-local-map)) + ;; Configure TAB to start completion when executing read-string. + ;; "Original" minibuffer keymap is restored just before calling + ;; notmuch-address-expand-name as it may also use minibuffer-local-map + ;; (completing-read probably does not but if something else is used there). + (define-key rmap (kbd "TAB") (lambda () + (interactive) + (let ((enable-recursive-minibuffers t) + (minibuffer-local-map omap)) + (notmuch-address-expand-name)))) + (let ((minibuffer-local-map rmap)) + (read-string prompt))))) + +;; + (provide 'notmuch-address) ;;; notmuch-address.el ends here diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el index b881d6dc..0619c7ef 100644 --- a/emacs/notmuch-company.el +++ b/emacs/notmuch-company.el @@ -16,7 +16,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . +;; along with this program. If not, see . ;;; Commentary: diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index 004463c3..e376aa80 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Jameson Rollins diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 9495c1a4..75ccf579 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Edmondson @@ -265,7 +265,7 @@ International Bureau of Weights and Measures." :group 'notmuch-hello :group 'notmuch-hooks) -(defvar notmuch-hello-url "http://notmuchmail.org" +(defvar notmuch-hello-url "https://notmuchmail.org" "The `notmuch' web site.") (defvar notmuch-hello-custom-section-options diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index fd770f1e..963253c9 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Austin Clements ;; David Edmondson diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index f05ded6f..1781af48 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Carl Worth diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el index d437b857..55e4cfee 100644 --- a/emacs/notmuch-message.el +++ b/emacs/notmuch-message.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Jesse Rosenthal diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 399e1380..1ca80564 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Edmondson @@ -142,7 +142,7 @@ mutiple parts get a header." (let ((notmuch-version (if (string= notmuch-emacs-version "unknown") (notmuch-cli-version) notmuch-emacs-version))) - (concat "Notmuch/" notmuch-version " (http://notmuchmail.org)"))) + (concat "Notmuch/" notmuch-version " (https://notmuchmail.org)"))) (defun notmuch-mua-user-agent-emacs () "Generate a `User-Agent:' string suitable for notmuch." @@ -334,7 +334,7 @@ modified. This function is notmuch addaptation of ;; C-h f compose-mail says that headers should be specified as ;; (string . value); however all the rest of message expects ;; headers to be symbols, not strings (eg message-header-format-alist). - ;; http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00337.html + ;; https://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00337.html ;; We need to convert any string input, eg from rmail-start-mail. (dolist (h other-headers other-headers) (if (stringp (car h)) (setcar h (intern (capitalize (car h)))))))) diff --git a/emacs/notmuch-parser.el b/emacs/notmuch-parser.el index 620ca89d..bb0379c1 100644 --- a/emacs/notmuch-parser.el +++ b/emacs/notmuch-parser.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Austin Clements diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el index 480a0cfe..bca759fa 100644 --- a/emacs/notmuch-print.el +++ b/emacs/notmuch-print.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Edmondson diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el index 8587d881..436ad160 100644 --- a/emacs/notmuch-query.el +++ b/emacs/notmuch-query.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Bremner diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 5d9b7b45..6d3149bf 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -16,7 +16,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Carl Worth ;; David Edmondson @@ -182,9 +182,9 @@ each attachment handler is logged in buffers with names beginning (defcustom notmuch-show-stash-mlarchive-link-alist '(("Gmane" . "http://mid.gmane.org/") - ("MARC" . "http://marc.info/?i=") - ("Mail Archive, The" . "http://mid.mail-archive.com/") - ("LKML" . "http://lkml.kernel.org/r/") + ("MARC" . "https://marc.info/?i=") + ("Mail Archive, The" . "https://mid.mail-archive.com/") + ("LKML" . "https://lkml.kernel.org/r/") ;; FIXME: can these services be searched by `Message-Id' ? ;; ("MarkMail" . "http://markmail.org/") ;; ("Nabble" . "http://nabble.com/") @@ -1418,6 +1418,7 @@ reset based on the original query." (define-key map (kbd "TAB") 'notmuch-show-next-button) (define-key map "f" 'notmuch-show-forward-message) (define-key map "F" 'notmuch-show-forward-open-messages) + (define-key map "b" 'notmuch-show-resend-message) (define-key map "l" 'notmuch-show-filter-thread) (define-key map "r" 'notmuch-show-reply-sender) (define-key map "R" 'notmuch-show-reply) @@ -1700,12 +1701,23 @@ user decision and we should not override it." (notmuch-show-mark-read) (notmuch-show-set-prop :seen t))) +(defvar notmuch-show--seen-has-errored nil) +(make-variable-buffer-local 'notmuch-show--seen-has-errored) + (defun notmuch-show-command-hook () (when (eq major-mode 'notmuch-show-mode) ;; We need to redisplay to get window-start and window-end correct. (redisplay) (save-excursion - (funcall notmuch-show-mark-read-function (window-start) (window-end))))) + (condition-case err + (funcall notmuch-show-mark-read-function (window-start) (window-end)) + ((debug error) + (unless notmuch-show--seen-has-errored + (setq notmuch-show--seen-has-errored 't) + (setq header-line-format + (concat header-line-format + (propertize " [some mark read tag changes may have failed]" + 'face font-lock-warning-face))))))))) (defun notmuch-show-filter-thread (query) "Filter or LIMIT the current thread based on a new query string. @@ -1855,6 +1867,14 @@ any effects from previous calls to (error "No open messages to forward.")) (notmuch-mua-new-forward-messages open-messages prompt-for-sender))) +(defun notmuch-show-resend-message (addresses) + "Resend the current message." + (interactive (list (notmuch-address-from-minibuffer "Resend to: "))) + (when (y-or-n-p (concat "Confirm resend to " addresses " ")) + (notmuch-show-view-raw-message) + (message-resend addresses) + (notmuch-bury-or-kill-this-buffer))) + (defun notmuch-show-next-message (&optional pop-at-end) "Show the next message. diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index 98064a3b..a3f0c52a 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -16,7 +16,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Carl Worth ;; Damien Cassou diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 4f9ca2de..52313199 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -17,7 +17,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: David Edmondson ;; Mark Walters diff --git a/emacs/notmuch-version.el.tmpl b/emacs/notmuch-version.el.tmpl index 88cc01ce..abf52f17 100644 --- a/emacs/notmuch-version.el.tmpl +++ b/emacs/notmuch-version.el.tmpl @@ -16,7 +16,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;;; Code: diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el index 065af16f..57e6dfa3 100644 --- a/emacs/notmuch-wash.el +++ b/emacs/notmuch-wash.el @@ -16,7 +16,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Carl Worth ;; David Edmondson diff --git a/emacs/notmuch.el b/emacs/notmuch.el index a8a4c8e5..8acdef37 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -15,7 +15,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Carl Worth ;; Homepage: https://notmuchmail.org/ @@ -26,7 +26,7 @@ ;; ;; You will first need to have the notmuch program installed and have a ;; notmuch database built in order to use this. See -;; http://notmuchmail.org for details. +;; https://notmuchmail.org for details. ;; ;; To install this software, copy it to a directory that is on the ;; `load-path' variable within emacs (a good candidate is @@ -48,7 +48,7 @@ ;; ;; Have fun, and let us know if you have any comment, questions, or ;; kudos: Notmuch list (subscription is not -;; required, but is available from http://notmuchmail.org). +;; required, but is available from https://notmuchmail.org). ;;; Code: diff --git a/hooks.c b/hooks.c index 662629a9..7348d322 100644 --- a/hooks.c +++ b/hooks.c @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Jani Nikula */ diff --git a/lib/Makefile.local b/lib/Makefile.local index 3a070907..beb96358 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -39,6 +39,7 @@ libnotmuch_c_srcs = \ $(dir)/message-file.c \ $(dir)/messages.c \ $(dir)/sha1.c \ + $(dir)/built-with.c \ $(dir)/tags.c libnotmuch_cxx_srcs = \ @@ -48,6 +49,8 @@ libnotmuch_cxx_srcs = \ $(dir)/index.cc \ $(dir)/message.cc \ $(dir)/query.cc \ + $(dir)/query-fp.cc \ + $(dir)/config.cc \ $(dir)/thread.cc libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o) diff --git a/lib/built-with.c b/lib/built-with.c new file mode 100644 index 00000000..2f1f0b5c --- /dev/null +++ b/lib/built-with.c @@ -0,0 +1,36 @@ +/* notmuch - Not much of an email program, (just index and search) + * + * Copyright © 2016 David Bremner + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/ . + * + * Author: David Bremner + */ + +#include "notmuch.h" +#include "notmuch-private.h" + +notmuch_bool_t +notmuch_built_with (const char *name) +{ + if (STRNCMP_LITERAL (name, "compact") == 0) { + return HAVE_XAPIAN_COMPACT; + } else if (STRNCMP_LITERAL (name, "field_processor") == 0) { + return HAVE_XAPIAN_FIELD_PROCESSOR; + } else if (STRNCMP_LITERAL (name, "retry_lock") == 0) { + return HAVE_XAPIAN_DB_RETRY_LOCK; + } else { + return FALSE; + } +} diff --git a/lib/config.cc b/lib/config.cc new file mode 100644 index 00000000..0703b9bb --- /dev/null +++ b/lib/config.cc @@ -0,0 +1,193 @@ +/* config.cc - API for database metadata + * + * Copyright © 2016 David Bremner + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/ . + * + * Author: David Bremner + */ + +#include "notmuch.h" +#include "notmuch-private.h" +#include "database-private.h" + +static const std::string CONFIG_PREFIX = "C"; + +struct _notmuch_config_list { + notmuch_database_t *notmuch; + Xapian::TermIterator iterator; + char *current_key; + char *current_val; +}; + +static int +_notmuch_config_list_destroy (notmuch_config_list_t *list) +{ + /* invoke destructor w/o deallocating memory */ + list->iterator.~TermIterator(); + return 0; +} + +notmuch_status_t +notmuch_database_set_config (notmuch_database_t *notmuch, + const char *key, + const char *value) +{ + notmuch_status_t status; + Xapian::WritableDatabase *db; + + status = _notmuch_database_ensure_writable (notmuch); + if (status) + return status; + + try { + db = static_cast (notmuch->xapian_db); + db->set_metadata (CONFIG_PREFIX + key, value); + } catch (const Xapian::Error &error) { + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; + notmuch->exception_reported = TRUE; + _notmuch_database_log (notmuch, "Error: A Xapian exception occurred setting metadata: %s\n", + error.get_msg().c_str()); + } + return NOTMUCH_STATUS_SUCCESS; +} + +static notmuch_status_t +_metadata_value (notmuch_database_t *notmuch, + const char *key, + std::string &value) +{ + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; + + try { + value = notmuch->xapian_db->get_metadata (CONFIG_PREFIX + key); + } catch (const Xapian::Error &error) { + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; + notmuch->exception_reported = TRUE; + _notmuch_database_log (notmuch, "Error: A Xapian exception occurred getting metadata: %s\n", + error.get_msg().c_str()); + } + return status; +} + +notmuch_status_t +notmuch_database_get_config (notmuch_database_t *notmuch, + const char *key, + char **value) +{ + std::string strval; + notmuch_status_t status; + + if (! value) + return NOTMUCH_STATUS_NULL_POINTER; + + status = _metadata_value (notmuch, key, strval); + if (status) + return status; + + *value = strdup (strval.c_str ()); + + return NOTMUCH_STATUS_SUCCESS; +} + +notmuch_status_t +notmuch_database_get_config_list (notmuch_database_t *notmuch, + const char *prefix, + notmuch_config_list_t **out) +{ + notmuch_config_list_t *list = NULL; + notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; + + list = talloc (notmuch, notmuch_config_list_t); + if (! list) { + status = NOTMUCH_STATUS_OUT_OF_MEMORY; + goto DONE; + } + + talloc_set_destructor (list, _notmuch_config_list_destroy); + list->notmuch = notmuch; + list->current_key = NULL; + list->current_val = NULL; + + try { + + new(&(list->iterator)) Xapian::TermIterator (notmuch->xapian_db->metadata_keys_begin + (CONFIG_PREFIX + (prefix ? prefix : ""))); + + } catch (const Xapian::Error &error) { + _notmuch_database_log (notmuch, "A Xapian exception occurred getting metadata iterator: %s.\n", + error.get_msg().c_str()); + notmuch->exception_reported = TRUE; + status = NOTMUCH_STATUS_XAPIAN_EXCEPTION; + } + + *out = list; + + DONE: + if (status && list) + talloc_free (list); + + return status; +} + +notmuch_bool_t +notmuch_config_list_valid (notmuch_config_list_t *metadata) +{ + if (metadata->iterator == metadata->notmuch->xapian_db->metadata_keys_end ()) + return FALSE; + + return TRUE; +} + +const char * +notmuch_config_list_key (notmuch_config_list_t *list) +{ + if (list->current_key) + talloc_free (list->current_key); + + list->current_key = talloc_strdup (list, (*list->iterator).c_str () + CONFIG_PREFIX.length ()); + + return list->current_key; +} + +const char * +notmuch_config_list_value (notmuch_config_list_t *list) +{ + std::string strval; + notmuch_status_t status; + const char *key = notmuch_config_list_key (list); + + /* TODO: better error reporting?? */ + status = _metadata_value (list->notmuch, key, strval); + if (status) + return NULL; + + if (list->current_val) + talloc_free (list->current_val); + + list->current_val = talloc_strdup (list, strval.c_str ()); + return list->current_val; +} + +void +notmuch_config_list_move_to_next (notmuch_config_list_t *list) +{ + list->iterator++; +} + +void +notmuch_config_list_destroy (notmuch_config_list_t *list) +{ + talloc_free (list); +} diff --git a/lib/database-private.h b/lib/database-private.h index 3fb10f7a..ca71a92f 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -144,6 +144,13 @@ operator&=(_notmuch_features &a, _notmuch_features b) return a; } +#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | \ + Xapian::QueryParser::FLAG_PHRASE | \ + Xapian::QueryParser::FLAG_LOVEHATE | \ + Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | \ + Xapian::QueryParser::FLAG_WILDCARD | \ + Xapian::QueryParser::FLAG_PURE_NOT) + struct _notmuch_database { notmuch_bool_t exception_reported; @@ -176,6 +183,10 @@ struct _notmuch_database { Xapian::TermGenerator *term_gen; Xapian::ValueRangeProcessor *value_range_processor; Xapian::ValueRangeProcessor *date_range_processor; +#if HAVE_XAPIAN_FIELD_PROCESSOR + Xapian::FieldProcessor *date_field_processor; + Xapian::FieldProcessor *query_field_processor; +#endif Xapian::ValueRangeProcessor *last_mod_range_processor; }; diff --git a/lib/database.cc b/lib/database.cc index c8c5e261..66ee267f 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -13,13 +13,14 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ #include "database-private.h" #include "parse-time-vrp.h" +#include "query-fp.h" #include "string-util.h" #include @@ -48,6 +49,12 @@ typedef struct { #define STRINGIFY(s) _SUB_STRINGIFY(s) #define _SUB_STRINGIFY(s) #s +#if HAVE_XAPIAN_DB_RETRY_LOCK +#define DB_ACTION (Xapian::DB_CREATE_OR_OPEN | Xapian::DB_RETRY_LOCK) +#else +#define DB_ACTION Xapian::DB_CREATE_OR_OPEN +#endif + /* Here's the current schema for our database (for NOTMUCH_DATABASE_VERSION): * * We currently have three different types of documents (mail, ghost, @@ -184,6 +191,14 @@ typedef struct { * generated is 1 and the value will be * incremented for each thread ID. * + * C* metadata keys starting with C indicate + * configuration data. It can be managed with the + * n_database_*config* API. There is a convention + * of hierarchical keys separated by '.' (e.g. + * query.notmuch stores the value for the named + * query 'notmuch'), but it is not enforced by the + * API. + * * Obsolete metadata * ----------------- * @@ -216,7 +231,7 @@ typedef struct { /* With these prefix values we follow the conventions published here: * - * http://xapian.org/docs/omega/termprefixes.html + * https://xapian.org/docs/omega/termprefixes.html * * as much as makes sense. Note that I took some liberty in matching * the reserved prefix values to notmuch concepts, (for example, 'G' @@ -930,7 +945,7 @@ notmuch_database_open_verbose (const char *path, if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) { notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path, - Xapian::DB_CREATE_OR_OPEN); + DB_ACTION); } else { notmuch->xapian_db = new Xapian::Database (xapian_path); } @@ -1000,6 +1015,14 @@ notmuch_database_open_verbose (const char *path, notmuch->term_gen->set_stemmer (Xapian::Stem ("english")); notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); notmuch->date_range_processor = new ParseTimeValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); +#if HAVE_XAPIAN_FIELD_PROCESSOR + /* This currently relies on the query parser to pass anything + * with a .. to the range processor */ + notmuch->date_field_processor = new DateFieldProcessor(); + notmuch->query_parser->add_boolean_prefix("date", notmuch->date_field_processor); + notmuch->query_field_processor = new QueryFieldProcessor (*notmuch->query_parser, notmuch); + notmuch->query_parser->add_boolean_prefix("query", notmuch->query_field_processor); +#endif notmuch->last_mod_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:"); notmuch->query_parser->set_default_op (Xapian::Query::OP_AND); @@ -1090,6 +1113,13 @@ notmuch_database_close (notmuch_database_t *notmuch) delete notmuch->last_mod_range_processor; notmuch->last_mod_range_processor = NULL; +#if HAVE_XAPIAN_FIELD_PROCESSOR + delete notmuch->date_field_processor; + notmuch->date_field_processor = NULL; + delete notmuch->query_field_processor; + notmuch->query_field_processor = NULL; +#endif + return status; } @@ -2168,8 +2198,8 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch, * References header, if available. If not, fall back to the * first message ID in the In-Reply-To header. */ if (last_ref_message_id) { - _notmuch_message_add_term (message, "replyto", - last_ref_message_id); + _notmuch_message_add_term (message, "replyto", + last_ref_message_id); } else if (in_reply_to_message_id) { _notmuch_message_add_term (message, "replyto", in_reply_to_message_id); @@ -2278,15 +2308,15 @@ _consume_metadata_thread_id (void *ctx, notmuch_database_t *notmuch, if (stored_id.empty ()) { return NULL; } else { - Xapian::WritableDatabase *db; + Xapian::WritableDatabase *db; db = static_cast (notmuch->xapian_db); /* Clear the metadata for this message ID. We don't need it * anymore. */ - db->set_metadata (metadata_key, ""); + db->set_metadata (metadata_key, ""); - return talloc_strdup (ctx, stored_id.c_str ()); + return talloc_strdup (ctx, stored_id.c_str ()); } } diff --git a/lib/directory.cc b/lib/directory.cc index 78637b3a..a19f7779 100644 --- a/lib/directory.cc +++ b/lib/directory.cc @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/lib/filenames.c b/lib/filenames.c index 4f7c0d85..63e737dd 100644 --- a/lib/filenames.c +++ b/lib/filenames.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/lib/gen-version-script.sh b/lib/gen-version-script.sh index 84770011..5621f2a9 100644 --- a/lib/gen-version-script.sh +++ b/lib/gen-version-script.sh @@ -2,7 +2,7 @@ set -eu # we go through a bit of work to get the unmangled names of the # typeinfo symbols because of -# http://sourceware.org/bugzilla/show_bug.cgi?id=10326 +# https://sourceware.org/bugzilla/show_bug.cgi?id=10326 if [ $# -lt 2 ]; then echo Usage: $0 header obj1 obj2 obj3 @@ -17,7 +17,7 @@ nm $* | awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $3 ~ "Xapian.*Error" {print $3 while read sym; do demangled=$(c++filt $sym) case $demangled in - typeinfo*) + typeinfo*) printf "\t$sym;\n" ;; *) diff --git a/lib/index.cc b/lib/index.cc index f166aefd..8c145540 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -12,7 +12,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -144,7 +144,7 @@ filter_filter (GMimeFilter *gmime_filter, char *inbuf, size_t inlen, size_t pres {9, ' ', ' ', 10, 0}, {10, '\n', '\n', 11, 10}, {11, 'M', 'M', 12, 0}, - {12, ' ', '`', 12, 11} + {12, ' ', '`', 12, 11} }; int next; diff --git a/lib/message-file.c b/lib/message-file.c index ee305202..db18b163 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/lib/message.cc b/lib/message.cc index 68393055..24e698ab 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -1444,7 +1444,7 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) for (i = 0; i < ARRAY_SIZE(flag2tag); i++) { if ((strchr (combined_flags, flag2tag[i].flag) != NULL) - ^ + ^ flag2tag[i].inverse) { status = notmuch_message_add_tag (message, flag2tag[i].tag); diff --git a/lib/messages.c b/lib/messages.c index 0eee5690..b5363bb8 100644 --- a/lib/messages.c +++ b/lib/messages.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 92807975..3721431e 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -158,8 +158,8 @@ typedef enum _notmuch_private_status { ((private_status >= (notmuch_private_status_t) NOTMUCH_STATUS_LAST_STATUS)\ ? \ _internal_error (format " (%s).\n", \ - ##__VA_ARGS__, \ - __location__), \ + ##__VA_ARGS__, \ + __location__), \ (notmuch_status_t) NOTMUCH_PRIVATE_STATUS_SUCCESS \ : \ (notmuch_status_t) private_status) @@ -477,11 +477,11 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages); notmuch_bool_t _notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids, - unsigned int doc_id); + unsigned int doc_id); void _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids, - unsigned int doc_id); + unsigned int doc_id); /* querying xapian documents by type (e.g. "mail" or "ghost"): */ notmuch_status_t diff --git a/lib/notmuch.h b/lib/notmuch.h index 24944f0b..2faa1468 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -206,6 +206,7 @@ typedef struct _notmuch_message notmuch_message_t; typedef struct _notmuch_tags notmuch_tags_t; typedef struct _notmuch_directory notmuch_directory_t; typedef struct _notmuch_filenames notmuch_filenames_t; +typedef struct _notmuch_config_list notmuch_config_list_t; #endif /* __DOXYGEN__ */ /** @@ -694,7 +695,7 @@ notmuch_database_get_all_tags (notmuch_database_t *db); * completely in the future, but it's likely to be a specialized * version of the general Xapian query syntax: * - * http://xapian.org/docs/queryparser.html + * https://xapian.org/docs/queryparser.html * * As a special case, passing either a length-zero string, (that is ""), * or a string consisting of a single asterisk (that is "*"), will @@ -1840,6 +1841,74 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames); void notmuch_filenames_destroy (notmuch_filenames_t *filenames); + +/** + * set config 'key' to 'value' + * + */ +notmuch_status_t +notmuch_database_set_config (notmuch_database_t *db, const char *key, const char *value); + +/** + * retrieve config item 'key', assign to 'value' + * + * keys which have not been previously set with n_d_set_config will + * return an empty string. + * + * return value is allocated by malloc and should be freed by the + * caller. + */ +notmuch_status_t +notmuch_database_get_config (notmuch_database_t *db, const char *key, char **value); + +/** + * Create an iterator for all config items with keys matching a given prefix + */ +notmuch_status_t +notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out); + +/** + * Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called). + */ +notmuch_bool_t +notmuch_config_list_valid (notmuch_config_list_t *config_list); + +/** + * return key for current config pair + * + * return value is owned by the iterator, and will be destroyed by the + * next call to notmuch_config_list_key or notmuch_config_list_destroy. + */ +const char * +notmuch_config_list_key (notmuch_config_list_t *config_list); + +/** + * return 'value' for current config pair + * + * return value is owned by the iterator, and will be destroyed by the + * next call to notmuch_config_list_value or notmuch config_list_destroy + */ +const char * +notmuch_config_list_value (notmuch_config_list_t *config_list); + + +/** + * move 'config_list' iterator to the next pair + */ +void +notmuch_config_list_move_to_next (notmuch_config_list_t *config_list); + +/** + * free any resources held by 'config_list' + */ +void +notmuch_config_list_destroy (notmuch_config_list_t *config_list); + +/** + * interrogate the library for compile time features + */ +notmuch_bool_t +notmuch_built_with (const char *name); /* @} */ NOTMUCH_END_DECLS diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc index 03804cf5..dd691494 100644 --- a/lib/parse-time-vrp.cc +++ b/lib/parse-time-vrp.cc @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Jani Nikula */ @@ -64,3 +64,24 @@ ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end) return valno; } + +#if HAVE_XAPIAN_FIELD_PROCESSOR +/* XXX TODO: is throwing an exception the right thing to do here? */ +Xapian::Query DateFieldProcessor::operator()(const std::string & str) { + time_t from, to, now; + + /* Use the same 'now' for begin and end. */ + if (time (&now) == (time_t) -1) + throw Xapian::QueryParserError("Unable to get current time"); + + if (parse_time_string (str.c_str (), &from, &now, PARSE_TIME_ROUND_DOWN)) + throw Xapian::QueryParserError ("Didn't understand date specification '" + str + "'"); + + if (parse_time_string (str.c_str (), &to, &now, PARSE_TIME_ROUND_UP_INCLUSIVE)) + throw Xapian::QueryParserError ("Didn't understand date specification '" + str + "'"); + + return Xapian::Query(Xapian::Query::OP_AND, + Xapian::Query(Xapian::Query::OP_VALUE_GE, 0, Xapian::sortable_serialise ((double) from)), + Xapian::Query(Xapian::Query::OP_VALUE_LE, 0, Xapian::sortable_serialise ((double) to))); +} +#endif diff --git a/lib/parse-time-vrp.h b/lib/parse-time-vrp.h index 094c4f87..c024dba2 100644 --- a/lib/parse-time-vrp.h +++ b/lib/parse-time-vrp.h @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Jani Nikula */ @@ -37,4 +37,9 @@ public: Xapian::valueno operator() (std::string &begin, std::string &end); }; +#if HAVE_XAPIAN_FIELD_PROCESSOR +class DateFieldProcessor : public Xapian::FieldProcessor { + Xapian::Query operator()(const std::string & str); +}; +#endif #endif /* NOTMUCH_PARSE_TIME_VRP_H */ diff --git a/lib/query-fp.cc b/lib/query-fp.cc new file mode 100644 index 00000000..c39f5915 --- /dev/null +++ b/lib/query-fp.cc @@ -0,0 +1,43 @@ +/* query-fp.cc - "query:" field processor glue + * + * This file is part of notmuch. + * + * Copyright © 2016 David Bremner + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/ . + * + * Author: David Bremner + */ + +#include "database-private.h" +#include "query-fp.h" +#include + +#if HAVE_XAPIAN_FIELD_PROCESSOR + +Xapian::Query +QueryFieldProcessor::operator() (const std::string & name) +{ + std::string key = "query." + name; + char *expansion; + notmuch_status_t status; + + status = notmuch_database_get_config (notmuch, key.c_str (), &expansion); + if (status) { + throw Xapian::QueryParserError ("error looking up key" + name); + } + + return parser.parse_query (expansion, NOTMUCH_QUERY_PARSER_FLAGS); +} +#endif diff --git a/lib/query-fp.h b/lib/query-fp.h new file mode 100644 index 00000000..d6e4b313 --- /dev/null +++ b/lib/query-fp.h @@ -0,0 +1,42 @@ +/* query-fp.h - query field processor glue + * + * This file is part of notmuch. + * + * Copyright © 2016 David Bremner + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/ . + * + * Author: David Bremner + */ + +#ifndef NOTMUCH_QUERY_FP_H +#define NOTMUCH_QUERY_FP_H + +#include +#include "notmuch.h" + +#if HAVE_XAPIAN_FIELD_PROCESSOR +class QueryFieldProcessor : public Xapian::FieldProcessor { + protected: + Xapian::QueryParser &parser; + notmuch_database_t *notmuch; + + public: + QueryFieldProcessor (Xapian::QueryParser &parser_, notmuch_database_t *notmuch_) + : parser(parser_), notmuch(notmuch_) { }; + + Xapian::Query operator()(const std::string & str); +}; +#endif +#endif /* NOTMUCH_QUERY_FP_H */ diff --git a/lib/query.cc b/lib/query.cc index 77a7926b..7eb73a13 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -220,12 +220,6 @@ _notmuch_query_search_documents (notmuch_query_t *query, Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; Xapian::MSetIterator iterator; - unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | - Xapian::QueryParser::FLAG_PHRASE | - Xapian::QueryParser::FLAG_LOVEHATE | - Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | - Xapian::QueryParser::FLAG_WILDCARD | - Xapian::QueryParser::FLAG_PURE_NOT); if (strcmp (query_string, "") == 0 || strcmp (query_string, "*") == 0) @@ -233,7 +227,7 @@ _notmuch_query_search_documents (notmuch_query_t *query, final_query = mail_query; } else { string_query = notmuch->query_parser-> - parse_query (query_string, flags); + parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); final_query = Xapian::Query (Xapian::Query::OP_AND, mail_query, string_query); } @@ -282,7 +276,7 @@ _notmuch_query_search_documents (notmuch_query_t *query, case NOTMUCH_SORT_MESSAGE_ID: enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE); break; - case NOTMUCH_SORT_UNSORTED: + case NOTMUCH_SORT_UNSORTED: break; } @@ -418,7 +412,7 @@ _notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids, void _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids, - unsigned int doc_id) + unsigned int doc_id) { if (doc_id < doc_ids->bound) doc_ids->bitmap[DOCIDSET_WORD(doc_id)] &= ~(1 << DOCIDSET_BIT(doc_id)); @@ -579,12 +573,6 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign type)); Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; - unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | - Xapian::QueryParser::FLAG_PHRASE | - Xapian::QueryParser::FLAG_LOVEHATE | - Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | - Xapian::QueryParser::FLAG_WILDCARD | - Xapian::QueryParser::FLAG_PURE_NOT); if (strcmp (query_string, "") == 0 || strcmp (query_string, "*") == 0) @@ -592,7 +580,7 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign final_query = mail_query; } else { string_query = notmuch->query_parser-> - parse_query (query_string, flags); + parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); final_query = Xapian::Query (Xapian::Query::OP_AND, mail_query, string_query); } diff --git a/lib/sha1.c b/lib/sha1.c index 94060d57..b7dea1c2 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -112,4 +112,3 @@ _notmuch_sha1_of_file (const char *filename) return result; } - diff --git a/lib/string-list.c b/lib/string-list.c index da72746d..43ebe499 100644 --- a/lib/string-list.c +++ b/lib/string-list.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth * Austin Clements diff --git a/lib/tags.c b/lib/tags.c index b7e5602c..c7d3f66f 100644 --- a/lib/tags.c +++ b/lib/tags.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/lib/thread.cc b/lib/thread.cc index 0c937d76..84ee5298 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/mime-node.c b/mime-node.c index e96e6639..c9b82330 100644 --- a/mime-node.c +++ b/mime-node.c @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Authors: Carl Worth * Keith Packard diff --git a/notmuch-client.h b/notmuch-client.h index b3d0b668..ebc092b8 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -446,11 +446,19 @@ typedef enum dump_formats { DUMP_FORMAT_SUP } dump_format_t; +typedef enum dump_includes { + DUMP_INCLUDE_TAGS = 1, + DUMP_INCLUDE_CONFIG = 2, +} dump_include_t; + +#define NOTMUCH_DUMP_VERSION 2 + int notmuch_database_dump (notmuch_database_t *notmuch, const char *output_file_name, const char *query_str, dump_format_t output_format, + dump_include_t include, notmuch_bool_t gzip_output); /* If status is non-zero (i.e. error) print appropriate diff --git a/notmuch-compact.c b/notmuch-compact.c index 93737216..855545d7 100644 --- a/notmuch-compact.c +++ b/notmuch-compact.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Ben Gamari */ diff --git a/notmuch-config.c b/notmuch-config.c index d252bb25..e5d42a0c 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -27,7 +27,7 @@ static const char toplevel_config_comment[] = " .notmuch-config - Configuration file for the notmuch mail system\n" "\n" - " For more information about notmuch, see http://notmuchmail.org"; + " For more information about notmuch, see https://notmuchmail.org"; static const char database_config_comment[] = " Database configuration\n" @@ -750,6 +750,30 @@ _item_split (char *item, char **group, char **key) return 0; } +#define BUILT_WITH_PREFIX "built_with." +#define QUERY_PREFIX "query." + +static int +_print_db_config(notmuch_config_t *config, const char *name) +{ + notmuch_database_t *notmuch; + char *val; + + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) + return EXIT_FAILURE; + + /* XXX Handle UUID mismatch? */ + + if (print_status_database ("notmuch config", notmuch, + notmuch_database_get_config (notmuch, name, &val))) + return EXIT_FAILURE; + + puts (val); + + return EXIT_SUCCESS; +} + static int notmuch_config_command_get (notmuch_config_t *config, char *item) { @@ -773,6 +797,11 @@ notmuch_config_command_get (notmuch_config_t *config, char *item) tags = notmuch_config_get_new_tags (config, &length); for (i = 0; i < length; i++) printf ("%s\n", tags[i]); + } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) { + printf ("%s\n", + notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false"); + } else if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) { + return _print_db_config (config, item); } else { char **value; size_t i, length; @@ -799,11 +828,53 @@ notmuch_config_command_get (notmuch_config_t *config, char *item) return 0; } +static int +_set_db_config(notmuch_config_t *config, const char *key, int argc, char **argv) +{ + notmuch_database_t *notmuch; + const char *val = ""; + + if (argc > 1) { + /* XXX handle lists? */ + fprintf (stderr, "notmuch config set: at most one value expected for %s\n", key); + return EXIT_FAILURE; + } + + if (argc > 0) { + val = argv[0]; + } + + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) + return EXIT_FAILURE; + + /* XXX Handle UUID mismatch? */ + + if (print_status_database ("notmuch config", notmuch, + notmuch_database_set_config (notmuch, key, val))) + return EXIT_FAILURE; + + if (print_status_database ("notmuch config", notmuch, + notmuch_database_close (notmuch))) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} + static int notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char *argv[]) { char *group, *key; + if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) { + fprintf (stderr, "Error: read only option: %s\n", item); + return 1; + } + + if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) { + return _set_db_config (config, item, argc, argv); + } + if (_item_split (item, &group, &key)) return 1; @@ -830,6 +901,46 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char return notmuch_config_save (config); } +static +void +_notmuch_config_list_built_with () +{ + printf("%scompact=%s\n", + BUILT_WITH_PREFIX, + notmuch_built_with ("compact") ? "true" : "false"); + printf("%sfield_processor=%s\n", + BUILT_WITH_PREFIX, + notmuch_built_with ("field_processor") ? "true" : "false"); + printf("%sretry_lock=%s\n", + BUILT_WITH_PREFIX, + notmuch_built_with ("retry_lock") ? "true" : "false"); +} + +static int +_list_db_config (notmuch_config_t *config) +{ + notmuch_database_t *notmuch; + notmuch_config_list_t *list; + + if (notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much)) + return EXIT_FAILURE; + + /* XXX Handle UUID mismatch? */ + + + if (print_status_database ("notmuch config", notmuch, + notmuch_database_get_config_list (notmuch, "", &list))) + return EXIT_FAILURE; + + for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) { + printf("%s=%s\n", notmuch_config_list_key (list), notmuch_config_list_value(list)); + } + notmuch_config_list_destroy (list); + + return EXIT_SUCCESS; +} + static int notmuch_config_command_list (notmuch_config_t *config) { @@ -865,7 +976,8 @@ notmuch_config_command_list (notmuch_config_t *config) g_strfreev (groups); - return 0; + _notmuch_config_list_built_with (); + return _list_db_config (config); } int diff --git a/notmuch-count.c b/notmuch-count.c index 0b6e6f54..35a2aa70 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Keith Packard */ diff --git a/notmuch-dump.c b/notmuch-dump.c index 829781f8..cae1db8a 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -23,16 +23,80 @@ #include "string-util.h" #include +static int +database_dump_config (notmuch_database_t *notmuch, gzFile output) +{ + notmuch_config_list_t *list; + int ret = EXIT_FAILURE; + char *buffer = NULL; + size_t buffer_size = 0; + + if (print_status_database ("notmuch dump", notmuch, + notmuch_database_get_config_list (notmuch, NULL, &list))) + goto DONE; + + for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) { + if (hex_encode (notmuch, notmuch_config_list_key (list), + &buffer, &buffer_size) != HEX_SUCCESS) { + fprintf (stderr, "Error: failed to hex-encode config key %s\n", + notmuch_config_list_key (list)); + goto DONE; + } + gzprintf (output, "#@ %s", buffer); + + if (hex_encode (notmuch, notmuch_config_list_value (list), + &buffer, &buffer_size) != HEX_SUCCESS) { + fprintf (stderr, "Error: failed to hex-encode config value %s\n", + notmuch_config_list_value (list) ); + goto DONE; + } + + gzprintf (output, " %s\n", buffer); + } + + ret = EXIT_SUCCESS; + + DONE: + if (list) + notmuch_config_list_destroy (list); + + if (buffer) + talloc_free (buffer); + + return ret; +} + +static void +print_dump_header (gzFile output, int output_format, int include) +{ + gzprintf (output, "#notmuch-dump %s:%d %s%s%s\n", + (output_format == DUMP_FORMAT_SUP) ? "sup" : "batch-tag", + NOTMUCH_DUMP_VERSION, + (include & DUMP_INCLUDE_CONFIG) ? "config" : "", + (include & DUMP_INCLUDE_TAGS) && (include & DUMP_INCLUDE_CONFIG) ? "," : "", + (include & DUMP_INCLUDE_TAGS) ? "tags" : ""); +} static int database_dump_file (notmuch_database_t *notmuch, gzFile output, - const char *query_str, int output_format) + const char *query_str, int output_format, int include) { notmuch_query_t *query; notmuch_messages_t *messages; notmuch_message_t *message; notmuch_tags_t *tags; + print_dump_header (output, output_format, include); + + if (include & DUMP_INCLUDE_CONFIG) { + if (print_status_database ("notmuch dump", notmuch, + database_dump_config(notmuch,output))) + return EXIT_FAILURE; + } + + if (! (include & DUMP_INCLUDE_TAGS)) + return EXIT_SUCCESS; + if (! query_str) query_str = ""; @@ -130,6 +194,7 @@ notmuch_database_dump (notmuch_database_t *notmuch, const char *output_file_name, const char *query_str, dump_format_t output_format, + dump_include_t include, notmuch_bool_t gzip_output) { gzFile output = NULL; @@ -164,7 +229,7 @@ notmuch_database_dump (notmuch_database_t *notmuch, goto DONE; } - ret = database_dump_file (notmuch, output, query_str, output_format); + ret = database_dump_file (notmuch, output, query_str, output_format, include); if (ret) goto DONE; ret = gzflush (output, Z_FINISH); @@ -226,6 +291,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[]) int opt_index; int output_format = DUMP_FORMAT_BATCH_TAG; + int include = 0; notmuch_bool_t gzip_output = 0; notmuch_opt_desc_t options[] = { @@ -233,6 +299,9 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[]) (notmuch_keyword_t []){ { "sup", DUMP_FORMAT_SUP }, { "batch-tag", DUMP_FORMAT_BATCH_TAG }, { 0, 0 } } }, + { NOTMUCH_OPT_KEYWORD_FLAGS, &include, "include", 'I', + (notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG }, + { "tags", DUMP_INCLUDE_TAGS} } }, { NOTMUCH_OPT_STRING, &output_file_name, "output", 'o', 0 }, { NOTMUCH_OPT_BOOLEAN, &gzip_output, "gzip", 'z', 0 }, { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, @@ -245,6 +314,9 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_process_shared_options (argv[0]); + if (include == 0) + include = DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_TAGS; + if (opt_index < argc) { query_str = query_string_from_args (notmuch, argc - opt_index, argv + opt_index); if (query_str == NULL) { @@ -254,7 +326,7 @@ notmuch_dump_command (notmuch_config_t *config, int argc, char *argv[]) } ret = notmuch_database_dump (notmuch, output_file_name, query_str, - output_format, gzip_output); + output_format, include, gzip_output); notmuch_database_destroy (notmuch); diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua index 4404cd7c..f9d83713 100755 --- a/notmuch-emacs-mua +++ b/notmuch-emacs-mua @@ -15,7 +15,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . # # Authors: Jani Nikula # @@ -39,8 +39,10 @@ USE_EMACSCLIENT= AUTO_DAEMON= CREATE_FRAME= +escape -v pwd "$PWD" + # The crux of it all: construct an elisp progn and eval it. -ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)" +ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") (notmuch-mua-new-mail)" # Short options compatible with mutt(1). while getopts :s:c:b:i:h opt; do @@ -95,7 +97,7 @@ while getopts :s:c:b:i:h opt; do ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")" ;; --body|i) - ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")" + ELISP="${ELISP} (message-goto-body) (insert-file \"${OPTARG}\")" ;; --print) PRINT_ONLY=1 @@ -132,7 +134,7 @@ done # Kill the terminal/frame if we're creating one. if [ -z "$USE_EMACSCLIENT" -o -n "$CREATE_FRAME" -o -n "$NO_WINDOW" ]; then - ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))" + ELISP="${ELISP} (message-add-action #'save-buffers-kill-terminal 'exit)" fi # End progn. diff --git a/notmuch-insert.c b/notmuch-insert.c index 5205c17a..131f09e2 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -16,7 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Peter Wang */ diff --git a/notmuch-new.c b/notmuch-new.c index 04cb5cac..799fec20 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -351,7 +351,6 @@ add_files (notmuch_database_t *notmuch, const char *path, add_files_state_t *state) { - DIR *dir = NULL; struct dirent *entry = NULL; char *next = NULL; time_t fs_mtime, db_mtime; @@ -655,8 +654,6 @@ add_files (notmuch_database_t *notmuch, DONE: if (next) talloc_free (next); - if (dir) - closedir (dir); if (fs_entries) { for (i = 0; i < num_fs_entries; i++) free (fs_entries[i]); @@ -1045,7 +1042,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) } if (notmuch_database_dump (notmuch, backup_name, "", - DUMP_FORMAT_BATCH_TAG, TRUE)) { + DUMP_FORMAT_BATCH_TAG, DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_TAGS, TRUE)) { fprintf (stderr, "Backup failed. Aborting upgrade."); return EXIT_FAILURE; } diff --git a/notmuch-reply.c b/notmuch-reply.c index 3c6d685c..49513732 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Authors: Carl Worth * Keith Packard @@ -324,7 +324,7 @@ add_recipients_from_message (GMimeMessage *reply, unsigned int n = 0; /* Some mailing lists munge the Reply-To header despite it being A Bad - * Thing, see http://www.unicom.com/pw/reply-to-harmful.html + * Thing, see http://marc.merlins.org/netrants/reply-to-harmful.html * * The munging is easy to detect, because it results in a * redundant reply-to header, (with an address that already exists @@ -664,7 +664,7 @@ notmuch_reply_format_sprinter(void *ctx, return 1; if (count != 1) { - fprintf (stderr, "Error: search term did not match precisely one message.\n"); + fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count); return 1; } diff --git a/notmuch-restore.c b/notmuch-restore.c index 9abc64fd..371237c5 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -24,6 +24,39 @@ #include "string-util.h" #include "zlib-extra.h" +static int +process_config_line (notmuch_database_t *notmuch, const char* line) +{ + const char *key_p, *val_p; + char *key, *val; + size_t key_len,val_len; + const char *delim = " \t\n"; + int ret = EXIT_FAILURE; + + void *local = talloc_new(NULL); + + key_p = strtok_len_c (line, delim, &key_len); + val_p = strtok_len_c (key_p+key_len, delim, &val_len); + + key = talloc_strndup (local, key_p, key_len); + val = talloc_strndup (local, val_p, val_len); + if (hex_decode_inplace (key) != HEX_SUCCESS || + hex_decode_inplace (val) != HEX_SUCCESS ) { + fprintf (stderr, "hex decoding failure on line %s\n", line); + goto DONE; + } + + if (print_status_database ("notmuch restore", notmuch, + notmuch_database_set_config (notmuch, key, val))) + goto DONE; + + ret = EXIT_SUCCESS; + + DONE: + talloc_free (local); + return ret; +} + static regex_t regex; /* Non-zero return indicates an error in retrieving the message, @@ -137,6 +170,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) int ret = 0; int opt_index; + int include = 0; int input_format = DUMP_FORMAT_AUTO; if (notmuch_database_open (notmuch_config_get_database_path (config), @@ -152,6 +186,10 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) { "batch-tag", DUMP_FORMAT_BATCH_TAG }, { "sup", DUMP_FORMAT_SUP }, { 0, 0 } } }, + { NOTMUCH_OPT_KEYWORD_FLAGS, &include, "include", 'I', + (notmuch_keyword_t []){ { "config", DUMP_INCLUDE_CONFIG }, + { "tags", DUMP_INCLUDE_TAGS} } }, + { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 }, { NOTMUCH_OPT_BOOLEAN, &accumulate, "accumulate", 'a', 0 }, { NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 }, @@ -167,6 +205,10 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_process_shared_options (argv[0]); notmuch_exit_if_unmatched_db_uuid (notmuch); + if (include == 0) { + include = DUMP_INCLUDE_CONFIG | DUMP_INCLUDE_TAGS; + } + name_for_error = input_file_name ? input_file_name : "stdin"; if (! accumulate) @@ -225,11 +267,23 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) ret = EXIT_FAILURE; goto DONE; } + + if ((include & DUMP_INCLUDE_CONFIG) && line_len >= 2 && line[0] == '#' && line[1] == '@') { + ret = process_config_line(notmuch, line+2); + if (ret) + goto DONE; + } + } while ((line_len == 0) || (line[0] == '#') || /* the cast is safe because we checked about for line_len < 0 */ (strspn (line, " \t\n") == (unsigned)line_len)); + if (! (include & DUMP_INCLUDE_TAGS)) { + ret = EXIT_SUCCESS; + goto DONE; + } + char *p; for (p = line; (input_format == DUMP_FORMAT_AUTO) && *p; p++) { if (*p == '(') diff --git a/notmuch-search.c b/notmuch-search.c index 6d08c250..8c65d5ad 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/notmuch-setup.c b/notmuch-setup.c index 9aaf9286..9a66810d 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/notmuch-show.c b/notmuch-show.c index 87e52bbc..22fa655a 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ @@ -904,7 +904,7 @@ do_show_single (void *ctx, return 1; if (count != 1) { - fprintf (stderr, "Error: search term did not match precisely one message.\n"); + fprintf (stderr, "Error: search term did not match precisely one message (matched %d messages).\n", count); return 1; } diff --git a/notmuch-tag.c b/notmuch-tag.c index 0d153282..18d78ddd 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/notmuch-time.c b/notmuch-time.c index e250c3d5..2734b36a 100644 --- a/notmuch-time.c +++ b/notmuch-time.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/notmuch.c b/notmuch.c index ce6c5756..38b73c1d 100644 --- a/notmuch.c +++ b/notmuch.c @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Authors: Carl Worth * Keith Packard @@ -354,7 +354,7 @@ notmuch_command (notmuch_config_t *config, "You can also use \"notmuch show\" with any of the thread IDs resulting\n" "from a search. Finally, you may want to explore using a more sophisticated\n" "interface to notmuch such as the emacs interface implemented in notmuch.el\n" - "or any other interface described at http://notmuchmail.org\n\n" + "or any other interface described at https://notmuchmail.org\n\n" "And don't forget to run \"notmuch new\" whenever new mail arrives.\n\n" "Have fun, and may your inbox never have much mail.\n\n", notmuch_config_get_user_name (config), diff --git a/packaging/fedora/notmuch.spec b/packaging/fedora/notmuch.spec index 79994c9a..5146edd3 100644 --- a/packaging/fedora/notmuch.spec +++ b/packaging/fedora/notmuch.spec @@ -21,9 +21,9 @@ Summary: Thread-based email index, search and tagging Group: Applications/Internet License: GPLv3+ -URL: http://notmuchmail.org/ +URL: https://notmuchmail.org/ -Source0: http://notmuchmail.org/releases/notmuch-%{version}.tar.gz +Source0: https://notmuchmail.org/releases/notmuch-%{version}.tar.gz BuildRequires: xapian-core-devel gmime-devel libtalloc-devel BuildRequires: zlib-devel emacs-el emacs-nox python ruby ruby-devel perl diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c index 1cef47d4..48ec5b0c 100644 --- a/parse-time-string/parse-time-string.c +++ b/parse-time-string/parse-time-string.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * * Author: Jani Nikula */ diff --git a/parse-time-string/parse-time-string.h b/parse-time-string/parse-time-string.h index bfa4ee35..2063bcad 100644 --- a/parse-time-string/parse-time-string.h +++ b/parse-time-string/parse-time-string.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * * Author: Jani Nikula */ diff --git a/performance-test/Makefile.local b/performance-test/Makefile.local index 3469aa3d..9dc260e3 100644 --- a/performance-test/Makefile.local +++ b/performance-test/Makefile.local @@ -10,7 +10,7 @@ MEMORY_TEST_SCRIPT := ${dir}/notmuch-memory-test CORPUS_NAME := notmuch-email-corpus-$(PERFTEST_VERSION).tar.xz TXZFILE := ${dir}/download/${CORPUS_NAME} SIGFILE := ${TXZFILE}.asc -DEFAULT_URL := http://notmuchmail.org/releases/${CORPUS_NAME} +DEFAULT_URL := https://notmuchmail.org/releases/${CORPUS_NAME} perf-test: time-test memory-test @@ -32,7 +32,7 @@ setup-perf-test: $(TXZFILE) $(TXZFILE): @printf "\nPlease download ${TXZFILE} using:\n\n" @printf "\t%% make download-corpus\n\n" - @echo or see http://notmuchmail.org/corpus for download locations + @echo or see https://notmuchmail.org/corpus for download locations @echo @false diff --git a/performance-test/README b/performance-test/README index 996724cd..fbc61028 100644 --- a/performance-test/README +++ b/performance-test/README @@ -37,7 +37,7 @@ To fetch the actual corpus it should work to run In case that fails or is too slow, check - http://notmuchmail.org/corpus + https://notmuchmail.org/corpus for a list of mirrors. diff --git a/performance-test/notmuch-memory-test b/performance-test/notmuch-memory-test index 3cf28c7f..047aac70 100755 --- a/performance-test/notmuch-memory-test +++ b/performance-test/notmuch-memory-test @@ -3,6 +3,7 @@ # Run tests # # Copyright (c) 2005 Junio C Hamano +# Copyright (c) 2010 Notmuch Developers # # Adapted from a Makefile to a shell script by Carl Worth (2010) @@ -14,7 +15,7 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then exit 1 fi -cd $(dirname "$0") +cd "$(dirname "$0")" for test in M*.sh; do ./"$test" "$@" diff --git a/performance-test/notmuch-time-test b/performance-test/notmuch-time-test index 7113efbf..4dd21fe1 100755 --- a/performance-test/notmuch-time-test +++ b/performance-test/notmuch-time-test @@ -3,6 +3,7 @@ # Run tests # # Copyright (c) 2005 Junio C Hamano +# Copyright (c) 2010 Notmuch Developers # # Adapted from a Makefile to a shell script by Carl Worth (2010) @@ -14,7 +15,7 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then exit 1 fi -cd $(dirname "$0") +cd "$(dirname "$0")" for test in T*.sh; do ./"$test" "$@" diff --git a/query-string.c b/query-string.c index 65365123..cc8b27de 100644 --- a/query-string.c +++ b/query-string.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/sprinter-sexp.c b/sprinter-sexp.c index 0aa51e8b..08783e11 100644 --- a/sprinter-sexp.c +++ b/sprinter-sexp.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Peter Feigl */ diff --git a/test/Makefile.local b/test/Makefile.local index 022f2cf7..91b36936 100644 --- a/test/Makefile.local +++ b/test/Makefile.local @@ -19,7 +19,7 @@ $(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a $(call quiet,CC) $^ -o $@ $(LDFLAGS) $(TALLOC_LDFLAGS) random_corpus_deps = $(dir)/random-corpus.o $(dir)/database-test.o \ - notmuch-config.o command-line-arguments.o \ + notmuch-config.o status.o command-line-arguments.o \ lib/libnotmuch.a util/libutil.a \ parse-time-string/libparse-time-string.a diff --git a/test/README b/test/README index bd9ab547..104a120e 100644 --- a/test/README +++ b/test/README @@ -145,13 +145,9 @@ Tddd-testname.sh where 'ddd' is three digits and 'testname' the "bare" name of your test. Tests will be run in order the 'ddd' part determines. The test script should start with the standard "#!/usr/bin/env bash" -with copyright notices, and an assignment to variable 'test_description', -like this: +and an assignment to variable 'test_description', like this: #!/usr/bin/env bash - # - # Copyright (c) 2005 Junio C Hamano - # test_description='xxx test (option --frotz) diff --git a/test/T030-config.sh b/test/T030-config.sh index f404908a..0915abdb 100755 --- a/test/T030-config.sh +++ b/test/T030-config.sh @@ -43,10 +43,10 @@ notmuch config set foo.nonexistent test_expect_equal "$(notmuch config get foo.nonexistent)" "" test_begin_subtest "List all items" -notmuch config set database.path "/canonical/path" -output=$(notmuch config list) -test_expect_equal "$output" "\ -database.path=/canonical/path +notmuch config list 2>&1 | notmuch_config_sanitize > OUTPUT +cat < EXPECTED +Error opening database at MAIL_DIR/.notmuch: No such file or directory +database.path=MAIL_DIR user.name=Notmuch Test Suite user.primary_email=test_suite@notmuchmail.org user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org @@ -56,7 +56,12 @@ search.exclude_tags= maildir.synchronize_flags=true crypto.gpg_path=gpg foo.string=this is another string value -foo.list=this;is another;list value;" +foo.list=this;is another;list value; +built_with.compact=something +built_with.field_processor=something +built_with.retry_lock=something +EOF +test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Top level --config=FILE option" cp "${NOTMUCH_CONFIG}" alt-config diff --git a/test/T040-setup.sh b/test/T040-setup.sh index cf0c00bc..021f2d0b 100755 --- a/test/T040-setup.sh +++ b/test/T040-setup.sh @@ -19,7 +19,7 @@ another.suite@example.com foo bar baz EOF -output=$(notmuch --config=new-notmuch-config config list) +output=$(notmuch --config=new-notmuch-config config list | notmuch_built_with_sanitize) test_expect_equal "$output" "\ database.path=/path/to/maildir user.name=Test Suite @@ -29,6 +29,9 @@ new.tags=foo;bar; new.ignore= search.exclude_tags=baz; maildir.synchronize_flags=true -crypto.gpg_path=gpg" +crypto.gpg_path=gpg +built_with.compact=something +built_with.field_processor=something +built_with.retry_lock=something" test_done diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh index a451ffae..61d13116 100755 --- a/test/T150-tagging.sh +++ b/test/T150-tagging.sh @@ -188,7 +188,7 @@ cat < EXPECTED +%22%27%22%27%22%22%27%27 +inbox +tag4 +tag5 +unread -- id:msg-002@notmuch-test-suite EOF -notmuch dump --format=batch-tag | sort > OUTPUT +NOTMUCH_DUMP_TAGS > OUTPUT notmuch restore --format=batch-tag < BACKUP test_expect_equal_file EXPECTED OUTPUT @@ -209,7 +209,7 @@ cat < EXPECTED +%21@%23%20%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e +inbox +tag5 +unread -- id:msg-001@notmuch-test-suite EOF -notmuch dump --format=batch-tag | sort > OUTPUT +NOTMUCH_DUMP_TAGS > OUTPUT notmuch restore --format=batch-tag < BACKUP test_expect_equal_file EXPECTED OUTPUT @@ -235,7 +235,7 @@ cat < EXPECTED +%2a@%7d%cf%b5%f4%85%80%adO3%da%a7 +=%e0%ac%95%c8%b3+%ef%aa%95%c8%a64w%c7%9d%c9%a2%cf%b3%d6%82%24B%c4%a9%c5%a1UX%ee%99%b0%27E7%ca%a4%d0%8b%5d +A%e1%a0%bc%de%8b%d5%b2V%d9%9b%f3%b5%a2%a3M%d8%a1u@%f0%a0%ac%948%7e%f0%ab%86%af%27 +L%df%85%ef%a1%a5m@%d3%96%c2%ab%d4%9f%ca%b8%f3%b3%a2%bf%c7%b1_u%d7%b4%c7%b1 +P%c4%98%2f +R +inbox +tag5 +unread +%7e%d1%8b%25%ec%a0%ae%d1%a0M%3b%e3%b6%b7%e9%a4%87%3c%db%9a%cc%a8%e1%96%9d +%c4%bf7%c7%ab9H%c4%99k%ea%91%bd%c3%8ck%e2%b3%8dk%c5%952V%e4%99%b2%d9%b3%e4%8b%bda%5b%24%c7%9b +%da%88=f%cc%b9I%ce%af%7b%c9%97%e3%b9%8bH%cb%92X%d2%8c6 +%dc%9crh%d2%86B%e5%97%a2%22t%ed%99%82d -- id:msg-001@notmuch-test-suite EOF -notmuch dump --format=batch-tag | sort > OUTPUT +NOTMUCH_DUMP_TAGS > OUTPUT notmuch restore --format=batch-tag < BACKUP test_expect_equal_file EXPECTED OUTPUT @@ -260,7 +260,7 @@ cat < EXPECTED +foo%3a%3abar%25 +found%3a%3ait +inbox +tag5 +unread +winner -- id:msg-001@notmuch-test-suite EOF -notmuch dump --format=batch-tag | sort > OUTPUT +NOTMUCH_DUMP_TAGS > OUTPUT notmuch restore --format=batch-tag < BACKUP test_expect_equal_file EXPECTED OUTPUT diff --git a/test/T210-raw.sh b/test/T210-raw.sh index dfea2d19..832a4ad3 100755 --- a/test/T210-raw.sh +++ b/test/T210-raw.sh @@ -8,7 +8,7 @@ add_message test_begin_subtest "Attempt to show multiple raw messages" output=$(notmuch show --format=raw "*" 2>&1) -test_expect_equal "$output" "Error: search term did not match precisely one message." +test_expect_equal "$output" "Error: search term did not match precisely one message (matched 2 messages)." test_begin_subtest "Show a raw message" output=$(notmuch show --format=raw id:msg-001@notmuch-test-suite | notmuch_date_sanitize) diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh index 97e9e7f9..faa10364 100755 --- a/test/T240-dump-restore.sh +++ b/test/T240-dump-restore.sh @@ -97,7 +97,7 @@ test_expect_equal_file dump.expected dump.actual # Note, we assume all messages from cworth have a message-id # containing cworth.org -grep 'cworth[.]org' dump.expected > dump-cworth.expected +{ head -1 dump.expected ; grep 'cworth[.]org' dump.expected; } > dump-cworth.expected test_begin_subtest "dump -- from:cworth" notmuch dump -- from:cworth > dump-dash-cworth.actual @@ -118,16 +118,16 @@ notmuch search --output=messages from:cworth | sed s/^id:// |\ test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "format=batch-tag, dump sanity check." -notmuch dump --format=sup from:cworth | cut -f1 -d' ' | \ +NOTMUCH_DUMP_TAGS --format=sup from:cworth | cut -f1 -d' ' | \ sort > EXPECTED.$test_count -notmuch dump --format=batch-tag from:cworth | sed 's/^.*-- id://' | \ +NOTMUCH_DUMP_TAGS --format=batch-tag from:cworth | sed 's/^.*-- id://' | \ sort > OUTPUT.$test_count test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count test_begin_subtest "format=batch-tag, missing newline" printf "+a_tag_without_newline -- id:20091117232137.GA7669@griffis1.net" > IN notmuch restore --accumulate < IN -notmuch dump id:20091117232137.GA7669@griffis1.net > OUT +NOTMUCH_DUMP_TAGS id:20091117232137.GA7669@griffis1.net > OUT cat < EXPECTED +a_tag_without_newline +inbox +unread -- id:20091117232137.GA7669@griffis1.net EOF @@ -156,7 +156,7 @@ cat <EXPECTED.$test_count + -- id:20091117232137.GA7669@griffis1.net EOF notmuch restore --format=batch-tag < EXPECTED.$test_count -notmuch dump --format=batch-tag id:20091117232137.GA7669@griffis1.net > OUTPUT.$test_count +NOTMUCH_DUMP_TAGS --format=batch-tag id:20091117232137.GA7669@griffis1.net > OUTPUT.$test_count test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count tag1='comic_swear=$&^%$^%\\//-+$^%$' @@ -219,9 +219,9 @@ notmuch dump --format=batch-tag > OUTPUT.$test_count test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count test_begin_subtest 'format=batch-tag, checking encoded output' -notmuch dump --format=batch-tag -- from:cworth |\ +NOTMUCH_DUMP_TAGS --format=batch-tag -- from:cworth |\ awk "{ print \"+$enc1 +$enc2 +$enc3 -- \" \$5 }" > EXPECTED.$test_count -notmuch dump --format=batch-tag -- from:cworth > OUTPUT.$test_count +NOTMUCH_DUMP_TAGS --format=batch-tag -- from:cworth > OUTPUT.$test_count test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count test_begin_subtest 'restoring sane tags' diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index daa02568..65c1728d 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -760,8 +760,8 @@ bought inbox,stashtest ${gen_msg_filename} http://mid.gmane.org/bought -http://marc.info/?i=bought -http://mid.mail-archive.com/bought +https://marc.info/?i=bought +https://mid.mail-archive.com/bought EOF test_expect_equal_file OUTPUT EXPECTED diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh index 3f18ec1a..b3dbb1b5 100755 --- a/test/T360-symbol-hiding.sh +++ b/test/T360-symbol-hiding.sh @@ -5,7 +5,7 @@ # This test tests whether hiding Xapian::Error symbols in libnotmuch # also hides them for other users of libxapian. This is motivated by -# the discussion in http://gcc.gnu.org/wiki/Visibility' +# the discussion in https://gcc.gnu.org/wiki/Visibility' test_description='exception symbol hiding' @@ -13,9 +13,8 @@ test_description='exception symbol hiding' test_begin_subtest 'running test' run_test mkdir -p ${PWD}/fakedb/.notmuch -( LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \ - $TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent \ - 2>&1 | notmuch_dir_sanitize | sed -e "s,\`,\',g" -e "s,${NOTMUCH_DEFAULT_XAPIAN_BACKEND},backend,g") > OUTPUT +$TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent 2>&1 \ + | notmuch_dir_sanitize | sed -e "s,\`,\',g" -e "s,${NOTMUCH_DEFAULT_XAPIAN_BACKEND},backend,g" > OUTPUT cat < EXPECTED A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian' diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh index d5cade8f..20e06917 100755 --- a/test/T395-ruby.sh +++ b/test/T395-ruby.sh @@ -83,4 +83,20 @@ EOF notmuch count --output=threads tag:inbox > EXPECTED test_expect_equal_file OUTPUT EXPECTED +test_begin_subtest "get all tags" +test_ruby <<"EOF" +require 'notmuch' +$maildir = ENV['MAIL_DIR'] +if not $maildir then + abort('environment variable MAIL_DIR must be set') +end +@db = Notmuch::Database.new($maildir) +@t = @db.all_tags() +for tag in @t do + print tag,"\n" +end +EOF +notmuch search --output=tags '*' > EXPECTED +test_expect_equal_file OUTPUT EXPECTED + test_done diff --git a/test/T500-search-date.sh b/test/T500-search-date.sh index f5cea421..198a2e60 100755 --- a/test/T500-search-date.sh +++ b/test/T500-search-date.sh @@ -12,6 +12,12 @@ test_begin_subtest "Absolute date range with 'same' operator" output=$(notmuch search date:2010-12-16..! | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)" +if [ "${NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR}" = "1" ]; then + test_begin_subtest "Absolute date field" + output=$(notmuch search date:2010-12-16 | notmuch_search_sanitize) + test_expect_equal "$output" "thread:XXX 2010-12-16 [1/1] Olivier Berger; Essai accentué (inbox unread)" +fi + test_begin_subtest "Absolute time range with TZ" notmuch search date:18-Nov-2009_02:19:26-0800..2009-11-18_04:49:52-06:00 | notmuch_search_sanitize > OUTPUT cat <EXPECTED diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh new file mode 100755 index 00000000..e8c078d5 --- /dev/null +++ b/test/T590-libconfig.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash +test_description="library config API" + +. ./test-lib.sh || exit 1 + +add_email_corpus + +cat < c_head +#include +#include +#include + +int main (int argc, char** argv) +{ + notmuch_database_t *db; + char *val; + notmuch_status_t stat; + + EXPECT0(notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db)); + +EOF + +cat < c_tail + EXPECT0(notmuch_database_destroy(db)); +} +EOF + +test_begin_subtest "notmuch_database_{set,get}_config" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ + EXPECT0(notmuch_database_set_config (db, "testkey1", "testvalue1")); + EXPECT0(notmuch_database_set_config (db, "testkey2", "testvalue2")); + EXPECT0(notmuch_database_get_config (db, "testkey1", &val)); + printf("testkey1 = %s\n", val); + EXPECT0(notmuch_database_get_config (db, "testkey2", &val)); + printf("testkey2 = %s\n", val); +} +EOF +cat <<'EOF' >EXPECTED +== stdout == +testkey1 = testvalue1 +testkey2 = testvalue2 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + + +test_begin_subtest "notmuch_database_get_config_list: empty list" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ + notmuch_config_list_t *list; + EXPECT0(notmuch_database_get_config_list (db, "nonexistent", &list)); + printf("valid = %d\n", notmuch_config_list_valid (list)); + notmuch_config_list_destroy (list); +} +EOF +cat <<'EOF' >EXPECTED +== stdout == +valid = 0 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + + +test_begin_subtest "notmuch_database_get_config_list: all pairs" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ + notmuch_config_list_t *list; + EXPECT0(notmuch_database_set_config (db, "zzzafter", "afterval")); + EXPECT0(notmuch_database_set_config (db, "aaabefore", "beforeval")); + EXPECT0(notmuch_database_get_config_list (db, "", &list)); + for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) { + printf("%s %s\n", notmuch_config_list_key (list), notmuch_config_list_value(list)); + } + notmuch_config_list_destroy (list); +} +EOF +cat <<'EOF' >EXPECTED +== stdout == +aaabefore beforeval +testkey1 testvalue1 +testkey2 testvalue2 +zzzafter afterval +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "notmuch_database_get_config_list: one prefix" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ + notmuch_config_list_t *list; + EXPECT0(notmuch_database_get_config_list (db, "testkey", &list)); + for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) { + printf("%s %s\n", notmuch_config_list_key (list), notmuch_config_list_value(list)); + } + notmuch_config_list_destroy (list); +} +EOF +cat <<'EOF' >EXPECTED +== stdout == +testkey1 testvalue1 +testkey2 testvalue2 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "dump config" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ + EXPECT0(notmuch_database_set_config (db, "key with spaces", "value, with, spaces!")); +} +EOF +notmuch dump --include=config >OUTPUT +cat <<'EOF' >EXPECTED +#notmuch-dump batch-tag:2 config +#@ aaabefore beforeval +#@ key%20with%20spaces value,%20with,%20spaces%21 +#@ testkey1 testvalue1 +#@ testkey2 testvalue2 +#@ zzzafter afterval +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "restore config" +notmuch dump --include=config >EXPECTED +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ + EXPECT0(notmuch_database_set_config (db, "testkey1", "mutatedvalue")); +} +EOF +notmuch restore --include=config OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +test_done diff --git a/test/T600-named-queries.sh b/test/T600-named-queries.sh new file mode 100755 index 00000000..f0ae24f1 --- /dev/null +++ b/test/T600-named-queries.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +test_description='named queries' +. ./test-lib.sh || exit 1 + +QUERYSTR="date:2009-11-18..2009-11-18 and tag:unread" + +test_expect_code 1 "error adding named query before initializing DB" \ + "notmuch config set query.test \"$QUERYSTR\"" + +add_email_corpus + +test_expect_success "adding named query" \ + "notmuch config set query.test \"$QUERYSTR\"" + +QUERYSTR2="query:test and subject:Maildir" +test_expect_success "adding nested named query" \ + "notmuch config set query.test2 \"$QUERYSTR2\"" + +test_begin_subtest "retrieve named query" +output=$(notmuch config get query.test) +test_expect_equal "$QUERYSTR" "$output" + +test_begin_subtest "List all queries" +notmuch config list | grep ^query | notmuch_config_sanitize > OUTPUT +cat < EXPECTED +query.test=date:2009-11-18..2009-11-18 and tag:unread +query.test2=query:test and subject:Maildir +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "dump named queries" +notmuch dump | grep '^#@' > OUTPUT +cat< QUERIES.BEFORE +#@ query.test date%3a2009-11-18..2009-11-18%20and%20tag%3aunread +#@ query.test2 query%3atest%20and%20subject%3aMaildir +EOF +test_expect_equal_file QUERIES.BEFORE OUTPUT + +test_begin_subtest "delete named queries" +notmuch dump > BEFORE +notmuch config set query.test +notmuch dump | grep '^#@' > OUTPUT +cat< EXPECTED +#@ query.test2 query%3atest%20and%20subject%3aMaildir +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "restore named queries" +notmuch restore < BEFORE +notmuch dump | grep '^#@' > OUTPUT +test_expect_equal_file QUERIES.BEFORE OUTPUT + +if [ $NOTMUCH_HAVE_XAPIAN_FIELD_PROCESSOR -eq 1 ]; then + test_begin_subtest "search named query" + notmuch search query:test > OUTPUT + notmuch search $QUERYSTR > EXPECTED + test_expect_equal_file EXPECTED OUTPUT + + test_begin_subtest "search named query with other terms" + notmuch search query:test and subject:Maildir > OUTPUT + notmuch search $QUERYSTR and subject:Maildir > EXPECTED + test_expect_equal_file EXPECTED OUTPUT + + test_begin_subtest "search nested named query" + notmuch search query:test2 > OUTPUT + notmuch search $QUERYSTR2 > EXPECTED + test_expect_equal_file EXPECTED OUTPUT +fi + +test_done diff --git a/test/T620-lock.sh b/test/T620-lock.sh new file mode 100755 index 00000000..f46475e8 --- /dev/null +++ b/test/T620-lock.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +test_description="locking" +. ./test-lib.sh || exit 1 + +if [ "${NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK}" = "0" ]; then + test_subtest_missing_external_prereq_["lock retry support"]=t +fi + +add_email_corpus + +test_begin_subtest "blocking open" +test_C ${MAIL_DIR} <<'EOF' +#include +#include +#include +#include + +void +taggit (notmuch_database_t *db, const char *tag) +{ + notmuch_message_t *message; + + EXPECT0 (notmuch_database_find_message (db, "4EFC743A.3060609@april.org", &message)); + if (message == NULL) { + fprintf (stderr, "unable to find message"); + exit (1); + } + + EXPECT0 (notmuch_message_add_tag (message, tag)); + notmuch_message_destroy (message); +} + +int +main (int argc, char **argv) +{ + pid_t child; + const char *path = argv[1]; + + child = fork (); + if (child == -1) { + fprintf (stderr, "fork failed\n"); + exit (1); + } + + if (child == 0) { + notmuch_database_t *db2; + + sleep (1); + EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db2)); + taggit (db2, "child"); + EXPECT0 (notmuch_database_close (db2)); + } else { + notmuch_database_t *db; + + EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &db)); + taggit (db, "parent"); + sleep (2); + EXPECT0 (notmuch_database_close (db)); + wait (NULL); + } +} + +EOF +notmuch search --output=tags id:4EFC743A.3060609@april.org >> OUTPUT +cat <<'EOF' >EXPECTED +== stdout == +== stderr == +child +inbox +parent +unread +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_done diff --git a/test/database-test.c b/test/database-test.c index b8c3a67c..42f66559 100644 --- a/test/database-test.c +++ b/test/database-test.c @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: David Bremner */ diff --git a/test/notmuch-test b/test/notmuch-test index b8437127..e7d3151c 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -3,6 +3,7 @@ # Run tests # # Copyright (c) 2005 Junio C Hamano +# Copyright (c) 2010 Notmuch Developers # # Adapted from a Makefile to a shell script by Carl Worth (2010) @@ -14,16 +15,16 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then exit 1 fi -cd $(dirname "$0") +cd "$(dirname "$0")" -TESTS=${NOTMUCH_TESTS:-`echo T[0-9][0-9][0-9]-*.sh`} +TESTS=${NOTMUCH_TESTS:-T[0-9][0-9][0-9]-*.sh} # Clean up any results from a previous run -rm -r test-results >/dev/null 2>/dev/null +rm -rf test-results -# test for timeout utility +# Test for timeout utility if command -v timeout >/dev/null; then - TEST_TIMEOUT_CMD="timeout 2m " + TEST_TIMEOUT_CMD="timeout 2m" echo "INFO: using 2 minute timeout for tests" else TEST_TIMEOUT_CMD="" diff --git a/test/notmuch-test.h b/test/notmuch-test.h new file mode 100644 index 00000000..d39febbe --- /dev/null +++ b/test/notmuch-test.h @@ -0,0 +1,16 @@ +#ifndef _NOTMUCH_TEST_H +#define _NOTMUCH_TEST_H +#include +#include + +inline static void +expect0(int line, notmuch_status_t ret) +{ + if (ret) { + fprintf (stderr, "line %d: %s\n", line, ret); + exit (1); + } +} + +#define EXPECT0(v) expect0(__LINE__, v); +#endif diff --git a/test/parse-time.c b/test/parse-time.c index 901a4dde..694761cf 100644 --- a/test/parse-time.c +++ b/test/parse-time.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * * Author: Jani Nikula */ diff --git a/test/random-corpus.c b/test/random-corpus.c index d74271d9..aca694a3 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: David Bremner */ diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c index bb136687..a629927c 100644 --- a/test/smtp-dummy.c +++ b/test/smtp-dummy.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Authors: Carl Worth */ diff --git a/test/test-databases/Makefile.local b/test/test-databases/Makefile.local index ff333a1d..dcc8863c 100644 --- a/test/test-databases/Makefile.local +++ b/test/test-databases/Makefile.local @@ -1,6 +1,6 @@ # -*- makefile -*- -TEST_DATABASE_MIRROR=http://notmuchmail.org/releases/test-databases +TEST_DATABASE_MIRROR=https://notmuchmail.org/releases/test-databases dir := test/test-databases diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh index 4e17b781..03ef1d2d 100644 --- a/test/test-lib-common.sh +++ b/test/test-lib-common.sh @@ -1,5 +1,6 @@ # # Copyright (c) 2005 Junio C Hamano +# Copyright (c) 2010 Notmuch Developers # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,11 +13,17 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . # This file contains common code to be used by both the regular # (correctness) tests and the performance tests. +# test-lib.sh defines die() which echoes to nonstandard fd where +# output was redirected earlier in that file. If test-lib.sh is not +# loaded, neither this redirection nor die() function were defined. +# +type die >/dev/null 2>&1 || die () { echo "$@" >&2; exit 1; } + find_notmuch_path () { dir="$1" @@ -51,6 +58,11 @@ restore_database () { TEST_DIRECTORY=$(pwd -P) notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"` +# Prepend $TEST_DIRECTORY/../lib to LD_LIBRARY_PATH, to make tests work +# on systems where ../notmuch depends on LD_LIBRARY_PATH. +LD_LIBRARY_PATH=${TEST_DIRECTORY%/*}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} +export LD_LIBRARY_PATH + # configure output . $notmuch_path/sh.config || exit 1 diff --git a/test/test-lib.el b/test/test-lib.el index 596a7051..496626f6 100644 --- a/test/test-lib.el +++ b/test/test-lib.el @@ -16,7 +16,7 @@ ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License -;; along with Notmuch. If not, see . +;; along with Notmuch. If not, see . ;; ;; Authors: Dmitry Kurochkin diff --git a/test/test-lib.sh b/test/test-lib.sh index ac04b15a..aac0343b 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -1,5 +1,6 @@ # # Copyright (c) 2005 Junio C Hamano +# Copyright (c) 2010 Notmuch Developers # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,7 +13,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . if [ ${BASH_VERSINFO[0]} -lt 4 ]; then echo "Error: The notmuch test suite requires a bash version >= 4.0" @@ -222,15 +223,15 @@ test_fixed=0 test_broken=0 test_success=0 -_die_common () { +_exit_common () { code=$? trap - EXIT set +ex rm -rf "$TEST_TMPDIR" } -die () { - _die_common +trap_exit () { + _exit_common if test -n "$GIT_EXIT_OK" then exit $code @@ -244,17 +245,27 @@ die () { fi } -die_signal () { - _die_common +trap_signal () { + _exit_common echo >&6 "FATAL: $0: interrupted by signal" $((code - 128)) exit $code } +die () { + _exit_common + exec >&6 + say_color error '%-6s' FATAL + echo " $*" + echo + echo "Unexpected exit while executing $0." + exit 1 +} + GIT_EXIT_OK= # Note: TEST_TMPDIR *NOT* exported! TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX") -trap 'die' EXIT -trap 'die_signal' HUP INT TERM +trap 'trap_exit' EXIT +trap 'trap_signal' HUP INT TERM test_decode_color () { sed -e 's/.\[1m//g' \ @@ -543,7 +554,7 @@ add_email_corpus () cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR} else cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR} - notmuch new >/dev/null + notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus" cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail fi } @@ -673,6 +684,12 @@ NOTMUCH_NEW () notmuch new "${@}" | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file' } +NOTMUCH_DUMP_TAGS () +{ + # this relies on the default format being batch-tag, otherwise some tests will break + notmuch dump --include=tags "${@}" | sed '/^#/d' | sort +} + notmuch_search_sanitize () { perl -pe 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/' @@ -733,6 +750,17 @@ notmuch_uuid_sanitize () { sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g' } + +notmuch_built_with_sanitize () +{ + sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/' +} + +notmuch_config_sanitize () +{ + notmuch_dir_sanitize | notmuch_built_with_sanitize +} + # End of notmuch helper functions # Use test_set_prereq to tell that a particular prerequisite is available. @@ -1164,15 +1192,13 @@ test_emacs () { } test_python() { - export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib - export PYTHONPATH=$TEST_DIRECTORY/../bindings/python - - (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \ - | $NOTMUCH_PYTHON - + # Note: if there is need to print debug information from python program, + # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w') + PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \ + $NOTMUCH_PYTHON -B - > OUTPUT } test_ruby() { - export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib MAIL_DIR=$MAIL_DIR ruby -I $TEST_DIRECTORY/../bindings/ruby> OUTPUT } @@ -1180,8 +1206,7 @@ test_C () { exec_file="test${test_count}" test_file="${exec_file}.c" cat > ${test_file} - export LD_LIBRARY_PATH=${TEST_DIRECTORY}/../lib - ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY}/../lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc + ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY} -I${TEST_DIRECTORY}/../lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc echo "== stdout ==" > OUTPUT.stdout echo "== stderr ==" > OUTPUT.stderr ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr diff --git a/util/error_util.c b/util/error_util.c index d6e60fc9..778bbd52 100644 --- a/util/error_util.c +++ b/util/error_util.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/util/error_util.h b/util/error_util.h index 17c8727d..4bb338a2 100644 --- a/util/error_util.h +++ b/util/error_util.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/util/hex-escape.c b/util/hex-escape.c index b4a2a02a..8883ff90 100644 --- a/util/hex-escape.c +++ b/util/hex-escape.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: David Bremner */ diff --git a/util/string-util.c b/util/string-util.c index 92af937f..18125309 100644 --- a/util/string-util.c +++ b/util/string-util.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Jani Nikula */ diff --git a/util/xutil.c b/util/xutil.c index ac496daf..f211eaaa 100644 --- a/util/xutil.c +++ b/util/xutil.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/util/xutil.h b/util/xutil.h index b84e0e25..4829f33c 100644 --- a/util/xutil.h +++ b/util/xutil.h @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Carl Worth */ diff --git a/util/zlib-extra.c b/util/zlib-extra.c index 2e704457..2b2cd8f9 100644 --- a/util/zlib-extra.c +++ b/util/zlib-extra.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: David Bremner */