From: David Bremner Date: Mon, 31 May 2021 23:26:31 +0000 (-0300) Subject: Merge remote-tracking branch 'origin/release' X-Git-Tag: archive/debian/0.33_rc0-1~67 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=100106a45d9f362ed8770c95cf35bd43f6580511;hp=0478c0e077a697caeaa2f99678f69b57e6975b6e Merge remote-tracking branch 'origin/release' --- diff --git a/Makefile.local b/Makefile.local index bbb8f0b6..e12b94cd 100644 --- a/Makefile.local +++ b/Makefile.local @@ -231,6 +231,7 @@ notmuch_client_srcs = \ gmime-filter-reply.c \ hooks.c \ notmuch.c \ + notmuch-client-init.c \ notmuch-compact.c \ notmuch-config.c \ notmuch-count.c \ diff --git a/NEWS b/NEWS index 4bb4779e..35b57cef 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Notmuch 0.33 (UNRELEASED) +========================= + +Vim +--- + +Respect excluded tags when showing a thread. + Notmuch 0.32.1 (2021-05-15) =========================== diff --git a/bindings/Makefile.local b/bindings/Makefile.local index bc960bbc..3672e69f 100644 --- a/bindings/Makefile.local +++ b/bindings/Makefile.local @@ -10,7 +10,7 @@ ifeq ($(HAVE_RUBY_DEV),1) LIBNOTMUCH="../../lib/$(LINKER_NAME)" \ NOTMUCH_SRCDIR='$(NOTMUCH_SRCDIR)' \ $(RUBY) extconf.rb --vendor - $(MAKE) -C $(dir)/ruby + $(MAKE) -C $(dir)/ruby CFLAGS="$(CFLAGS) -pipe -fno-plt -fPIC" endif python-cffi-bindings: lib/$(LINKER_NAME) diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c index 416eb709..bb993d86 100644 --- a/bindings/ruby/database.c +++ b/bindings/ruby/database.c @@ -23,7 +23,7 @@ VALUE notmuch_rb_database_alloc (VALUE klass) { - return Data_Wrap_Struct (klass, NULL, NULL, NULL); + return Data_Wrap_Notmuch_Object (klass, ¬much_rb_database_type, NULL); } /* @@ -74,7 +74,7 @@ notmuch_rb_database_initialize (int argc, VALUE *argv, VALUE self) mode = NOTMUCH_DATABASE_MODE_READ_ONLY; } - Check_Type (self, T_DATA); + rb_check_typeddata (self, ¬much_rb_database_type); if (create) ret = notmuch_database_create (path, &database); else @@ -114,11 +114,7 @@ VALUE notmuch_rb_database_close (VALUE self) { notmuch_status_t ret; - notmuch_database_t *db; - - Data_Get_Notmuch_Database (self, db); - ret = notmuch_database_destroy (db); - DATA_PTR (self) = NULL; + ret = notmuch_rb_object_destroy (self, ¬much_rb_database_type); notmuch_rb_status_raise (ret); return Qnil; @@ -266,7 +262,7 @@ notmuch_rb_database_get_directory (VALUE self, VALUE pathv) ret = notmuch_database_get_directory (db, path, &dir); notmuch_rb_status_raise (ret); if (dir) - return Data_Wrap_Struct (notmuch_rb_cDirectory, NULL, NULL, dir); + return Data_Wrap_Notmuch_Object (notmuch_rb_cDirectory, ¬much_rb_directory_type, dir); return Qnil; } @@ -293,7 +289,7 @@ notmuch_rb_database_add_message (VALUE self, VALUE pathv) ret = notmuch_database_index_file (db, path, NULL, &message); notmuch_rb_status_raise (ret); - return rb_assoc_new (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message), + return rb_assoc_new (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message), (ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse); } @@ -344,7 +340,7 @@ notmuch_rb_database_find_message (VALUE self, VALUE idv) notmuch_rb_status_raise (ret); if (message) - return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message); return Qnil; } @@ -370,7 +366,7 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv) notmuch_rb_status_raise (ret); if (message) - return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message); return Qnil; } @@ -395,7 +391,7 @@ notmuch_rb_database_get_all_tags (VALUE self) rb_raise (notmuch_rb_eBaseError, "%s", msg); } - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } /* @@ -419,5 +415,5 @@ notmuch_rb_database_query_create (VALUE self, VALUE qstrv) if (!query) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cQuery, NULL, NULL, query); + return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, ¬much_rb_query_type, query); } diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 48544ca2..9860ee17 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -55,77 +55,70 @@ extern ID ID_db_mode; # define RSTRING_PTR(v) (RSTRING((v))->ptr) #endif /* !defined (RSTRING_PTR) */ -#define Data_Get_Notmuch_Database(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "database closed"); \ - Data_Get_Struct ((obj), notmuch_database_t, (ptr)); \ +extern const rb_data_type_t notmuch_rb_object_type; +extern const rb_data_type_t notmuch_rb_database_type; +extern const rb_data_type_t notmuch_rb_directory_type; +extern const rb_data_type_t notmuch_rb_filenames_type; +extern const rb_data_type_t notmuch_rb_query_type; +extern const rb_data_type_t notmuch_rb_threads_type; +extern const rb_data_type_t notmuch_rb_thread_type; +extern const rb_data_type_t notmuch_rb_messages_type; +extern const rb_data_type_t notmuch_rb_message_type; +extern const rb_data_type_t notmuch_rb_tags_type; + +#define Data_Get_Notmuch_Object(obj, type, ptr) \ + do { \ + (ptr) = rb_check_typeddata ((obj), (type)); \ + if (RB_UNLIKELY (!(ptr))) { \ + VALUE cname = rb_class_name (CLASS_OF ((obj))); \ + rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname); \ + } \ } while (0) -#define Data_Get_Notmuch_Directory(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "directory destroyed"); \ - Data_Get_Struct ((obj), notmuch_directory_t, (ptr)); \ - } while (0) +#define Data_Wrap_Notmuch_Object(klass, type, ptr) \ + TypedData_Wrap_Struct ((klass), (type), (ptr)) -#define Data_Get_Notmuch_FileNames(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "filenames destroyed"); \ - Data_Get_Struct ((obj), notmuch_filenames_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_Database(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_database_type, (ptr)) -#define Data_Get_Notmuch_Query(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "query destroyed"); \ - Data_Get_Struct ((obj), notmuch_query_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_Directory(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_directory_type, (ptr)) -#define Data_Get_Notmuch_Threads(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "threads destroyed"); \ - Data_Get_Struct ((obj), notmuch_threads_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_FileNames(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_filenames_type, (ptr)) -#define Data_Get_Notmuch_Messages(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "messages destroyed"); \ - Data_Get_Struct ((obj), notmuch_messages_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_Query(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_query_type, (ptr)) -#define Data_Get_Notmuch_Thread(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "thread destroyed"); \ - Data_Get_Struct ((obj), notmuch_thread_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_Threads(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_threads_type, (ptr)) -#define Data_Get_Notmuch_Message(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "message destroyed"); \ - Data_Get_Struct ((obj), notmuch_message_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_Messages(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_messages_type, (ptr)) -#define Data_Get_Notmuch_Tags(obj, ptr) \ - do { \ - Check_Type ((obj), T_DATA); \ - if (DATA_PTR ((obj)) == NULL) \ - rb_raise (rb_eRuntimeError, "tags destroyed"); \ - Data_Get_Struct ((obj), notmuch_tags_t, (ptr)); \ - } while (0) +#define Data_Get_Notmuch_Thread(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_thread_type, (ptr)) + +#define Data_Get_Notmuch_Message(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_message_type, (ptr)) + +#define Data_Get_Notmuch_Tags(obj, ptr) \ + Data_Get_Notmuch_Object ((obj), ¬much_rb_tags_type, (ptr)) + +static inline notmuch_status_t +notmuch_rb_object_destroy (VALUE rb_object, const rb_data_type_t *type) +{ + void *nm_object; + notmuch_status_t ret; + + Data_Get_Notmuch_Object (rb_object, type, nm_object); + + /* Call the corresponding notmuch_*_destroy function */ + ret = ((notmuch_status_t (*)(void *)) type->data) (nm_object); + DATA_PTR (rb_object) = NULL; + + return ret; +} /* status.c */ void diff --git a/bindings/ruby/directory.c b/bindings/ruby/directory.c index 0f37b391..910f0a99 100644 --- a/bindings/ruby/directory.c +++ b/bindings/ruby/directory.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_directory_destroy (VALUE self) { - notmuch_directory_t *dir; - - Data_Get_Struct (self, notmuch_directory_t, dir); - - notmuch_directory_destroy (dir); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_directory_type); return Qnil; } @@ -92,7 +87,7 @@ notmuch_rb_directory_get_child_files (VALUE self) fnames = notmuch_directory_get_child_files (dir); - return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, ¬much_rb_filenames_type, fnames); } /* @@ -111,5 +106,5 @@ notmuch_rb_directory_get_child_directories (VALUE self) fnames = notmuch_directory_get_child_directories (dir); - return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, ¬much_rb_filenames_type, fnames); } diff --git a/bindings/ruby/filenames.c b/bindings/ruby/filenames.c index 656c58e6..0dec1952 100644 --- a/bindings/ruby/filenames.c +++ b/bindings/ruby/filenames.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_filenames_destroy (VALUE self) { - notmuch_filenames_t *fnames; - - Data_Get_Notmuch_FileNames (self, fnames); - - notmuch_filenames_destroy (fnames); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_filenames_type); return Qnil; } diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index 819fd1e3..bedfbf60 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -46,6 +46,27 @@ ID ID_call; ID ID_db_create; ID ID_db_mode; +const rb_data_type_t notmuch_rb_object_type = { + .wrap_struct_name = "notmuch_object", +}; + +#define define_type(id) \ + const rb_data_type_t notmuch_rb_ ## id ## _type = { \ + .wrap_struct_name = "notmuch_" #id, \ + .parent = ¬much_rb_object_type, \ + .data = ¬much_ ## id ## _destroy, \ + } + +define_type (database); +define_type (directory); +define_type (filenames); +define_type (query); +define_type (threads); +define_type (thread); +define_type (messages); +define_type (message); +define_type (tags); + /* * Document-module: Notmuch * @@ -133,6 +154,30 @@ Init_notmuch (void) * Maximum allowed length of a tag */ rb_define_const (mod, "TAG_MAX", INT2FIX (NOTMUCH_TAG_MAX)); + /* + * Document-const: Notmuch::EXCLUDE_FLAG + * + * Only flag excluded results + */ + rb_define_const (mod, "EXCLUDE_FLAG", INT2FIX (NOTMUCH_EXCLUDE_FLAG)); + /* + * Document-const: Notmuch::EXCLUDE_TRUE + * + * Exclude messages from the results + */ + rb_define_const (mod, "EXCLUDE_TRUE", INT2FIX (NOTMUCH_EXCLUDE_TRUE)); + /* + * Document-const: Notmuch::EXCLUDE_FALSE + * + * Don't exclude anything + */ + rb_define_const (mod, "EXCLUDE_FALSE", INT2FIX (NOTMUCH_EXCLUDE_FALSE)); + /* + * Document-const: Notmuch::EXCLUDE_ALL + * + * Exclude all results + */ + rb_define_const (mod, "EXCLUDE_ALL", INT2FIX (NOTMUCH_EXCLUDE_ALL)); /* * Document-class: Notmuch::BaseError diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c index 6ea82afa..f45c95cc 100644 --- a/bindings/ruby/message.c +++ b/bindings/ruby/message.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_message_destroy (VALUE self) { - notmuch_message_t *message; - - Data_Get_Notmuch_Message (self, message); - - notmuch_message_destroy (message); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_message_type); return Qnil; } @@ -89,7 +84,7 @@ notmuch_rb_message_get_replies (VALUE self) messages = notmuch_message_get_replies (message); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, messages); } /* @@ -125,7 +120,7 @@ notmuch_rb_message_get_filenames (VALUE self) fnames = notmuch_message_get_filenames (message); - return Data_Wrap_Struct (notmuch_rb_cFileNames, NULL, NULL, fnames); + return Data_Wrap_Notmuch_Object (notmuch_rb_cFileNames, ¬much_rb_filenames_type, fnames); } /* @@ -226,7 +221,7 @@ notmuch_rb_message_get_tags (VALUE self) if (!tags) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } /* diff --git a/bindings/ruby/messages.c b/bindings/ruby/messages.c index a337feeb..ca5b10d0 100644 --- a/bindings/ruby/messages.c +++ b/bindings/ruby/messages.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_messages_destroy (VALUE self) { - notmuch_messages_t *messages; - - Data_Get_Notmuch_Messages (self, messages); - - notmuch_messages_destroy (messages); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_messages_type); return Qnil; } @@ -53,7 +48,7 @@ notmuch_rb_messages_each (VALUE self) for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { message = notmuch_messages_get (messages); - rb_yield (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message)); + rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message)); } return self; @@ -76,5 +71,5 @@ notmuch_rb_messages_collect_tags (VALUE self) if (!tags) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 8b46d700..8a2b4d3d 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_query_destroy (VALUE self) { - notmuch_query_t *query; - - Data_Get_Notmuch_Query (self, query); - - notmuch_query_destroy (query); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_query_type); return Qnil; } @@ -107,19 +102,21 @@ notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv) } /* - * call-seq: QUERY.omit_excluded=(boolean) => nil + * call-seq: QUERY.omit_excluded=(fixnum) => nil * * Specify whether to omit excluded results or simply flag them. - * By default, this is set to +true+. + * By default, this is set to +Notmuch::EXCLUDE_TRUE+. */ VALUE notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv) { notmuch_query_t *query; + notmuch_exclude_t value; Data_Get_Notmuch_Query (self, query); - notmuch_query_set_omit_excluded (query, RTEST (omitv)); + value = FIXNUM_P (omitv) ? FIX2UINT (omitv) : RTEST(omitv); + notmuch_query_set_omit_excluded (query, value); return Qnil; } @@ -142,7 +139,7 @@ notmuch_rb_query_search_threads (VALUE self) if (status) notmuch_rb_status_raise (status); - return Data_Wrap_Struct (notmuch_rb_cThreads, NULL, NULL, threads); + return Data_Wrap_Notmuch_Object (notmuch_rb_cThreads, ¬much_rb_threads_type, threads); } /* @@ -163,7 +160,7 @@ notmuch_rb_query_search_messages (VALUE self) if (status) notmuch_rb_status_raise (status); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, messages); } /* diff --git a/bindings/ruby/tags.c b/bindings/ruby/tags.c index db8b4cfc..2af85e36 100644 --- a/bindings/ruby/tags.c +++ b/bindings/ruby/tags.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_tags_destroy (VALUE self) { - notmuch_tags_t *tags; - - Data_Get_Notmuch_Tags (self, tags); - - notmuch_tags_destroy (tags); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_tags_type); return Qnil; } diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c index 9b295981..7cb2a3dc 100644 --- a/bindings/ruby/thread.c +++ b/bindings/ruby/thread.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_thread_destroy (VALUE self) { - notmuch_thread_t *thread; - - Data_Get_Notmuch_Thread (self, thread); - - notmuch_thread_destroy (thread); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_thread_type); return Qnil; } @@ -88,7 +83,7 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self) if (!messages) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, messages); } /* @@ -108,7 +103,7 @@ notmuch_rb_thread_get_messages (VALUE self) if (!messages) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages); + return Data_Wrap_Notmuch_Object (notmuch_rb_cMessages, ¬much_rb_messages_type, messages); } /* @@ -209,5 +204,5 @@ notmuch_rb_thread_get_tags (VALUE self) if (!tags) rb_raise (notmuch_rb_eMemoryError, "Out of memory"); - return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags); + return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags); } diff --git a/bindings/ruby/threads.c b/bindings/ruby/threads.c index ed403a8f..50280260 100644 --- a/bindings/ruby/threads.c +++ b/bindings/ruby/threads.c @@ -28,12 +28,7 @@ VALUE notmuch_rb_threads_destroy (VALUE self) { - notmuch_threads_t *threads; - - Data_Get_Struct (self, notmuch_threads_t, threads); - - notmuch_threads_destroy (threads); - DATA_PTR (self) = NULL; + notmuch_rb_object_destroy (self, ¬much_rb_threads_type); return Qnil; } @@ -53,7 +48,7 @@ notmuch_rb_threads_each (VALUE self) for (; notmuch_threads_valid (threads); notmuch_threads_move_to_next (threads)) { thread = notmuch_threads_get (threads); - rb_yield (Data_Wrap_Struct (notmuch_rb_cThread, NULL, NULL, thread)); + rb_yield (Data_Wrap_Notmuch_Object (notmuch_rb_cThread, ¬much_rb_thread_type, thread)); } return self; diff --git a/doc/conf.py b/doc/conf.py index d0f7f66c..4a4a3421 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -80,6 +80,11 @@ htmlhelp_basename = 'notmuchdoc' # Despite the name, this actually affects manual pages as well. html_use_smartypants = False +# See: +# - https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-manpages_url +# - https://manpages.debian.org/ +manpages_url = 'https://manpages.debian.org/{page}.{section}.html' + # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples diff --git a/doc/man1/notmuch-address.rst b/doc/man1/notmuch-address.rst index 2a7df6f0..7423b629 100644 --- a/doc/man1/notmuch-address.rst +++ b/doc/man1/notmuch-address.rst @@ -1,3 +1,5 @@ +.. _notmuch-address(1): + =============== notmuch-address =============== @@ -13,94 +15,102 @@ DESCRIPTION Search for messages matching the given search terms, and display the addresses from them. Duplicate addresses are filtered out. -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for . Supported options for **address** include -``--format=``\ (**json**\ \|\ **sexp**\ \|\ **text**\ \|\ **text0**) - Presents the results in either JSON, S-Expressions, newline - character separated plain-text (default), or null character - separated plain-text (compatible with **xargs(1)** -0 option where - available). - -``--format-version=N`` - Use the specified structured output format version. This is - intended for programs that invoke **notmuch(1)** internally. If - omitted, the latest supported version will be used. - -``--output=(sender|recipients|count|address)`` - Controls which information appears in the output. This option can - be given multiple times to combine different outputs. When - neither ``--output=sender`` nor ``--output=recipients`` is - given, ``--output=sender`` is implied. - - **sender** - Output all addresses from the *From* header. - - Note: Searching for **sender** should be much faster than - searching for **recipients**, because sender addresses are - cached directly in the database whereas other addresses need - to be fetched from message files. - - **recipients** - Output all addresses from the *To*, *Cc* and *Bcc* headers. - - **count** - Print the count of how many times was the address encountered - during search. - - Note: With this option, addresses are printed only after the - whole search is finished. This may take long time. - - **address** - Output only the email addresses instead of the full mailboxes - with names and email addresses. This option has no effect on - the JSON or S-Expression output formats. - -``--deduplicate=(no|mailbox|address)`` - Control the deduplication of results. - - **no** - Output all occurrences of addresses in the matching - messages. This is not applicable with ``--output=count``. - - **mailbox** - Deduplicate addresses based on the full, case sensitive name - and email address, or mailbox. This is effectively the same as - piping the ``--deduplicate=no`` output to **sort | uniq**, except - for the order of results. This is the default. - - **address** - Deduplicate addresses based on the case insensitive address - part of the mailbox. Of all the variants (with different name - or case), print the one occurring most frequently among the - matching messages. If ``--output=count`` is specified, include all - variants in the count. - -``--sort=``\ (**newest-first**\ \|\ **oldest-first**) - This option can be used to present results in either chronological - order (**oldest-first**) or reverse chronological order - (**newest-first**). - - By default, results will be displayed in reverse chronological - order, (that is, the newest results will be displayed first). - - However, if either ``--output=count`` or ``--deduplicate=address`` is - specified, this option is ignored and the order of the results is - unspecified. - -``--exclude=(true|false)`` - A message is called "excluded" if it matches at least one tag in - search.exclude\_tags that does not appear explicitly in the search - terms. This option specifies whether to omit excluded messages in - the search process. - - The default value, **true**, prevents excluded messages from - matching the search terms. - - **false** allows excluded messages to match search terms and - appear in displayed results. +.. program:: address + +.. option:: --format=(json|sexp|text|text0) + + Presents the results in either JSON, S-Expressions, newline + character separated plain-text (default), or null character + separated plain-text (compatible with :manpage:`xargs(1)` -0 + option where available). + +.. option:: --format-version=N + + Use the specified structured output format version. This is + intended for programs that invoke :any:`notmuch(1)` internally. If + omitted, the latest supported version will be used. + +.. option:: --output=(sender|recipients|count|address) + + Controls which information appears in the output. This option can + be given multiple times to combine different outputs. When + neither ``--output=sender`` nor ``--output=recipients`` is + given, ``--output=sender`` is implied. + + **sender** + Output all addresses from the *From* header. + + Note: Searching for **sender** should be much faster than + searching for **recipients**, because sender addresses are + cached directly in the database whereas other addresses need + to be fetched from message files. + + **recipients** + Output all addresses from the *To*, *Cc* and *Bcc* headers. + + **count** + Print the count of how many times was the address encountered + during search. + + Note: With this option, addresses are printed only after the + whole search is finished. This may take long time. + + **address** + Output only the email addresses instead of the full mailboxes + with names and email addresses. This option has no effect on + the JSON or S-Expression output formats. + +.. option:: --deduplicate=(no|mailbox|address) + + Control the deduplication of results. + + **no** + Output all occurrences of addresses in the matching + messages. This is not applicable with ``--output=count``. + + **mailbox** + Deduplicate addresses based on the full, case sensitive name + and email address, or mailbox. This is effectively the same as + piping the ``--deduplicate=no`` output to **sort | uniq**, except + for the order of results. This is the default. + + **address** + Deduplicate addresses based on the case insensitive address + part of the mailbox. Of all the variants (with different name + or case), print the one occurring most frequently among the + matching messages. If ``--output=count`` is specified, include all + variants in the count. + +.. option:: --sort=(newest-first|oldest-first) + + This option can be used to present results in either chronological + order (**oldest-first**) or reverse chronological order + (**newest-first**). + + By default, results will be displayed in reverse chronological + order, (that is, the newest results will be displayed first). + + However, if either ``--output=count`` or ``--deduplicate=address`` is + specified, this option is ignored and the order of the results is + unspecified. + +.. option:: --exclude=(true|false) + + A message is called "excluded" if it matches at least one tag in + search.exclude\_tags that does not appear explicitly in the search + terms. This option specifies whether to omit excluded messages in + the search process. + + The default value, **true**, prevents excluded messages from + matching the search terms. + + **false** allows excluded messages to match search terms and + appear in displayed results. EXIT STATUS =========== @@ -116,16 +126,16 @@ This command supports the following special exit status codes SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)**, -**notmuch-search(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-compact.rst b/doc/man1/notmuch-compact.rst index b05593ec..cb1c858b 100644 --- a/doc/man1/notmuch-compact.rst +++ b/doc/man1/notmuch-compact.rst @@ -1,3 +1,5 @@ +.. _notmuch-compact(1): + =============== notmuch-compact =============== @@ -24,37 +26,31 @@ process (which may be quite long) to protect data integrity. Supported options for **compact** include -``--backup=``\ - Save the current database to the given directory before replacing - it with the compacted database. The backup directory must not - exist and it must reside on the same mounted filesystem as the - current database. +.. program:: compact -``--quiet`` - Do not report database compaction progress to stdout. +.. option:: --backup= -ENVIRONMENT -=========== + Save the current database to the given directory before replacing + it with the compacted database. The backup directory must not + exist and it must reside on the same mounted filesystem as the + current database. -The following environment variables can be used to control the behavior -of notmuch. +.. option:: --quiet -**NOTMUCH\_CONFIG** - Specifies the location of the notmuch configuration file. Notmuch - will use ${HOME}/.notmuch-config if this variable is not set. + Do not report database compaction progress to stdout. SEE ALSO ======== -**notmuch(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst index 75c59ff9..56f4a160 100644 --- a/doc/man1/notmuch-config.rst +++ b/doc/man1/notmuch-config.rst @@ -1,3 +1,5 @@ +.. _notmuch-config(1): + ============== notmuch-config ============== @@ -17,32 +19,37 @@ DESCRIPTION The **config** command can be used to get or set settings in the notmuch configuration file and corresponding database. -**get** - The value of the specified configuration item is printed to - stdout. If the item has multiple values (it is a list), each value - is separated by a newline character. +.. program:: config + +.. option:: get + + The value of the specified configuration item is printed to + stdout. If the item has multiple values (it is a list), each value + is separated by a newline character. + +.. option:: set -**set** - The specified configuration item is set to the given value. To - specify a multiple-value item (a list), provide each value as a - separate command-line argument. + The specified configuration item is set to the given value. To + specify a multiple-value item (a list), provide each value as a + separate command-line argument. - If no values are provided, the specified configuration item will - be removed from the configuration file. + If no values are provided, the specified configuration item will + be removed from the configuration file. - With the `--database` option, updates configuration metadata - stored in the database, rather than the default (text) - configuration file. + With the `--database` option, updates configuration metadata + stored in the database, rather than the default (text) + configuration file. -**list** - Every configuration item is printed to stdout, each on a separate - line of the form:: +.. option:: list - section.item=value + Every configuration item is printed to stdout, each on a separate + line of the form:: - No additional whitespace surrounds the dot or equals sign - characters. In a multiple-value item (a list), the values are - separated by semicolon characters. + section.item=value + + No additional whitespace surrounds the dot or equals sign + characters. In a multiple-value item (a list), the values are + separated by semicolon characters. The available configuration items are described below. Non-absolute paths are presumed relative to `$HOME` for items in section @@ -76,7 +83,7 @@ paths are presumed relative to `$HOME` for items in section **database.hook_dir** Directory containing hooks run by notmuch commands. See - **notmuch-hooks(5)**. + :any:`notmuch-hooks(5)`. **user.name** Your full name. @@ -103,7 +110,7 @@ paths are presumed relative to `$HOME` for items in section **new.ignore** A list to specify files and directories that will not be searched - for messages by **notmuch new**. Each entry in the list is either: + for messages by :any:`notmuch-new(1)`. Each entry in the list is either: A file or a directory name, without path, that will be ignored, regardless of the location in the mail store directory hierarchy. @@ -124,7 +131,7 @@ paths are presumed relative to `$HOME` for items in section default. Using an excluded tag in a query will override that exclusion. - Default: empty list. Note that **notmuch-setup(1)** puts + Default: empty list. Note that :any:`notmuch-setup(1)` puts ``deleted;spam`` here when creating new configuration file. **maildir.synchronize\_flags** @@ -145,16 +152,18 @@ paths are presumed relative to `$HOME` for items in section | S | unread (added when 'S' flag is not present) | +--------+-----------------------------------------------+ - The **notmuch new** command will notice flag changes in filenames - and update tags, while the **notmuch tag** and **notmuch restore** - commands will notice tag changes and update flags in filenames. + The :any:`notmuch-new(1)` command will notice flag changes in + filenames and update tags, while the :any:`notmuch-tag(1)` and + :any:`notmuch-restore(1)` commands will notice tag changes and + update flags in filenames. If there have been any changes in the maildir (new messages added, old ones removed or renamed, maildir flags changed, etc.), it is - advisable to run **notmuch new** before **notmuch tag** or - **notmuch restore** commands to ensure the tag changes are - properly synchronized to the maildir flags, as the commands expect - the database and maildir to be in sync. + advisable to run :any:`notmuch-new(1)` before + :any:`notmuch-tag(1)` or :any:`notmuch-restore(1)` commands to + ensure the tag changes are properly synchronized to the maildir + flags, as the commands expect the database and maildir to be in + sync. Default: ``true``. @@ -174,8 +183,8 @@ paths are presumed relative to `$HOME` for items in section ``nostash`` is the same as ``true`` except that it will not stash newly-discovered session keys in the database. - From the command line (i.e. during **notmuch-new(1)**, - **notmuch-insert(1)**, or **notmuch-reindex(1)**), the user can + From the command line (i.e. during :any:`notmuch-new(1)`, + :any:`notmuch-insert(1)`, or :any:`notmuch-reindex(1)`), the user can override the database's stored decryption policy with the ``--decrypt=`` option. @@ -199,7 +208,7 @@ paths are presumed relative to `$HOME` for items in section Stashed session keys are kept in the database as properties associated with the message. See ``session-key`` in - **notmuch-properties(7)** for more details about how they can be + :any:`notmuch-properties(7)` for more details about how they can be useful. Be aware that the notmuch index is likely sufficient (and a @@ -217,7 +226,7 @@ paths are presumed relative to `$HOME` for items in section prefix ``List:`` that searches the ``List-Id`` field. User defined prefixes must not start with 'a'...'z'; in particular adding a prefix with same name as a predefined prefix is not - supported. See **notmuch-search-terms(7)** for a list of existing + supported. See :any:`notmuch-search-terms(7)` for a list of existing prefixes, and an explanation of probabilistic prefixes. **built_with.** @@ -228,56 +237,56 @@ paths are presumed relative to `$HOME` for items in section **query.** Expansion for named query called . See - **notmuch-search-terms(7)** for more information about named + :any:`notmuch-search-terms(7)` for more information about named queries. -ENVIRONMENT -=========== - -The following environment variables can be used to control the behavior -of notmuch. - -**NOTMUCH\_CONFIG** - Specifies the location of the notmuch configuration file. - -**NOTMUCH_PROFILE** - Selects among notmuch configurations. - FILES ===== CONFIGURATION ------------- -If ``NOTMUCH_CONFIG`` is unset, notmuch tries (in order) +Notmuch configuration file search order: + +1. File specified by :option:`notmuch --config` global option; see + :any:`notmuch(1)`. + +2. File specified by :envvar:`NOTMUCH_CONFIG` environment variable. -- ``$XDG_CONFIG_HOME/notmuch//config`` where ```` is - defined by ``$NOTMUCH_PROFILE`` or "default" -- ``${HOME}/.notmuch-config`` where ```` is - ``.$NOTMUCH_PROFILE`` or "" +3. ``$XDG_CONFIG_HOME/notmuch//config`` where ```` + is defined by :envvar:`NOTMUCH_PROFILE` environment variable if + set, ``$XDG_CONFIG_HOME/notmuch/default/config`` otherwise. + +4. ``$HOME/.notmuch-config.`` where ```` is defined + by :envvar:`NOTMUCH_PROFILE` environment variable if set, + ``$HOME/.notmuch-config`` otherwise. Hooks ----- -If ``database.hook_dir`` is unset, notmuch tries (in order) +Notmuch hook directory search order: + +1. Directory specified by ``database.hook_dir`` configuration option. + +2. ``$XDG_CONFIG_HOME/notmuch//hooks`` where ```` + is defined by :envvar:`NOTMUCH_PROFILE` environment variable if + set, ``$XDG_CONFIG_HOME/notmuch/default/hooks`` otherwise. -- ``$XDG_CONFIG_HOME/notmuch//hooks`` where ```` is - defined by ``$NOTMUCH_PROFILE`` or "default" -- ``/.notmuch/hooks`` +3. ``/.notmuch/hooks`` SEE ALSO ======== -**notmuch(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-properties(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-properties(7)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-count.rst b/doc/man1/notmuch-count.rst index 0eac5dbe..9a7e4bac 100644 --- a/doc/man1/notmuch-count.rst +++ b/doc/man1/notmuch-count.rst @@ -1,3 +1,5 @@ +.. _notmuch-count(1): + ============= notmuch-count ============= @@ -17,56 +19,63 @@ The number of matching messages (or threads) is output to stdout. With no search terms, a count of all messages (or threads) in the database will be displayed. -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for . Supported options for **count** include -``--output=(messages|threads|files)`` - **messages** - Output the number of matching messages. This is the default. +.. program:: count + +.. option:: --output=(messages|threads|files) + + **messages** + Output the number of matching messages. This is the default. + + **threads** + Output the number of matching threads. + + **files** + Output the number of files associated with matching + messages. This may be bigger than the number of matching + messages due to duplicates (i.e. multiple files having the + same message-id). + +.. option:: --exclude=(true|false) + + Specify whether to omit messages matching search.exclude\_tags from + the count (the default) or not. - **threads** - Output the number of matching threads. +.. option:: --batch - **files** - Output the number of files associated with matching - messages. This may be bigger than the number of matching - messages due to duplicates (i.e. multiple files having the - same message-id). + Read queries from a file (stdin by default), one per line, and + output the number of matching messages (or threads) to stdout, one + per line. On an empty input line the count of all messages (or + threads) in the database will be output. This option is not + compatible with specifying search terms on the command line. -``--exclude=(true|false)`` - Specify whether to omit messages matching search.exclude\_tags from - the count (the default) or not. +.. option:: --lastmod -``--batch`` - Read queries from a file (stdin by default), one per line, and - output the number of matching messages (or threads) to stdout, one - per line. On an empty input line the count of all messages (or - threads) in the database will be output. This option is not - compatible with specifying search terms on the command line. + Append lastmod (counter for number of database updates) and UUID + to the output. lastmod values are only comparable between + databases with the same UUID. -``--lastmod`` - Append lastmod (counter for number of database updates) and UUID - to the output. lastmod values are only comparable between - databases with the same UUID. +.. option:: --input= -``--input=``\ - Read input from given file, instead of from stdin. Implies - ``--batch``. + Read input from given file, instead of from stdin. Implies + ``--batch``. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-dump.rst b/doc/man1/notmuch-dump.rst index ec6335b2..4319c5c3 100644 --- a/doc/man1/notmuch-dump.rst +++ b/doc/man1/notmuch-dump.rst @@ -1,3 +1,5 @@ +.. _notmuch-dump(1): + ============ notmuch-dump ============ @@ -19,97 +21,103 @@ recreated from the messages themselves. The output of notmuch dump is therefore the only critical thing to backup (and much more friendly to incremental backup than the native database files.) -See **notmuch-search-terms(7)** for details of the supported syntax +See :any:`notmuch-search-terms(7)` for details of the supported syntax for . With no search terms, a dump of all messages in the database will be generated. A ``--`` argument instructs notmuch that the remaining arguments are search terms. Supported options for **dump** include -``--gzip`` - Compress the output in a format compatible with **gzip(1)**. - -``--format=(sup|batch-tag)`` - Notmuch restore supports two plain text dump formats, both with - one message-id per line, followed by a list of tags. - - **batch-tag** - The default **batch-tag** dump format is intended to more - robust against malformed message-ids and tags containing - whitespace or non-\ **ascii(7)** characters. Each line has the - form:: - - +<*encoded-tag*\ > +<*encoded-tag*\ > ... -- id:<*quoted-message-id*\ > - - Tags are hex-encoded by replacing every byte not matching the - regex **[A-Za-z0-9@=.,\_+-]** with **%nn** where nn is the two - digit hex encoding. The message ID is a valid Xapian query, - quoted using Xapian boolean term quoting rules: if the ID - contains whitespace or a close paren or starts with a double - quote, it must be enclosed in double quotes and double quotes - inside the ID must be doubled. The astute reader will notice - this is a special case of the batch input format for - **notmuch-tag(1)**; note that the single message-id query is - mandatory for **notmuch-restore(1)**. - - **sup** - The **sup** dump file format is specifically chosen to be - compatible with the format of files produced by sup-dump. So - if you've previously been using sup for mail, then the - **notmuch restore** command provides you a way to import all - of your tags (or labels as sup calls them). Each line has the - following form:: - - <*message-id*\ > **(** <*tag*\ > ... **)** - - with zero or more tags are separated by spaces. Note that - (malformed) message-ids may contain arbitrary non-null - characters. Note also that tags with spaces will not be - correctly restored with this format. - -``--include=(config|properties|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 separated key-value - pair. Both key and value are hex encoded if needed. - - **properties** - Output per-message (key,value) metadata. Each line starts - with "#= ", followed by a message id, and a space separated - list of key=value pairs. Ids, keys and values are hex encoded - if needed. See **notmuch-properties(7)** for more details. - - **tags** - Output per-message boolean metadata, namely tags. See *format* above - for description of the output. - - The default is to include all available types of data. The option - can be specified multiple times to select some subset. As of - version 3 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. +.. program:: dump + +.. option:: --gzip + + Compress the output in a format compatible with :manpage:`gzip(1)`. + +.. option:: --format=(sup|batch-tag) + + Notmuch restore supports two plain text dump formats, both with + one message-id per line, followed by a list of tags. + + **batch-tag** + The default **batch-tag** dump format is intended to more + robust against malformed message-ids and tags containing + whitespace or non-\ :manpage:`ascii(7)` characters. Each line + has the form:: + + +<*encoded-tag*\ > +<*encoded-tag*\ > ... -- id:<*quoted-message-id*\ > + + Tags are hex-encoded by replacing every byte not matching the + regex **[A-Za-z0-9@=.,\_+-]** with **%nn** where nn is the two + digit hex encoding. The message ID is a valid Xapian query, + quoted using Xapian boolean term quoting rules: if the ID + contains whitespace or a close paren or starts with a double + quote, it must be enclosed in double quotes and double quotes + inside the ID must be doubled. The astute reader will notice + this is a special case of the batch input format for + :any:`notmuch-tag(1)`; note that the single message-id query is + mandatory for :any:`notmuch-restore(1)`. + + **sup** + The **sup** dump file format is specifically chosen to be + compatible with the format of files produced by + :manpage:`sup-dump(1)`. So if you've previously been using sup + for mail, then the :any:`notmuch-restore(1)` command provides + you a way to import all of your tags (or labels as sup calls + them). Each line has the following form:: + + <*message-id*\ > **(** <*tag*\ > ... **)** + + with zero or more tags are separated by spaces. Note that + (malformed) message-ids may contain arbitrary non-null + characters. Note also that tags with spaces will not be + correctly restored with this format. + +.. option:: --include=(config|properties|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 separated key-value + pair. Both key and value are hex encoded if needed. + + **properties** + Output per-message (key,value) metadata. Each line starts + with "#= ", followed by a message id, and a space separated + list of key=value pairs. Ids, keys and values are hex encoded + if needed. See :any:`notmuch-properties(7)` for more details. + + **tags** + Output per-message boolean metadata, namely tags. See *format* above + for description of the output. + + The default is to include all available types of data. The option + can be specified multiple times to select some subset. As of + version 3 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. + +.. option:: --output= + + Write output to given file instead of stdout. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-properties(7)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-properties(7)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst index a0476136..d8af08bd 100644 --- a/doc/man1/notmuch-emacs-mua.rst +++ b/doc/man1/notmuch-emacs-mua.rst @@ -1,3 +1,5 @@ +.. _notmuch-emacs-mua(1): + ================= notmuch-emacs-mua ================= @@ -15,67 +17,86 @@ subject, recipients, and message body, or mailto: URL. Supported options for **emacs-mua** include -``-h, --help`` - Display help. +.. program:: emacs-mua + +.. option:: -h, --help + + Display help. + +.. option:: -s, --subject= + + Specify the subject of the message. + +.. option:: --to= + + Specify a recipient (To). + +.. option:: -c, --cc= -``-s, --subject=``\ - Specify the subject of the message. + Specify a carbon-copy (Cc) recipient. -``--to=``\ - Specify a recipient (To). +.. option:: -b, --bcc= -``-c, --cc=``\ - Specify a carbon-copy (Cc) recipient. + Specify a blind-carbon-copy (Bcc) recipient. -``-b, --bcc=``\ - Specify a blind-carbon-copy (Bcc) recipient. +.. option:: -i, --body= -``-i, --body=``\ - Specify a file to include into the body of the message. + Specify a file to include into the body of the message. -``--hello`` - Go to the Notmuch hello screen instead of the message composition - window if no message composition parameters are given. +.. option:: --hello -``--no-window-system`` - Even if a window system is available, use the current terminal. + Go to the Notmuch hello screen instead of the message composition + window if no message composition parameters are given. -``--client`` - Use **emacsclient**, rather than **emacs**. For **emacsclient** to - work, you need an already running Emacs with a server, or use - ``--auto-daemon``. +.. option:: --no-window-system -``--auto-daemon`` - Automatically start Emacs in daemon mode, if the Emacs server is - not running. Applicable with ``--client``. Implies - ``--create-frame``. + Even if a window system is available, use the current terminal. -``--create-frame`` - Create a new frame instead of trying to use the current Emacs - frame. Applicable with ``--client``. This will be required when - Emacs is running (or automatically started with ``--auto-daemon``) - in daemon mode. +.. option:: --client -``--print`` - Output the resulting elisp to stdout instead of evaluating it. + Use :manpage:`emacsclient(1)`, rather than + :manpage:`emacs(1)`. For :manpage:`emacsclient(1)` to work, you + need an already running Emacs with a server, or use + ``--auto-daemon``. + +.. option:: --auto-daemon + + Automatically start Emacs in daemon mode, if the Emacs server is + not running. Applicable with ``--client``. Implies + ``--create-frame``. + +.. option:: --create-frame + + Create a new frame instead of trying to use the current Emacs + frame. Applicable with ``--client``. This will be required when + Emacs is running (or automatically started with ``--auto-daemon``) + in daemon mode. + +.. option:: --print + + Output the resulting elisp to stdout instead of evaluating it. The supported positional parameters and short options are a compatible -subset of the **mutt** MUA command-line options. The options and -positional parameters modifying the message can't be combined with the -mailto: URL. +subset of the :manpage:`mutt(1)` MUA command-line options. The options +and positional parameters modifying the message can't be combined with +the mailto: URL. Options may be specified multiple times. ENVIRONMENT VARIABLES ===================== -**EMACS** - Name of emacs command to invoke. Defaults to "emacs". +.. envvar:: EMACS + + Name of emacs command to invoke. Defaults to "emacs". + +.. envvar:: EMACSCLIENT -**EMACSCLIENT** - Name of emacsclient command to invoke. Defaults to "emacsclient". + Name of emacsclient command to invoke. Defaults to "emacsclient". SEE ALSO ======== -**notmuch(1)**, **emacsclient(1)**, **mutt(1)** +:any:`notmuch(1)`, +:manpage:`emacsclient(1)`, +:manpage:`mutt(1)` diff --git a/doc/man1/notmuch-insert.rst b/doc/man1/notmuch-insert.rst index 86e2f567..82c4a7a0 100644 --- a/doc/man1/notmuch-insert.rst +++ b/doc/man1/notmuch-insert.rst @@ -1,3 +1,5 @@ +.. _notmuch-insert(1): + ============== notmuch-insert ============== @@ -14,7 +16,7 @@ DESCRIPTION into the maildir directory given by configuration option **database.path**, then incorporates the message into the notmuch database. It is an alternative to using a separate tool to deliver the -message then running **notmuch new** afterwards. +message then running :any:`notmuch-new(1)` afterwards. The new message will be tagged with the tags specified by the **new.tags** configuration option, then by operations specified on the @@ -25,58 +27,66 @@ If the new message is a duplicate of an existing message in the database (it has same Message-ID), it will be added to the maildir folder and notmuch database, but the tags will not be changed. -The **insert** command supports hooks. See **notmuch-hooks(5)** for +The **insert** command supports hooks. See :any:`notmuch-hooks(5)` for more details on hooks. Option arguments must appear before any tag operation arguments. Supported options for **insert** include -``--folder=<``\ folder\ **>** - Deliver the message to the specified folder, relative to the - top-level directory given by the value of **database.path**. The - default is the empty string, which means delivering to the - top-level directory. - -``--create-folder`` - Try to create the folder named by the ``--folder`` option, if it - does not exist. Otherwise the folder must already exist for mail - delivery to succeed. - -``--keep`` - Keep the message file if indexing fails, and keep the message - indexed if applying tags or maildir flag synchronization - fails. Ignore these errors and return exit status 0 to indicate - successful mail delivery. - -``--no-hooks`` - Prevent hooks from being run. - -``--world-readable`` - When writing mail to the mailbox, allow it to be read by users - other than the current user. Note that this does not override - umask. By default, delivered mail is only readable by the current - user. - -``--decrypt=(true|nostash|auto|false)`` - If ``true`` and the message is encrypted, try to decrypt the - message while indexing, stashing any session keys discovered. If - ``auto``, and notmuch already knows about a session key for the - message, it will try decrypting using that session key but will - not try to access the user's secret keys. If decryption is - successful, index the cleartext itself. Either way, the message - is always stored to disk in its original form (ciphertext). - - ``nostash`` is the same as ``true`` except that it will not stash - newly-discovered session keys in the database. - - Be aware that the index is likely sufficient (and a stashed - session key is certainly sufficient) to reconstruct the cleartext - of the message itself, so please ensure that the notmuch message - index is adequately protected. DO NOT USE ``--decrypt=true`` or - ``--decrypt=nostash`` without considering the security of your - index. - - See also ``index.decrypt`` in **notmuch-config(1)**. +.. program:: insert + +.. option:: --folder= + + Deliver the message to the specified folder, relative to the + top-level directory given by the value of **database.path**. The + default is the empty string, which means delivering to the + top-level directory. + +.. option:: --create-folder + + Try to create the folder named by the ``--folder`` option, if it + does not exist. Otherwise the folder must already exist for mail + delivery to succeed. + +.. option:: --keep + + Keep the message file if indexing fails, and keep the message + indexed if applying tags or maildir flag synchronization + fails. Ignore these errors and return exit status 0 to indicate + successful mail delivery. + +.. option:: --no-hooks + + Prevent hooks from being run. + +.. option:: --world-readable + + When writing mail to the mailbox, allow it to be read by users + other than the current user. Note that this does not override + umask. By default, delivered mail is only readable by the current + user. + +.. option:: --decrypt=(true|nostash|auto|false) + + If ``true`` and the message is encrypted, try to decrypt the + message while indexing, stashing any session keys discovered. If + ``auto``, and notmuch already knows about a session key for the + message, it will try decrypting using that session key but will + not try to access the user's secret keys. If decryption is + successful, index the cleartext itself. Either way, the message + is always stored to disk in its original form (ciphertext). + + ``nostash`` is the same as ``true`` except that it will not stash + newly-discovered session keys in the database. + + Be aware that the index is likely sufficient (and a stashed + session key is certainly sufficient) to reconstruct the cleartext + of the message itself, so please ensure that the notmuch message + index is adequately protected. DO NOT USE ``--decrypt=true`` or + ``--decrypt=nostash`` without considering the security of your + index. + + See also ``index.decrypt`` in :any:`notmuch-config(1)`. EXIT STATUS =========== @@ -101,14 +111,14 @@ status of the **insert** command. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst index 20a1103b..9cb4a54e 100644 --- a/doc/man1/notmuch-new.rst +++ b/doc/man1/notmuch-new.rst @@ -1,3 +1,5 @@ +.. _notmuch-new(1): + =========== notmuch-new =========== @@ -17,56 +19,64 @@ performing full-text indexing on new messages that are found. Each new message will automatically be tagged with both the **inbox** and **unread** tags. -You should run **notmuch new** once after first running **notmuch -setup** to create the initial database. The first run may take a long -time if you have a significant amount of mail (several hundred thousand -messages or more). Subsequently, you should run **notmuch new** whenever -new mail is delivered and you wish to incorporate it into the database. -These subsequent runs will be much quicker than the initial run. +You should run **notmuch new** once after first running +:any:`notmuch-setup(1)` to create the initial database. The first run +may take a long time if you have a significant amount of mail (several +hundred thousand messages or more). Subsequently, you should run +**notmuch new** whenever new mail is delivered and you wish to +incorporate it into the database. These subsequent runs will be much +quicker than the initial run. Invoking ``notmuch`` with no command argument will run **new** if -**notmuch setup** has previously been completed, but **notmuch new** has -not previously been run. +:any:`notmuch-setup(1)` has previously been completed, but **notmuch +new** has not previously been run. **notmuch new** updates tags according to maildir flag changes if the **maildir.synchronize\_flags** configuration option is enabled. See -**notmuch-config(1)** for details. +:any:`notmuch-config(1)` for details. -The **new** command supports hooks. See **notmuch-hooks(5)** for more +The **new** command supports hooks. See :any:`notmuch-hooks(5)` for more details on hooks. Supported options for **new** include -``--no-hooks`` - Prevents hooks from being run. +.. program:: new + +.. option:: --no-hooks + + Prevents hooks from being run. + +.. option:: --quiet + + Do not print progress or results. + +.. option:: --verbose + + Print file names being processed. Ignored when combined with + ``--quiet``. -``--quiet`` - Do not print progress or results. +.. option:: --decrypt=(true|nostash|auto|false) -``--verbose`` - Print file names being processed. Ignored when combined with - ``--quiet``. + If ``true``, when encountering an encrypted message, try to + decrypt it while indexing, and stash any discovered session keys. + If ``auto``, try to use any session key already known to belong to + this message, but do not attempt to use the user's secret keys. + If decryption is successful, index the cleartext of the message. -``--decrypt=(true|nostash|auto|false)`` - If ``true``, when encountering an encrypted message, try to - decrypt it while indexing, and stash any discovered session keys. - If ``auto``, try to use any session key already known to belong to - this message, but do not attempt to use the user's secret keys. - If decryption is successful, index the cleartext of the message. + Be aware that the index is likely sufficient (and the session key + is certainly sufficient) to reconstruct the cleartext of the + message itself, so please ensure that the notmuch message index is + adequately protected. DO NOT USE ``--decrypt=true`` or + ``--decrypt=nostash`` without considering the security of your + index. - Be aware that the index is likely sufficient (and the session key - is certainly sufficient) to reconstruct the cleartext of the - message itself, so please ensure that the notmuch message index is - adequately protected. DO NOT USE ``--decrypt=true`` or - ``--decrypt=nostash`` without considering the security of your - index. + See also ``index.decrypt`` in :any:`notmuch-config(1)`. - See also ``index.decrypt`` in **notmuch-config(1)**. +.. option:: --full-scan -``--full-scan`` - By default notmuch-new uses directory modification times (mtimes) - to optimize the scanning of directories for new mail. This option turns - that optimization off. + By default notmuch-new uses directory modification times (mtimes) + to optimize the scanning of directories for new mail. This option turns + that optimization off. EXIT STATUS =========== @@ -79,15 +89,15 @@ This command supports the following special exit status code SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-reindex.rst b/doc/man1/notmuch-reindex.rst index cd7c91a0..85dad249 100644 --- a/doc/man1/notmuch-reindex.rst +++ b/doc/man1/notmuch-reindex.rst @@ -1,3 +1,5 @@ +.. _notmuch-reindex(1): + =============== notmuch-reindex =============== @@ -12,7 +14,7 @@ DESCRIPTION Re-index all messages matching the search terms. -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for <*search-term*\ >. The **reindex** command searches for all messages matching the @@ -21,28 +23,31 @@ messages using the supplied options. Supported options for **reindex** include -``--decrypt=(true|nostash|auto|false)`` - If ``true``, when encountering an encrypted message, try to - decrypt it while reindexing, stashing any session keys discovered. - If ``auto``, and notmuch already knows about a session key for the - message, it will try decrypting using that session key but will - not try to access the user's secret keys. If decryption is - successful, index the cleartext itself. +.. program:: reindex + +.. option:: --decrypt=(true|nostash|auto|false) + + If ``true``, when encountering an encrypted message, try to + decrypt it while reindexing, stashing any session keys discovered. + If ``auto``, and notmuch already knows about a session key for the + message, it will try decrypting using that session key but will + not try to access the user's secret keys. If decryption is + successful, index the cleartext itself. - ``nostash`` is the same as ``true`` except that it will not stash - newly-discovered session keys in the database. + ``nostash`` is the same as ``true`` except that it will not stash + newly-discovered session keys in the database. - If ``false``, notmuch reindex will also delete any stashed session - keys for all messages matching the search terms. + If ``false``, notmuch reindex will also delete any stashed session + keys for all messages matching the search terms. - Be aware that the index is likely sufficient (and a stashed - session key is certainly sufficient) to reconstruct the cleartext - of the message itself, so please ensure that the notmuch message - index is adequately protected. DO NOT USE ``--decrypt=true`` or - ``--decrypt=nostash`` without considering the security of your - index. + Be aware that the index is likely sufficient (and a stashed + session key is certainly sufficient) to reconstruct the cleartext + of the message itself, so please ensure that the notmuch message + index is adequately protected. DO NOT USE ``--decrypt=true`` or + ``--decrypt=nostash`` without considering the security of your + index. - See also ``index.decrypt`` in **notmuch-config(1)**. + See also ``index.decrypt`` in :any:`notmuch-config(1)`. EXAMPLES ======== @@ -84,17 +89,17 @@ https://trac.xapian.org/ticket/742: SEE ALSO ======== -**notmuch(1)**, -**notmuch-compact(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-compact(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-reply.rst b/doc/man1/notmuch-reply.rst index 5c64c4a6..4a78a90b 100644 --- a/doc/man1/notmuch-reply.rst +++ b/doc/man1/notmuch-reply.rst @@ -1,3 +1,5 @@ +.. _notmuch-reply(1): + ============= notmuch-reply ============= @@ -34,64 +36,69 @@ The resulting message template is output to stdout. Supported options for **reply** include -``--format=``\ (**default**\ \|\ **json**\ \|\ **sexp**\ \|\ **headers-only**) - **default** - Includes subject and quoted message body as an RFC 2822 - message. +.. program:: reply + +.. option:: --format=(default|json|sexp|headers-only) + + **default** + Includes subject and quoted message body as an RFC 2822 + message. + + **json** + Produces JSON output containing headers for a reply message + and the contents of the original message. This output can be + used by a client to create a reply message intelligently. + + **sexp** + Produces S-Expression output containing headers for a reply + message and the contents of the original message. This output + can be used by a client to create a reply message + intelligently. - **json** - Produces JSON output containing headers for a reply message - and the contents of the original message. This output can be - used by a client to create a reply message intelligently. + **headers-only** + Only produces In-Reply-To, References, To, Cc, and Bcc + headers. - **sexp** - Produces S-Expression output containing headers for a reply - message and the contents of the original message. This output - can be used by a client to create a reply message - intelligently. +.. option:: --format-version=N - **headers-only** - Only produces In-Reply-To, References, To, Cc, and Bcc - headers. + Use the specified structured output format version. This is + intended for programs that invoke :any:`notmuch(1)` internally. If + omitted, the latest supported version will be used. -``--format-version=N`` - Use the specified structured output format version. This is - intended for programs that invoke **notmuch(1)** internally. If - omitted, the latest supported version will be used. +.. option:: --reply-to=(all|sender) -``--reply-to=``\ (**all**\ \|\ **sender**) - **all** (default) - Replies to all addresses. + **all** (default) + Replies to all addresses. - **sender** - Replies only to the sender. If replying to user's own message - (Reply-to: or From: header is one of the user's configured - email addresses), try To:, Cc:, and Bcc: headers in this - order, and copy values from the first that contains something - other than only the user's addresses. + **sender** + Replies only to the sender. If replying to user's own message + (Reply-to: or From: header is one of the user's configured + email addresses), try To:, Cc:, and Bcc: headers in this + order, and copy values from the first that contains something + other than only the user's addresses. -``--decrypt=(false|auto|true)`` +.. option:: --decrypt=(false|auto|true) - If ``true``, decrypt any MIME encrypted parts found in the - selected content (i.e., "multipart/encrypted" parts). Status - of the decryption will be reported (currently only supported - with ``--format=json`` and ``--format=sexp``), and on successful - decryption the multipart/encrypted part will be replaced by - the decrypted content. + If ``true``, decrypt any MIME encrypted parts found in the + selected content (i.e., "multipart/encrypted" parts). Status + of the decryption will be reported (currently only supported + with ``--format=json`` and ``--format=sexp``), and on successful + decryption the multipart/encrypted part will be replaced by + the decrypted content. - If ``auto``, and a session key is already known for the - message, then it will be decrypted, but notmuch will not try - to access the user's secret keys. + If ``auto``, and a session key is already known for the + message, then it will be decrypted, but notmuch will not try + to access the user's secret keys. - Use ``false`` to avoid even automatic decryption. + Use ``false`` to avoid even automatic decryption. - Non-automatic decryption expects a functioning - **gpg-agent(1)** to provide any needed credentials. Without - one, the decryption will likely fail. + Non-automatic decryption expects a functioning + :manpage:`gpg-agent(1)` to provide any needed credentials. Without + one, the decryption will likely fail. - Default: ``auto`` + Default: ``auto`` -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for . Note: It is most common to use **notmuch reply** with a search string @@ -116,15 +123,15 @@ This command supports the following special exit status codes SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-restore.rst b/doc/man1/notmuch-restore.rst index c0f47f26..bd452475 100644 --- a/doc/man1/notmuch-restore.rst +++ b/doc/man1/notmuch-restore.rst @@ -1,3 +1,5 @@ +.. _notmuch-restore(1): + =============== notmuch-restore =============== @@ -10,90 +12,96 @@ SYNOPSIS DESCRIPTION =========== -Restores the tags from the given file (see **notmuch dump**). +Restores the tags from the given file (see :any:`notmuch-dump(1)`). The input is read from the given filename, if any, or from stdin. Supported options for **restore** include -``--accumulate`` - The union of the existing and new tags is applied, instead of - replacing each message's tags as they are read in from the dump - file. - -``--format=(sup|batch-tag|auto)`` - Notmuch restore supports two plain text dump formats, with each - line specifying a message-id and a set of tags. For details of the - actual formats, see **notmuch-dump(1)**. - - **sup** - The **sup** dump file format is specifically chosen to be - compatible with the format of files produced by sup-dump. So - if you've previously been using sup for mail, then the - **notmuch restore** command provides you a way to import all - of your tags (or labels as sup calls them). - - **batch-tag** - The **batch-tag** dump format is intended to more robust - against malformed message-ids and tags containing whitespace - or non-\ **ascii(7)** characters. See **notmuch-dump(1)** for - details on this format. - - **notmuch restore** updates the maildir flags according to tag - changes if the **maildir.synchronize\_flags** configuration - option is enabled. See **notmuch-config(1)** for details. - - **auto** - This option (the default) tries to guess the format from the - input. For correctly formed input in either supported format, - this heuristic, based the fact that batch-tag format contains - no parentheses, should be accurate. - -``--include=(config|properties|tags)`` - Control what kind of metadata is restored. - - **config** - Restore configuration data to the database. Each configuration - line starts with "#@ ", followed by a space separated - key-value pair. Both key and value are hex encoded if needed. - - **properties** - Restore per-message (key,value) metadata. Each line starts - with "#= ", followed by a message id, and a space separated - list of key=value pairs. Ids, keys and values are hex encoded - if needed. See **notmuch-properties(7)** for more details. - - **tags** - Restore per-message metadata, namely tags. See *format* above - for more details. - - The default is to restore all available types of data. The option - can be specified multiple times to select some subset. - -``--input=``\ - Read input from given file instead of stdin. +.. program:: restore + +.. option:: --accumulate + + The union of the existing and new tags is applied, instead of + replacing each message's tags as they are read in from the dump + file. + +.. option:: --format=(sup|batch-tag|auto) + + Notmuch restore supports two plain text dump formats, with each + line specifying a message-id and a set of tags. For details of the + actual formats, see :any:`notmuch-dump(1)`. + + **sup** + The **sup** dump file format is specifically chosen to be + compatible with the format of files produced by sup-dump. So + if you've previously been using sup for mail, then the + **notmuch restore** command provides you a way to import all + of your tags (or labels as sup calls them). + + **batch-tag** + The **batch-tag** dump format is intended to more robust + against malformed message-ids and tags containing whitespace + or non-\ **ascii(7)** characters. See :any:`notmuch-dump(1)` for + details on this format. + + **notmuch restore** updates the maildir flags according to tag + changes if the **maildir.synchronize\_flags** configuration + option is enabled. See :any:`notmuch-config(1)` for details. + + **auto** + This option (the default) tries to guess the format from the + input. For correctly formed input in either supported format, + this heuristic, based the fact that batch-tag format contains + no parentheses, should be accurate. + +.. option:: --include=(config|properties|tags) + + Control what kind of metadata is restored. + + **config** + Restore configuration data to the database. Each configuration + line starts with "#@ ", followed by a space separated + key-value pair. Both key and value are hex encoded if needed. + + **properties** + Restore per-message (key,value) metadata. Each line starts + with "#= ", followed by a message id, and a space separated + list of key=value pairs. Ids, keys and values are hex encoded + if needed. See :any:`notmuch-properties(7)` for more details. + + **tags** + Restore per-message metadata, namely tags. See *format* above + for more details. + + The default is to restore all available types of data. The option + can be specified multiple times to select some subset. + +.. option:: --input= + + Read input from given file instead of stdin. GZIPPED INPUT ============= \ **notmuch restore** will detect if the input is compressed in -**gzip(1)** format and automatically decompress it while reading. This -detection does not depend on file naming and in particular works for -standard input. +:manpage:`gzip(1)` format and automatically decompress it while +reading. This detection does not depend on file naming and in +particular works for standard input. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-properties(7)**, -**notmuch-reply(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-properties(7)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst index ed9ff4e5..2d9ca2d5 100644 --- a/doc/man1/notmuch-search.rst +++ b/doc/man1/notmuch-search.rst @@ -1,3 +1,5 @@ +.. _notmuch-search(1): + ============== notmuch-search ============== @@ -19,123 +21,133 @@ in the thread, the number of matched messages and total messages in the thread, the names of all participants in the thread, and the subject of the newest (or oldest) message. -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for . Supported options for **search** include -``--format=``\ (**json**\ \|\ **sexp**\ \|\ **text**\ \|\ **text0**) - Presents the results in either JSON, S-Expressions, newline - character separated plain-text (default), or null character - separated plain-text (compatible with **xargs(1)** -0 option where - available). - -``--format-version=N`` - Use the specified structured output format version. This is - intended for programs that invoke **notmuch(1)** internally. If - omitted, the latest supported version will be used. - -``--output=(summary|threads|messages|files|tags)`` - **summary** - Output a summary of each thread with any message matching the - search terms. The summary includes the thread ID, date, the - number of messages in the thread (both the number matched and - the total number), the authors of the thread and the - subject. In the case where a thread contains multiple files - for some messages, the total number of files is printed in - parentheses (see below for an example). - - **threads** - Output the thread IDs of all threads with any message matching - the search terms, either one per line (``--format=text``), - separated by null characters (``--format=text0``), as a JSON array - (``--format=json``), or an S-Expression list (``--format=sexp``). - - **messages** - Output the message IDs of all messages matching the search - terms, either one per line (``--format=text``), separated by null - characters (``--format=text0``), as a JSON array (``--format=json``), - or as an S-Expression list (``--format=sexp``). - - **files** - Output the filenames of all messages matching the search - terms, either one per line (``--format=text``), separated by null - characters (``--format=text0``), as a JSON array (``--format=json``), - or as an S-Expression list (``--format=sexp``). - - Note that each message may have multiple filenames associated - with it. All of them are included in the output (unless - limited with the ``--duplicate=N`` option). This may be - particularly confusing for **folder:** or **path:** searches - in a specified directory, as the messages may have duplicates - in other directories that are included in the output, although - these files alone would not match the search. - - **tags** - Output all tags that appear on any message matching the search - terms, either one per line (``--format=text``), separated by null - characters (``--format=text0``), as a JSON array (``--format=json``), - or as an S-Expression list (``--format=sexp``). - -``--sort=``\ (**newest-first**\ \|\ **oldest-first**) - This option can be used to present results in either chronological - order (**oldest-first**) or reverse chronological order - (**newest-first**). - - Note: The thread order will be distinct between these two options - (beyond being simply reversed). When sorting by **oldest-first** - the threads will be sorted by the oldest message in each thread, - but when sorting by **newest-first** the threads will be sorted by - the newest message in each thread. - - By default, results will be displayed in reverse chronological - order, (that is, the newest results will be displayed first). - -``--offset=[-]N`` - Skip displaying the first N results. With the leading '-', start - at the Nth result from the end. - -``--limit=N`` - Limit the number of displayed results to N. - -``--exclude=(true|false|all|flag)`` - A message is called "excluded" if it matches at least one tag in - search.exclude\_tags that does not appear explicitly in the search - terms. This option specifies whether to omit excluded messages in - the search process. - - **true** (default) - Prevent excluded messages from matching the search terms. - - **all** - Additionally prevent excluded messages from appearing in - displayed results, in effect behaving as though the excluded - messages do not exist. - - **false** - Allow excluded messages to match search terms and appear in - displayed results. Excluded messages are still marked in the - relevant outputs. - - **flag** - Only has an effect when ``--output=summary``. The output is - almost identical to **false**, but the "match count" is the - number of matching non-excluded messages in the thread, rather - than the number of matching messages. - -``--duplicate=N`` - For ``--output=files``, output the Nth filename associated with - each message matching the query (N is 1-based). If N is greater - than the number of files associated with the message, don't print - anything. - - For ``--output=messages``, only output message IDs of messages - matching the search terms that have at least N filenames - associated with them. - - Note that this option is orthogonal with the **folder:** search - prefix. The prefix matches messages based on filenames. This - option filters filenames of the matching messages. +.. program:: search + +.. option:: --format=(json|sexp|text|text0) + + Presents the results in either JSON, S-Expressions, newline + character separated plain-text (default), or null character + separated plain-text (compatible with :manpage:`xargs(1)` -0 + option where available). + +.. option:: --format-version=N + + Use the specified structured output format version. This is + intended for programs that invoke :any:`notmuch(1)` internally. If + omitted, the latest supported version will be used. + +.. option:: --output=(summary|threads|messages|files|tags) + + **summary** + Output a summary of each thread with any message matching the + search terms. The summary includes the thread ID, date, the + number of messages in the thread (both the number matched and + the total number), the authors of the thread and the + subject. In the case where a thread contains multiple files + for some messages, the total number of files is printed in + parentheses (see below for an example). + + **threads** + Output the thread IDs of all threads with any message matching + the search terms, either one per line (``--format=text``), + separated by null characters (``--format=text0``), as a JSON array + (``--format=json``), or an S-Expression list (``--format=sexp``). + + **messages** + Output the message IDs of all messages matching the search + terms, either one per line (``--format=text``), separated by null + characters (``--format=text0``), as a JSON array (``--format=json``), + or as an S-Expression list (``--format=sexp``). + + **files** + Output the filenames of all messages matching the search + terms, either one per line (``--format=text``), separated by null + characters (``--format=text0``), as a JSON array (``--format=json``), + or as an S-Expression list (``--format=sexp``). + + Note that each message may have multiple filenames associated + with it. All of them are included in the output (unless + limited with the ``--duplicate=N`` option). This may be + particularly confusing for **folder:** or **path:** searches + in a specified directory, as the messages may have duplicates + in other directories that are included in the output, although + these files alone would not match the search. + + **tags** + Output all tags that appear on any message matching the search + terms, either one per line (``--format=text``), separated by null + characters (``--format=text0``), as a JSON array (``--format=json``), + or as an S-Expression list (``--format=sexp``). + +.. option:: --sort=(newest-first|oldest-first) + + This option can be used to present results in either chronological + order (**oldest-first**) or reverse chronological order + (**newest-first**). + + Note: The thread order will be distinct between these two options + (beyond being simply reversed). When sorting by **oldest-first** + the threads will be sorted by the oldest message in each thread, + but when sorting by **newest-first** the threads will be sorted by + the newest message in each thread. + + By default, results will be displayed in reverse chronological + order, (that is, the newest results will be displayed first). + +.. option:: --offset=[-]N + + Skip displaying the first N results. With the leading '-', start + at the Nth result from the end. + +.. option:: --limit=N + + Limit the number of displayed results to N. + +.. option:: --exclude=(true|false|all|flag) + + A message is called "excluded" if it matches at least one tag in + search.exclude\_tags that does not appear explicitly in the search + terms. This option specifies whether to omit excluded messages in + the search process. + + **true** (default) + Prevent excluded messages from matching the search terms. + + **all** + Additionally prevent excluded messages from appearing in + displayed results, in effect behaving as though the excluded + messages do not exist. + + **false** + Allow excluded messages to match search terms and appear in + displayed results. Excluded messages are still marked in the + relevant outputs. + + **flag** + Only has an effect when ``--output=summary``. The output is + almost identical to **false**, but the "match count" is the + number of matching non-excluded messages in the thread, rather + than the number of matching messages. + +.. option:: --duplicate=N + + For ``--output=files``, output the Nth filename associated with + each message matching the query (N is 1-based). If N is greater + than the number of files associated with the message, don't print + anything. + + For ``--output=messages``, only output message IDs of messages + matching the search terms that have at least N filenames + associated with them. + + Note that this option is orthogonal with the **folder:** search + prefix. The prefix matches messages based on filenames. This + option filters filenames of the matching messages. EXAMPLE ======= @@ -164,16 +176,16 @@ This command supports the following special exit status codes SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** -**notmuch-address(1)** +:any:`notmuch(1)`, +:any:`notmuch-address(1)` +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst index becd3e79..fc6bec62 100644 --- a/doc/man1/notmuch-show.rst +++ b/doc/man1/notmuch-show.rst @@ -1,3 +1,5 @@ +.. _notmuch-show(1): + ============ notmuch-show ============ @@ -12,7 +14,7 @@ DESCRIPTION Shows all messages matching the search terms. -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for . The messages will be grouped and sorted based on the threading (all @@ -23,176 +25,188 @@ post-processor (such as the emacs interface to notmuch). Supported options for **show** include -``--entire-thread=(true|false)`` - If true, **notmuch show** outputs all messages in the thread of - any message matching the search terms; if false, it outputs only - the matching messages. For ``--format=json`` and ``--format=sexp`` - this defaults to true. For other formats, this defaults to false. - -``--format=(text|json|sexp|mbox|raw)`` - **text** (default for messages) - The default plain-text format has all text-content MIME parts - decoded. Various components in the output, (**message**, - **header**, **body**, **attachment**, and MIME **part**), will - be delimited by easily-parsed markers. Each marker consists of - a Control-L character (ASCII decimal 12), the name of the - marker, and then either an opening or closing brace, ('{' or - '}'), to either open or close the component. For a multipart - MIME message, these parts will be nested. - - **json** - The output is formatted with Javascript Object Notation - (JSON). This format is more robust than the text format for - automated processing. The nested structure of multipart MIME - messages is reflected in nested JSON output. By default JSON - output includes all messages in a matching thread; that is, by - default, ``--format=json`` sets ``--entire-thread``. The - caller can disable this behaviour by setting - ``--entire-thread=false``. The JSON output is always encoded - as UTF-8 and any message content included in the output will - be charset-converted to UTF-8. - - **sexp** - The output is formatted as the Lisp s-expression (sexp) - equivalent of the JSON format above. Objects are formatted as - property lists whose keys are keywords (symbols preceded by a - colon). True is formatted as ``t`` and both false and null are - formatted as ``nil``. As for JSON, the s-expression output is - always encoded as UTF-8. - - **mbox** - All matching messages are output in the traditional, Unix mbox - format with each message being prefixed by a line beginning - with "From " and a blank line separating each message. Lines - in the message content beginning with "From " (preceded by - zero or more '>' characters) have an additional '>' character - added. This reversible escaping is termed "mboxrd" format and - described in detail here: - - http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html - - **raw** (default if ``--part`` is given) - Write the raw bytes of the given MIME part of a message to - standard out. For this format, it is an error to specify a - query that matches more than one message. - - If the specified part is a leaf part, this outputs the body of - the part after performing content transfer decoding (but no - charset conversion). This is suitable for saving attachments, - for example. - - For a multipart or message part, the output includes the part - headers as well as the body (including all child parts). No - decoding is performed because multipart and message parts - cannot have non-trivial content transfer encoding. Consumers - of this may need to implement MIME decoding and similar - functions. - -``--format-version=N`` - Use the specified structured output format version. This is - intended for programs that invoke **notmuch(1)** internally. If - omitted, the latest supported version will be used. - -``--part=N`` - Output the single decoded MIME part N of a single message. The - search terms must match only a single message. Message parts are - numbered in a depth-first walk of the message MIME structure, and - are identified in the 'json', 'sexp' or 'text' output formats. - - Note that even a message with no MIME structure or a single body - part still has two MIME parts: part 0 is the whole message - (headers and body) and part 1 is just the body. - -``--verify`` - Compute and report the validity of any MIME cryptographic - signatures found in the selected content (e.g., "multipart/signed" - parts). Status of the signature will be reported (currently only - supported with ``--format=json`` and ``--format=sexp``), and the - multipart/signed part will be replaced by the signed data. - -``--decrypt=(false|auto|true|stash)`` - If ``true``, decrypt any MIME encrypted parts found in the - selected content (e.g., "multipart/encrypted" parts). Status of - the decryption will be reported (currently only supported - with ``--format=json`` and ``--format=sexp``) and on successful - decryption the multipart/encrypted part will be replaced by - the decrypted content. - - ``stash`` behaves like ``true``, but upon successful decryption it - will also stash the message's session key in the database, and - index the cleartext of the message, enabling automatic decryption - in the future. - - If ``auto``, and a session key is already known for the - message, then it will be decrypted, but notmuch will not try - to access the user's keys. - - Use ``false`` to avoid even automatic decryption. - - Non-automatic decryption (``stash`` or ``true``, in the absence of - a stashed session key) expects a functioning **gpg-agent(1)** to - provide any needed credentials. Without one, the decryption will - fail. - - Note: setting either ``true`` or ``stash`` here implies - ``--verify``. - - Here is a table that summarizes each of these policies: - - +------------------------+-------+------+------+-------+ - | | false | auto | true | stash | - +========================+=======+======+======+=======+ - | Show cleartext if | | X | X | X | - | session key is | | | | | - | already known | | | | | - +------------------------+-------+------+------+-------+ - | Use secret keys to | | | X | X | - | show cleartext | | | | | - +------------------------+-------+------+------+-------+ - | Stash any newly | | | | X | - | recovered session keys,| | | | | - | reindexing message if | | | | | - | found | | | | | - +------------------------+-------+------+------+-------+ - - Note: ``--decrypt=stash`` requires write access to the database. - Otherwise, ``notmuch show`` operates entirely in read-only mode. - - Default: ``auto`` - -``--exclude=(true|false)`` - Specify whether to omit threads only matching search.exclude\_tags - from the search results (the default) or not. In either case the - excluded message will be marked with the exclude flag (except when - output=mbox when there is nowhere to put the flag). - - If ``--entire-thread`` is specified then complete threads are returned - regardless (with the excluded flag being set when appropriate) but - threads that only match in an excluded message are not returned - when ``--exclude=true.`` - - The default is ``--exclude=true.`` - -``--body=(true|false)`` - If true (the default) **notmuch show** includes the bodies of the - messages in the output; if false, bodies are omitted. - ``--body=false`` is only implemented for the text, json and sexp - formats and it is incompatible with ``--part > 0.`` - - This is useful if the caller only needs the headers as body-less - output is much faster and substantially smaller. - -``--include-html`` - Include "text/html" parts as part of the output (currently - only supported with ``--format=text``, ``--format=json`` and - ``--format=sexp``). By default, unless ``--part=N`` is used to - select a specific part or ``--include-html`` is used to include all - "text/html" parts, no part with content type "text/html" is included - in the output. - -A common use of **notmuch show** is to display a single thread of email -messages. For this, use a search term of "thread:" as can be -seen in the first column of output from the **notmuch search** command. +.. program:: show + +.. option:: --entire-thread=(true|false) + + If true, **notmuch show** outputs all messages in the thread of + any message matching the search terms; if false, it outputs only + the matching messages. For ``--format=json`` and ``--format=sexp`` + this defaults to true. For other formats, this defaults to false. + +.. option:: --format=(text|json|sexp|mbox|raw) + + **text** (default for messages) + The default plain-text format has all text-content MIME parts + decoded. Various components in the output, (**message**, + **header**, **body**, **attachment**, and MIME **part**), will + be delimited by easily-parsed markers. Each marker consists of + a Control-L character (ASCII decimal 12), the name of the + marker, and then either an opening or closing brace, ('{' or + '}'), to either open or close the component. For a multipart + MIME message, these parts will be nested. + + **json** + The output is formatted with Javascript Object Notation + (JSON). This format is more robust than the text format for + automated processing. The nested structure of multipart MIME + messages is reflected in nested JSON output. By default JSON + output includes all messages in a matching thread; that is, by + default, ``--format=json`` sets ``--entire-thread``. The + caller can disable this behaviour by setting + ``--entire-thread=false``. The JSON output is always encoded + as UTF-8 and any message content included in the output will + be charset-converted to UTF-8. + + **sexp** + The output is formatted as the Lisp s-expression (sexp) + equivalent of the JSON format above. Objects are formatted as + property lists whose keys are keywords (symbols preceded by a + colon). True is formatted as ``t`` and both false and null are + formatted as ``nil``. As for JSON, the s-expression output is + always encoded as UTF-8. + + **mbox** + All matching messages are output in the traditional, Unix mbox + format with each message being prefixed by a line beginning + with "From " and a blank line separating each message. Lines + in the message content beginning with "From " (preceded by + zero or more '>' characters) have an additional '>' character + added. This reversible escaping is termed "mboxrd" format and + described in detail here: + + http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html + + **raw** (default if ``--part`` is given) + Write the raw bytes of the given MIME part of a message to + standard out. For this format, it is an error to specify a + query that matches more than one message. + + If the specified part is a leaf part, this outputs the body of + the part after performing content transfer decoding (but no + charset conversion). This is suitable for saving attachments, + for example. + + For a multipart or message part, the output includes the part + headers as well as the body (including all child parts). No + decoding is performed because multipart and message parts + cannot have non-trivial content transfer encoding. Consumers + of this may need to implement MIME decoding and similar + functions. + +.. option:: --format-version=N + + Use the specified structured output format version. This is + intended for programs that invoke :any:`notmuch(1)` internally. If + omitted, the latest supported version will be used. + +.. option:: --part=N + + Output the single decoded MIME part N of a single message. The + search terms must match only a single message. Message parts are + numbered in a depth-first walk of the message MIME structure, and + are identified in the 'json', 'sexp' or 'text' output formats. + + Note that even a message with no MIME structure or a single body + part still has two MIME parts: part 0 is the whole message + (headers and body) and part 1 is just the body. + +.. option:: --verify + + Compute and report the validity of any MIME cryptographic + signatures found in the selected content (e.g., "multipart/signed" + parts). Status of the signature will be reported (currently only + supported with ``--format=json`` and ``--format=sexp``), and the + multipart/signed part will be replaced by the signed data. + +.. option:: --decrypt=(false|auto|true|stash) + + If ``true``, decrypt any MIME encrypted parts found in the + selected content (e.g., "multipart/encrypted" parts). Status of + the decryption will be reported (currently only supported + with ``--format=json`` and ``--format=sexp``) and on successful + decryption the multipart/encrypted part will be replaced by + the decrypted content. + + ``stash`` behaves like ``true``, but upon successful decryption it + will also stash the message's session key in the database, and + index the cleartext of the message, enabling automatic decryption + in the future. + + If ``auto``, and a session key is already known for the + message, then it will be decrypted, but notmuch will not try + to access the user's keys. + + Use ``false`` to avoid even automatic decryption. + + Non-automatic decryption (``stash`` or ``true``, in the absence of + a stashed session key) expects a functioning :manpage:`gpg-agent(1)` to + provide any needed credentials. Without one, the decryption will + fail. + + Note: setting either ``true`` or ``stash`` here implies + ``--verify``. + + Here is a table that summarizes each of these policies: + + +------------------------+-------+------+------+-------+ + | | false | auto | true | stash | + +========================+=======+======+======+=======+ + | Show cleartext if | | X | X | X | + | session key is | | | | | + | already known | | | | | + +------------------------+-------+------+------+-------+ + | Use secret keys to | | | X | X | + | show cleartext | | | | | + +------------------------+-------+------+------+-------+ + | Stash any newly | | | | X | + | recovered session keys,| | | | | + | reindexing message if | | | | | + | found | | | | | + +------------------------+-------+------+------+-------+ + + Note: ``--decrypt=stash`` requires write access to the database. + Otherwise, ``notmuch show`` operates entirely in read-only mode. + + Default: ``auto`` + +.. option:: --exclude=(true|false) + + Specify whether to omit threads only matching search.exclude\_tags + from the search results (the default) or not. In either case the + excluded message will be marked with the exclude flag (except when + output=mbox when there is nowhere to put the flag). + + If ``--entire-thread`` is specified then complete threads are returned + regardless (with the excluded flag being set when appropriate) but + threads that only match in an excluded message are not returned + when ``--exclude=true.`` + + The default is ``--exclude=true.`` + +.. option:: --body=(true|false) + + If true (the default) **notmuch show** includes the bodies of the + messages in the output; if false, bodies are omitted. + ``--body=false`` is only implemented for the text, json and sexp + formats and it is incompatible with ``--part > 0.`` + + This is useful if the caller only needs the headers as body-less + output is much faster and substantially smaller. + +.. option:: --include-html + + Include "text/html" parts as part of the output (currently + only supported with ``--format=text``, ``--format=json`` and + ``--format=sexp``). By default, unless ``--part=N`` is used to + select a specific part or ``--include-html`` is used to include all + "text/html" parts, no part with content type "text/html" is included + in the output. + +A common use of **notmuch show** is to display a single thread of +email messages. For this, use a search term of "thread:" as +can be seen in the first column of output from the +:any:`notmuch-search(1)` command. EXIT STATUS =========== @@ -208,15 +222,15 @@ This command supports the following special exit status codes SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-tag(1)` diff --git a/doc/man1/notmuch-tag.rst b/doc/man1/notmuch-tag.rst index c2324f5a..ae311a23 100644 --- a/doc/man1/notmuch-tag.rst +++ b/doc/man1/notmuch-tag.rst @@ -1,3 +1,5 @@ +.. _notmuch-tag(1): + =========== notmuch-tag =========== @@ -14,7 +16,7 @@ DESCRIPTION Add/remove tags for all messages matching the search terms. -See **notmuch-search-terms(7)** for details of the supported syntax for +See :any:`notmuch-search-terms(7)` for details of the supported syntax for <*search-term*\ >. Tags prefixed by '+' are added while those prefixed by '-' are removed. @@ -28,26 +30,31 @@ beginning with '+' or '-' is provided by allowing the user to specify a **notmuch tag** updates the maildir flags according to tag changes if the **maildir.synchronize\_flags** configuration option is enabled. See -**notmuch-config(1)** for details. +:any:`notmuch-config(1)` for details. Supported options for **tag** include -``--remove-all`` - Remove all tags from each message matching the search terms before - applying the tag changes appearing on the command line. This - means setting the tags of each message to the tags to be added. If - there are no tags to be added, the messages will have no tags. +.. program:: tag + +.. option:: --remove-all + + Remove all tags from each message matching the search terms before + applying the tag changes appearing on the command line. This + means setting the tags of each message to the tags to be added. If + there are no tags to be added, the messages will have no tags. + +.. option:: --batch + + Read batch tagging operations from a file (stdin by default). + This is more efficient than repeated **notmuch tag** + invocations. See `TAG FILE FORMAT <#tag_file_format>`__ below for + the input format. This option is not compatible with specifying + tagging on the command line. -``--batch`` - Read batch tagging operations from a file (stdin by default). - This is more efficient than repeated **notmuch tag** - invocations. See `TAG FILE FORMAT <#tag_file_format>`__ below for - the input format. This option is not compatible with specifying - tagging on the command line. +.. option:: --input= -``--input=``\ - Read input from given file, instead of from stdin. Implies - ``--batch``. + Read input from given file, instead of from stdin. Implies + ``--batch``. TAG FILE FORMAT =============== @@ -100,15 +107,15 @@ of the tag **space in tags** SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, diff --git a/doc/man1/notmuch.rst b/doc/man1/notmuch.rst index 48351588..e7adcfcd 100644 --- a/doc/man1/notmuch.rst +++ b/doc/man1/notmuch.rst @@ -1,3 +1,6 @@ +.. _notmuch(1): +.. _notmuch-setup(1): + ======= notmuch ======= @@ -15,8 +18,9 @@ reading, and tagging large collections of email messages. This page describes how to get started using notmuch from the command line, and gives a brief overview of the commands available. For more -information on e.g. **notmuch show** consult the **notmuch-show(1)** man -page, also accessible via **notmuch help show** +information on e.g. **notmuch show** consult the +:any:`notmuch-show(1)` man page, also accessible via **notmuch help +show** The quickest way to get started with Notmuch is to simply invoke the ``notmuch`` command with no arguments, which will interactively guide @@ -39,25 +43,31 @@ OPTIONS Supported global options for ``notmuch`` include -``--help`` [command-name] - Print a synopsis of available commands and exit. With an optional - command name, show the man page for that subcommand. +.. program:: notmuch + +.. option:: --help [command-name] + + Print a synopsis of available commands and exit. With an optional + command name, show the man page for that subcommand. + +.. option:: --version + + Print the installed version of notmuch, and exit. + +.. option:: --config=FILE -``--version`` - Print the installed version of notmuch, and exit. + Specify the configuration file to use. This overrides any + configuration file specified by :envvar:`NOTMUCH_CONFIG`. The empty + string is a permitted and sometimes useful value of *FILE*, which + tells ``notmuch`` to use only configuration metadata from the database. -``--config=FILE`` - Specify the configuration file to use. This overrides any - configuration file specified by ${NOTMUCH\_CONFIG}. The empty - string is a permitted and sometimes useful value of *FILE*, which - tells ``notmuch`` to use only configuration metadata from the database. +.. option:: --uuid=HEX -``--uuid=HEX`` - Enforce that the database UUID (a unique identifier which persists - until e.g. the database is compacted) is HEX; exit with an error - if it is not. This is useful to detect rollover in modification - counts on messages. You can find this UUID using e.g. ``notmuch - count --lastmod`` + Enforce that the database UUID (a unique identifier which persists + until e.g. the database is compacted) is HEX; exit with an error + if it is not. This is useful to detect rollover in modification + counts on messages. You can find this UUID using e.g. ``notmuch + count --lastmod`` All global options except ``--config`` can also be specified after the command. For example, ``notmuch subcommand --uuid=HEX`` is equivalent @@ -75,7 +85,7 @@ use, (or to reconfigure it later). The setup command will prompt for your full name, your primary email address, any alternate email addresses you use, and the directory containing your email archives. Your answers will be written to a -configuration file in ${NOTMUCH\_CONFIG} (if set) or +configuration file in :envvar:`NOTMUCH_CONFIG` (if set) or ${HOME}/.notmuch-config . This configuration file will be created with descriptive comments, making it easy to edit by hand later to change the configuration. Or you can run **notmuch setup** again to change the @@ -90,7 +100,8 @@ will do its best to detect those and ignore them. Mail storage that uses mbox format, (where one mbox file contains many messages), will not work with notmuch. If that's how your mail is currently stored, it is recommended you first convert it to maildir -format with a utility such as mb2md before running **notmuch setup .** +format with a utility such as :manpage:`mb2md(1)` before running +**notmuch setup**. Invoking ``notmuch`` with no command argument will run **setup** if the setup command has not previously been completed. @@ -99,30 +110,32 @@ OTHER COMMANDS -------------- Several of the notmuch commands accept search terms with a common -syntax. See **notmuch-search-terms**\ (7) for more details on the +syntax. See :any:`notmuch-search-terms(7)` for more details on the supported syntax. -The **search**, **show**, **address** and **count** commands are used -to query the email database. +The :any:`notmuch-search(1)`, :any:`notmuch-show(1)`, +:any:`notmuch-address(1)` and :any:`notmuch-count(1)` commands are +used to query the email database. -The **reply** command is useful for preparing a template for an email -reply. +The :any:`notmuch-reply(1)` command is useful for preparing a template +for an email reply. -The **tag** command is the only command available for manipulating -database contents. +The :any:`notmuch-tag(1)` command is the only command available for +manipulating database contents. -The **dump** and **restore** commands can be used to create a textual -dump of email tags for backup purposes, and to restore from that dump. +The :any:`notmuch-dump(1)` and :any:`notmuch-restore(1)` commands can +be used to create a textual dump of email tags for backup purposes, +and to restore from that dump. -The **config** command can be used to get or set settings in the notmuch -configuration file. +The :any:`notmuch-config(1)` command can be used to get or set +settings in the notmuch configuration file. CUSTOM COMMANDS --------------- If the given command is not known to notmuch, notmuch tries to execute -the external **notmuch-** in ${PATH} instead. This allows -users to have their own notmuch related tools to be run via the +the external **notmuch-** in :envvar:`PATH` instead. This +allows users to have their own notmuch related tools to be run via the notmuch command. By design, this does not allow notmuch's own commands to be overridden using external commands. @@ -146,38 +159,46 @@ ENVIRONMENT The following environment variables can be used to control the behavior of notmuch. -**NOTMUCH\_CONFIG** - Specifies the location of the notmuch configuration file. Notmuch - will use ${HOME}/.notmuch-config if this variable is not set. +.. envvar:: NOTMUCH_CONFIG + + Specifies the location of the notmuch configuration file. See + :any:`notmuch-config(1)` for details. + +.. envvar:: NOTMUCH_PROFILE + + Selects among notmuch configurations. See :any:`notmuch-config(1)` + for details. + +.. envvar:: NOTMUCH_TALLOC_REPORT + + Location to write a talloc memory usage report. See + **talloc\_enable\_leak\_report\_full** in :manpage:`talloc(3)` for more + information. -**NOTMUCH\_TALLOC\_REPORT** - Location to write a talloc memory usage report. See - **talloc\_enable\_leak\_report\_full** in **talloc(3)** for more - information. +.. envvar:: NOTMUCH_DEBUG_QUERY -**NOTMUCH\_DEBUG\_QUERY** - If set to a non-empty value, the notmuch library will print (to - stderr) Xapian queries it constructs. + If set to a non-empty value, the notmuch library will print (to + stderr) Xapian queries it constructs. SEE ALSO ======== -**notmuch-address(1)**, -**notmuch-compact(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-properties(7)**, -**notmuch-reindex(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch-address(1)`, +:any:`notmuch-compact(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-properties(7)`, +:any:`notmuch-reindex(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` The notmuch website: **https://notmuchmail.org** diff --git a/doc/man5/notmuch-hooks.rst b/doc/man5/notmuch-hooks.rst index c509afb3..268917cd 100644 --- a/doc/man5/notmuch-hooks.rst +++ b/doc/man5/notmuch-hooks.rst @@ -1,3 +1,5 @@ +.. _notmuch-hooks(5): + ============= notmuch-hooks ============= @@ -12,35 +14,35 @@ DESCRIPTION Hooks are scripts (or arbitrary executables or symlinks to such) that notmuch invokes before and after certain actions. These scripts reside -in a directory defined as described in **notmuch-config(1)**. They +in a directory defined as described in :any:`notmuch-config(1)`. They must have executable permissions. The currently available hooks are described below. **pre-new** - This hook is invoked by the **new** command before scanning or - importing new messages into the database. If this hook exits with - a non-zero status, notmuch will abort further processing of the - **new** command. + This hook is invoked by the :any:`notmuch-new(1)` command before + scanning or importing new messages into the database. If this hook + exits with a non-zero status, notmuch will abort further + processing of the :any:`notmuch-new(1)` command. Typically this hook is used for fetching or delivering new mail to be imported into the database. **post-new** - This hook is invoked by the **new** command after new messages - have been imported into the database and initial tags have been - applied. The hook will not be run if there have been any errors - during the scan or import. + This hook is invoked by the :any:`notmuch-new(1)` command after + new messages have been imported into the database and initial tags + have been applied. The hook will not be run if there have been any + errors during the scan or import. Typically this hook is used to perform additional query-based tagging on the imported messages. **post-insert** - This hook is invoked by the **insert** command after the message - has been delivered, added to the database, and initial tags have - been applied. The hook will not be run if there have been any - errors during the message delivery; what is regarded as successful - delivery depends on the ``--keep`` option. + This hook is invoked by the :any:`notmuch-insert(1)` command after + the message has been delivered, added to the database, and initial + tags have been applied. The hook will not be run if there have + been any errors during the message delivery; what is regarded as + successful delivery depends on the ``--keep`` option. Typically this hook is used to perform additional query-based tagging on the delivered messages. @@ -48,15 +50,15 @@ The currently available hooks are described below. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -**notmuch-search-terms(7)**, -**notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/doc/man7/notmuch-properties.rst b/doc/man7/notmuch-properties.rst index a7d91d67..7f128b5c 100644 --- a/doc/man7/notmuch-properties.rst +++ b/doc/man7/notmuch-properties.rst @@ -1,3 +1,5 @@ +.. _notmuch-properties(7): + ================== notmuch-properties ================== @@ -45,7 +47,7 @@ CONVENTIONS =========== Any property with a key that starts with "index." will be removed (and -possibly re-set) upon reindexing (see **notmuch-reindex(1)**). +possibly re-set) upon reindexing (see :any:`notmuch-reindex(1)`). MESSAGE PROPERTIES ================== @@ -70,15 +72,15 @@ of its normal activity. If notmuch never tried to decrypt an encrypted message during indexing (which is the default, see ``index.decrypt`` in - **notmuch-config(1)**), then this property will not be set on that + :any:`notmuch-config(1)`), then this property will not be set on that message. **session-key** - When **notmuch-show(1)** or **nomtuch-reply** encounters a message - with an encrypted part, if notmuch finds a ``session-key`` - property associated with the message, it will try that stashed - session key for decryption. + When :any:`notmuch-show(1)` or :any:`notmuch-reply(1)` encounters + a message with an encrypted part, if notmuch finds a + ``session-key`` property associated with the message, it will try + that stashed session key for decryption. If you do not want to use any stashed session keys that might be present, you should pass those programs ``--decrypt=false``. @@ -97,7 +99,7 @@ of its normal activity. message. This includes attachments, cryptographic signatures, and other material that cannot be reconstructed from the index alone. - See ``index.decrypt`` in **notmuch-config(1)** for more + See ``index.decrypt`` in :any:`notmuch-config(1)` for more details about how to set notmuch's policy on when to store session keys. @@ -136,13 +138,13 @@ of its normal activity. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-dump(1)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reindex(1)**, -**notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-show(1)**, -***notmuch-search-terms(7)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-reindex(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search-terms(7)`, +:any:`notmuch-show(1)` diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst index 28fca737..e80cc7d0 100644 --- a/doc/man7/notmuch-search-terms.rst +++ b/doc/man7/notmuch-search-terms.rst @@ -1,3 +1,5 @@ +.. _notmuch-search-terms(7): + ==================== notmuch-search-terms ==================== @@ -39,7 +41,7 @@ indicate user-supplied values). Some of the prefixes with forms can be also used to restrict the results to those whose value matches a regular expression (see -**regex(7)**) delimited with //, for example:: +:manpage:`regex(7)`) delimited with //, for example:: notmuch search 'from:"/bob@.*[.]example[.]com/"' @@ -71,8 +73,9 @@ mimetype: tag: or tag:// or is: or is:// For **tag:** and **is:** valid tag values include **inbox** and - **unread** by default for new messages added by **notmuch new** as - well as any other tag values added manually with **notmuch tag**. + **unread** by default for new messages added by + :any:`notmuch-new(1)` as well as any other tag values added + manually with :any:`notmuch-tag(1)`. id: or mid: or mid:// For **id:** and **mid:**, message ID values are the literal @@ -83,7 +86,7 @@ thread: The **thread:** prefix can be used with the thread ID values that are generated internally by notmuch (and do not appear in email messages). These thread ID values can be seen in the first column - of output from **notmuch search** + of output from :any:`notmuch-search(1)` thread:{} Threads may be searched for indirectly by providing an arbitrary @@ -151,21 +154,22 @@ lastmod:.. The **lastmod:** prefix can be used to restrict the result by the database revision number of when messages were last modified (tags 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. + conjunction with the ``--uuid`` argument to + :any:`notmuch-search(1)` to find messages that have changed since + an earlier query. query: The **query:** prefix allows queries to refer to previously saved - queries added with **notmuch-config(1)**. + queries added with :any:`notmuch-config(1)`. property:= The **property:** prefix searches for messages with a particular = property pair. Properties are used internally by notmuch (and extensions) to add metadata to messages. A given key can be present on a given message with several different values. - See **notmuch-properties(7)** for more details. + See :any:`notmuch-properties(7)` for more details. -User defined prefixes are also supported, see **notmuch-config(1)** for +User defined prefixes are also supported, see :any:`notmuch-config(1)` for details. Operators @@ -443,17 +447,17 @@ Some time zone codes, e.g. UTC, EET. SEE ALSO ======== -**notmuch(1)**, -**notmuch-config(1)**, -**notmuch-count(1)**, -**notmuch-dump(1)**, -**notmuch-hooks(5)**, -**notmuch-insert(1)**, -**notmuch-new(1)**, -**notmuch-reindex(1)**, -**notmuch-properties(1)**, -***notmuch-reply(1)**, -**notmuch-restore(1)**, -**notmuch-search(1)**, -***notmuch-show(1)**, -**notmuch-tag(1)** +:any:`notmuch(1)`, +:any:`notmuch-config(1)`, +:any:`notmuch-count(1)`, +:any:`notmuch-dump(1)`, +:any:`notmuch-hooks(5)`, +:any:`notmuch-insert(1)`, +:any:`notmuch-new(1)`, +:any:`notmuch-properties(7)`, +:any:`notmuch-reindex(1)`, +:any:`notmuch-reply(1)`, +:any:`notmuch-restore(1)`, +:any:`notmuch-search(1)`, +:any:`notmuch-show(1)`, +:any:`notmuch-tag(1)` diff --git a/gmime-filter-reply.c b/gmime-filter-reply.c index 2b067669..35349cc8 100644 --- a/gmime-filter-reply.c +++ b/gmime-filter-reply.c @@ -43,29 +43,31 @@ static void filter_reset (GMimeFilter *filter); static GMimeFilterClass *parent_class = NULL; +static GType type = 0; +static const GTypeInfo info = { + .class_size = sizeof (GMimeFilterReplyClass), + .base_init = NULL, + .base_finalize = NULL, + .class_init = (GClassInitFunc) g_mime_filter_reply_class_init, + .class_finalize = NULL, + .class_data = NULL, + .instance_size = sizeof (GMimeFilterReply), + .n_preallocs = 0, + .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init, + .value_table = NULL, +}; + + +void +g_mime_filter_reply_module_init (void) +{ + type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0); + parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); +} GType g_mime_filter_reply_get_type (void) { - static GType type = 0; - - if (! type) { - static const GTypeInfo info = { - .class_size = sizeof (GMimeFilterReplyClass), - .base_init = NULL, - .base_finalize = NULL, - .class_init = (GClassInitFunc) g_mime_filter_reply_class_init, - .class_finalize = NULL, - .class_data = NULL, - .instance_size = sizeof (GMimeFilterReply), - .n_preallocs = 0, - .instance_init = (GInstanceInitFunc) g_mime_filter_reply_init, - .value_table = NULL, - }; - - type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0); - } - return type; } @@ -76,8 +78,6 @@ g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *clas GObjectClass *object_class = G_OBJECT_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); - parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); - object_class->finalize = g_mime_filter_reply_finalize; filter_class->copy = filter_copy; diff --git a/gmime-filter-reply.h b/gmime-filter-reply.h index 7cdefcd1..988fe2d6 100644 --- a/gmime-filter-reply.h +++ b/gmime-filter-reply.h @@ -21,6 +21,8 @@ #include +void g_mime_filter_reply_module_init (void); + G_BEGIN_DECLS #define GMIME_TYPE_FILTER_REPLY (g_mime_filter_reply_get_type ()) diff --git a/lib/Makefile.local b/lib/Makefile.local index 01cbb3f2..e2d4b91d 100644 --- a/lib/Makefile.local +++ b/lib/Makefile.local @@ -62,7 +62,8 @@ libnotmuch_cxx_srcs = \ $(dir)/thread-fp.cc \ $(dir)/features.cc \ $(dir)/prefix.cc \ - $(dir)/open.cc + $(dir)/open.cc \ + $(dir)/init.cc libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o) diff --git a/lib/add-message.cc b/lib/add-message.cc index d6e5e73d..b16748fd 100644 --- a/lib/add-message.cc +++ b/lib/add-message.cc @@ -40,17 +40,14 @@ parse_references (void *ctx, static const char * _notmuch_database_generate_thread_id (notmuch_database_t *notmuch) { - /* 16 bytes (+ terminator) for hexadecimal representation of - * a 64-bit integer. */ - static char thread_id[17]; notmuch->last_thread_id++; - sprintf (thread_id, "%016" PRIx64, notmuch->last_thread_id); + sprintf (notmuch->thread_id_str, "%016" PRIx64, notmuch->last_thread_id); - notmuch->writable_xapian_db->set_metadata ("last_thread_id", thread_id); + notmuch->writable_xapian_db->set_metadata ("last_thread_id", notmuch->thread_id_str); - return thread_id; + return notmuch->thread_id_str; } static char * diff --git a/lib/database-private.h b/lib/database-private.h index 0d12ec1e..1a73dacc 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -206,6 +206,10 @@ struct _notmuch_database { enum _notmuch_features features; unsigned int last_doc_id; + + /* 16 bytes (+ terminator) for hexadecimal representation of + * a 64-bit integer. */ + char thread_id_str[17]; uint64_t last_thread_id; /* error reporting; this value persists only until the diff --git a/lib/index.cc b/lib/index.cc index 55c8372e..728bfb22 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -148,8 +148,6 @@ notmuch_filter_discard_non_term_class_init (NotmuchFilterDiscardNonTermClass *kl GObjectClass *object_class = G_OBJECT_CLASS (klass); GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass); - parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); - object_class->finalize = notmuch_filter_discard_non_term_finalize; filter_class->copy = filter_copy; @@ -240,30 +238,33 @@ filter_reset (GMimeFilter *gmime_filter) * * Returns: a new #NotmuchFilterDiscardNonTerm filter. **/ +static GType type = 0; + +static const GTypeInfo info = { + .class_size = sizeof (NotmuchFilterDiscardNonTermClass), + .base_init = NULL, + .base_finalize = NULL, + .class_init = (GClassInitFunc) notmuch_filter_discard_non_term_class_init, + .class_finalize = NULL, + .class_data = NULL, + .instance_size = sizeof (NotmuchFilterDiscardNonTerm), + .n_preallocs = 0, + .instance_init = NULL, + .value_table = NULL, +}; + +void +_notmuch_filter_init () { + type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, + (GTypeFlags) 0); + parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER); +} + static GMimeFilter * notmuch_filter_discard_non_term_new (GMimeContentType *content_type) { - static GType type = 0; NotmuchFilterDiscardNonTerm *filter; - if (! type) { - static const GTypeInfo info = { - .class_size = sizeof (NotmuchFilterDiscardNonTermClass), - .base_init = NULL, - .base_finalize = NULL, - .class_init = (GClassInitFunc) notmuch_filter_discard_non_term_class_init, - .class_finalize = NULL, - .class_data = NULL, - .instance_size = sizeof (NotmuchFilterDiscardNonTerm), - .n_preallocs = 0, - .instance_init = NULL, - .value_table = NULL, - }; - - type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, - (GTypeFlags) 0); - } - filter = (NotmuchFilterDiscardNonTerm *) g_object_new (type, NULL); filter->content_type = content_type; filter->state = 0; diff --git a/lib/init.cc b/lib/init.cc new file mode 100644 index 00000000..cf29200f --- /dev/null +++ b/lib/init.cc @@ -0,0 +1,21 @@ +#include "notmuch-private.h" + +#include + +static void do_init () +{ + /* Initialize the GLib type system and threads */ +#if ! GLIB_CHECK_VERSION (2, 35, 1) + g_type_init (); +#endif + + g_mime_init (); + _notmuch_filter_init (); +} + +void +_notmuch_init () +{ + static std::once_flag initialized; + std::call_once (initialized, do_init); +} diff --git a/lib/message-file.c b/lib/message-file.c index 9e9b387f..647ccf3a 100644 --- a/lib/message-file.c +++ b/lib/message-file.c @@ -141,7 +141,6 @@ _notmuch_message_file_parse (notmuch_message_file_t *message) { GMimeParser *parser; notmuch_status_t status = NOTMUCH_STATUS_SUCCESS; - static int initialized = 0; bool is_mbox; if (message->message) @@ -149,10 +148,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message) is_mbox = _is_mbox (message->stream); - if (! initialized) { - g_mime_init (); - initialized = 1; - } + _notmuch_init (); message->headers = g_hash_table_new_full (strcase_hash, strcase_equal, free, g_free); diff --git a/lib/message.cc b/lib/message.cc index 42d56acb..7af6ab82 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -68,7 +68,7 @@ struct maildir_flag_tag { }; /* ASCII ordered table of Maildir flags and associated tags */ -static struct maildir_flag_tag flag2tag[] = { +static const struct maildir_flag_tag flag2tag[] = { { 'D', "draft", false }, { 'F', "flagged", false }, { 'P', "passed", false }, diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 10b1b024..093c29b1 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -469,11 +469,18 @@ _notmuch_database_link_message_to_parents (notmuch_database_t *notmuch, const char **thread_id); /* index.cc */ +void +_notmuch_filter_init (); + notmuch_status_t _notmuch_message_index_file (notmuch_message_t *message, notmuch_indexopts_t *indexopts, notmuch_message_file_t *message_file); +/* init.cc */ +void +_notmuch_init (); + /* messages.c */ typedef struct _notmuch_message_node { diff --git a/lib/open.cc b/lib/open.cc index 3325e725..1ca69665 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -324,24 +324,6 @@ _set_database_path (notmuch_database_t *notmuch, _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path); } -static void -_init_libs () -{ - - static int initialized = 0; - - /* Initialize the GLib type system and threads */ -#if ! GLIB_CHECK_VERSION (2, 35, 1) - g_type_init (); -#endif - - /* Initialize gmime */ - if (! initialized) { - g_mime_init (); - initialized = 1; - } -} - static void _load_database_state (notmuch_database_t *notmuch) { @@ -515,7 +497,7 @@ notmuch_database_open_with_config (const char *database_path, GKeyFile *key_file = NULL; bool split = false; - _init_libs (); + _notmuch_init (); notmuch = _alloc_notmuch (); if (! notmuch) { @@ -612,7 +594,7 @@ notmuch_database_create_with_config (const char *database_path, int err; bool split = false; - _init_libs (); + _notmuch_init (); notmuch = _alloc_notmuch (); if (! notmuch) { @@ -808,7 +790,7 @@ notmuch_database_load_config (const char *database_path, GKeyFile *key_file = NULL; bool split = false; - _init_libs (); + _notmuch_init (); notmuch = _alloc_notmuch (); if (! notmuch) { diff --git a/lib/thread.cc b/lib/thread.cc index 46a50e80..60e9a666 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -25,7 +25,8 @@ #include /* GHashTable */ #ifdef DEBUG_THREADING -#define THREAD_DEBUG(format, ...) fprintf (stderr, format " (%s).\n", ##__VA_ARGS__, __location__) +#define THREAD_DEBUG(format, ...) fprintf (stderr, "DT: " format " (%s).\n", ##__VA_ARGS__, \ + __location__) #else #define THREAD_DEBUG(format, ...) do {} while (0) /* ignored */ #endif @@ -400,7 +401,7 @@ _parent_via_in_reply_to (notmuch_thread_t *thread, notmuch_message_t *message) const char *in_reply_to; in_reply_to = _notmuch_message_get_in_reply_to (message); - THREAD_DEBUG ("checking message = %s in_reply_to=%s\n", + THREAD_DEBUG ("checking message = %s in_reply_to=%s", notmuch_message_get_message_id (message), in_reply_to); if (in_reply_to && (! EMPTY_STRING (in_reply_to)) && @@ -423,31 +424,31 @@ _parent_or_toplevel (notmuch_thread_t *thread, notmuch_message_t *message) const notmuch_string_list_t *references = _notmuch_message_get_references (message); - THREAD_DEBUG ("trying to reparent via references: %s\n", + THREAD_DEBUG ("trying to reparent via references: %s", notmuch_message_get_message_id (message)); for (notmuch_string_node_t *ref_node = references->head; ref_node; ref_node = ref_node->next) { - THREAD_DEBUG ("checking reference=%s\n", ref_node->string); + THREAD_DEBUG ("checking reference=%s", ref_node->string); if ((g_hash_table_lookup_extended (thread->message_hash, ref_node->string, NULL, (void **) &new_parent))) { size_t new_depth = _notmuch_message_get_thread_depth (new_parent); - THREAD_DEBUG ("got depth %lu\n", new_depth); + THREAD_DEBUG ("got depth %lu", new_depth); if (new_depth > max_depth || ! parent) { - THREAD_DEBUG ("adding at depth %lu parent=%s\n", new_depth, ref_node->string); + THREAD_DEBUG ("adding at depth %lu parent=%s", new_depth, ref_node->string); max_depth = new_depth; parent = new_parent; } } } if (parent) { - THREAD_DEBUG ("adding reply %s to parent=%s\n", + THREAD_DEBUG ("adding reply %s to parent=%s", notmuch_message_get_message_id (message), notmuch_message_get_message_id (parent)); _notmuch_message_add_reply (parent, message); } else { - THREAD_DEBUG ("adding as toplevel %s\n", + THREAD_DEBUG ("adding as toplevel %s", notmuch_message_get_message_id (message)); _notmuch_message_list_add_message (thread->toplevel_list, message); } @@ -482,13 +483,13 @@ _resolve_thread_relationships (notmuch_thread_t *thread) */ if (first_node) { message = first_node->message; - THREAD_DEBUG ("checking first message %s\n", + THREAD_DEBUG ("checking first message %s", notmuch_message_get_message_id (message)); if (_notmuch_message_list_empty (maybe_toplevel_list) || ! _parent_via_in_reply_to (thread, message)) { - THREAD_DEBUG ("adding first message as toplevel = %s\n", + THREAD_DEBUG ("adding first message as toplevel = %s", notmuch_message_get_message_id (message)); _notmuch_message_list_add_message (maybe_toplevel_list, message); } diff --git a/notmuch-client-init.c b/notmuch-client-init.c new file mode 100644 index 00000000..60db6ba4 --- /dev/null +++ b/notmuch-client-init.c @@ -0,0 +1,18 @@ +#include "notmuch-client.h" +#include "gmime-filter-reply.h" + +/* Caller is responsible for only calling this once */ + +void +notmuch_client_init (void) +{ +#if ! GLIB_CHECK_VERSION (2, 35, 1) + g_type_init (); +#endif + + g_mime_init (); + + g_mime_filter_reply_module_init (); + + talloc_enable_null_tracking (); +} diff --git a/notmuch-client.h b/notmuch-client.h index 270553ad..8227fea4 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -250,6 +250,10 @@ json_quote_chararray (const void *ctx, const char *str, const size_t len); char * json_quote_str (const void *ctx, const char *str); +/* notmuch-client-init.c */ + +void notmuch_client_init (void); + /* notmuch-config.c */ typedef enum { diff --git a/notmuch-config.c b/notmuch-config.c index d9390c4d..3430a3d3 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -32,7 +32,7 @@ static const char toplevel_config_comment[] = "\n" " For more information about notmuch, see https://notmuchmail.org"; -struct config_group { +static const struct config_group { const char *group_name; const char *comment; } group_comment_table [] = { @@ -512,14 +512,14 @@ typedef struct config_key { bool (*validate)(const char *); } config_key_info_t; -static struct config_key +static const struct config_key config_key_table[] = { { "index.decrypt", false, NULL }, { "index.header.", true, validate_field_name }, { "query.", true, NULL }, }; -static config_key_info_t * +static const config_key_info_t * _config_key_info (const char *item) { for (size_t i = 0; i < ARRAY_SIZE (config_key_table); i++) { @@ -583,7 +583,7 @@ notmuch_config_command_set (notmuch_database_t *notmuch, int argc, char *argv[]) { char *group, *key; - config_key_info_t *key_info; + const config_key_info_t *key_info; notmuch_conffile_t *config; bool update_database = false; int opt_index, ret; diff --git a/notmuch-insert.c b/notmuch-insert.c index 00c00468..e3d87e4a 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -34,7 +34,7 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { - static char msg[] = "Stopping... \n"; + static const char msg[] = "Stopping... \n"; /* This write is "opportunistic", so it's okay to ignore the * result. It is not required for correctness, and if it does diff --git a/notmuch-new.c b/notmuch-new.c index 993359d6..1ee498fa 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -81,7 +81,7 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { - static char msg[] = "Stopping... \n"; + static const char msg[] = "Stopping... \n"; /* This write is "opportunistic", so it's okay to ignore the * result. It is not required for correctness, and if it does @@ -403,8 +403,11 @@ add_file (notmuch_database_t *notmuch, const char *filename, break; /* Non-fatal issues (go on to next file). */ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: - if (state->synchronize_flags) - notmuch_message_maildir_flags_to_tags (message); + if (state->synchronize_flags) { + status = notmuch_message_maildir_flags_to_tags (message); + if (print_status_message ("add_file", message, status)) + goto DONE; + } break; case NOTMUCH_STATUS_FILE_NOT_EMAIL: fprintf (stderr, "Note: Ignoring non-mail file: %s\n", filename); diff --git a/notmuch-reindex.c b/notmuch-reindex.c index 8904c1f4..a7380a4b 100644 --- a/notmuch-reindex.c +++ b/notmuch-reindex.c @@ -26,7 +26,7 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { - static char msg[] = "Stopping... \n"; + static const char msg[] = "Stopping... \n"; /* This write is "opportunistic", so it's okay to ignore the * result. It is not required for correctness, and if it does diff --git a/notmuch-tag.c b/notmuch-tag.c index 667a75d6..de428c8e 100644 --- a/notmuch-tag.c +++ b/notmuch-tag.c @@ -27,7 +27,7 @@ static volatile sig_atomic_t interrupted; static void handle_sigint (unused (int sig)) { - static char msg[] = "Stopping... \n"; + static const char msg[] = "Stopping... \n"; /* This write is "opportunistic", so it's okay to ignore the * result. It is not required for correctness, and if it does diff --git a/notmuch.c b/notmuch.c index 2429999c..d0a94fc2 100644 --- a/notmuch.c +++ b/notmuch.c @@ -139,7 +139,7 @@ notmuch_process_shared_indexing_options (notmuch_database_t *notmuch) } -static command_t commands[] = { +static const command_t commands[] = { { NULL, notmuch_command, NOTMUCH_COMMAND_CONFIG_CREATE | NOTMUCH_COMMAND_CONFIG_LOAD, "Notmuch main command." }, { "setup", notmuch_setup_command, NOTMUCH_COMMAND_CONFIG_CREATE | NOTMUCH_COMMAND_CONFIG_LOAD, @@ -189,7 +189,7 @@ typedef struct help_topic { const char *summary; } help_topic_t; -static help_topic_t help_topics[] = { +static const help_topic_t help_topics[] = { { "search-terms", "Common search term syntax." }, { "hooks", @@ -198,7 +198,7 @@ static help_topic_t help_topics[] = { "Message property conventions and documentation." }, }; -static command_t * +static const command_t * find_command (const char *name) { size_t i; @@ -216,8 +216,8 @@ int notmuch_format_version; static void usage (FILE *out) { - command_t *command; - help_topic_t *topic; + const command_t *command; + const help_topic_t *topic; unsigned int i; fprintf (out, @@ -308,8 +308,8 @@ exec_man (const char *page) static int _help_for (const char *topic_name) { - command_t *command; - help_topic_t *topic; + const command_t *command; + const help_topic_t *topic; unsigned int i; if (! topic_name) { @@ -452,7 +452,7 @@ main (int argc, char *argv[]) void *local; char *talloc_report; const char *command_name = NULL; - command_t *command; + const command_t *command; const char *config_file_name = NULL; notmuch_database_t *notmuch = NULL; int opt_index; @@ -464,15 +464,10 @@ main (int argc, char *argv[]) { } }; - talloc_enable_null_tracking (); + notmuch_client_init (); local = talloc_new (NULL); - g_mime_init (); -#if ! GLIB_CHECK_VERSION (2, 35, 1) - g_type_init (); -#endif - /* Globally default to the current output format version. */ notmuch_format_version = NOTMUCH_FORMAT_CUR; diff --git a/performance-test/README b/performance-test/README index fbc61028..59b37b1b 100644 --- a/performance-test/README +++ b/performance-test/README @@ -16,6 +16,7 @@ In addition to having notmuch, you need: - xz. Some speedup can be gotten by installing "pixz", but this is probably only worthwhile if you are debugging the tests. - valgrind (for the memory tests) +- perf (optional, for more fine-grained timing) Getting set up to run tests: ---------------------------- @@ -56,11 +57,24 @@ supports the following arguments --small / --medium / --large Choose corpus size. --debug Enable debugging. In particular don't delete - temporary directories. + temporary directories. +--perf Run perf record in place of /usr/bin/time. Perf output can be + found in a log directory. +--call-graph {fp,lbr,dwarf} Call graph option for perf record. Default is 'lbr'. When using the make targets, you can pass arguments to all test scripts by defining the make variable OPTIONS. +Log Directory +------------- + +The memory tests, and the time tests when option '--perf' is given +save their output in a directory named as follows + + log.$test_name-$corpus_size-$timestamp + +These directories are removed by "make clean". + Writing tests ------------- diff --git a/performance-test/T03-reindex.sh b/performance-test/T03-reindex.sh index 8db52a33..b58950d7 100755 --- a/performance-test/T03-reindex.sh +++ b/performance-test/T03-reindex.sh @@ -10,4 +10,32 @@ time_run 'reindex *' "notmuch reindex '*'" time_run 'reindex *' "notmuch reindex '*'" time_run 'reindex *' "notmuch reindex '*'" +manifest=$(mktemp manifestXXXXXX) + +find mail -type f ! -path 'mail/.notmuch/*' | sed -n '1~4 p' > $manifest +# arithmetic context is to eat extra whitespace on e.g. some BSDs +count=$((`wc -l < $manifest`)) + +xargs tar uf backup.tar < $manifest + +perl -nle 'rename $_, "$_.renamed"' $manifest + +time_run "reindex ($count mv)" "notmuch reindex '*'" + +perl -nle 'rename "$_.renamed", $_' $manifest + +time_run "reindex ($count mv back)" "notmuch reindex '*'" + +perl -nle 'unlink $_; unlink $_.copy' $manifest + +time_run "reindex ($count rm)" "notmuch reindex '*'" + +tar xf backup.tar + +time_run "reindex ($count restore)" "notmuch reindex '*'" + +perl -nle 'link $_, "$_.copy"' $manifest + +time_run "reindex ($count cp)" "notmuch reindex '*'" + time_done diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh index b70288cc..e7c502b6 100644 --- a/performance-test/perf-test-lib.sh +++ b/performance-test/perf-test-lib.sh @@ -1,6 +1,9 @@ . $(dirname "$0")/version.sh || exit 1 +debug="" corpus_size=large +perf_callgraph=lbr +use_perf=0 while test "$#" -ne 0 do @@ -9,6 +12,15 @@ do debug=t; shift ;; + -p|--perf) + use_perf=1; + shift + ;; + -c|--call-graph) + shift + perf_callgraph=$1 + shift + ;; -s|--small) corpus_size=small; shift @@ -127,10 +139,20 @@ notmuch_new_with_cache () fi } +make_log_dir () { + local timestamp=$(date +%Y%m%dT%H%M%S) + log_dir=${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp} + mkdir -p "${log_dir}" +} + time_start () { add_email_corpus + if [[ "$use_perf" = 1 ]]; then + make_log_dir + fi + print_header notmuch_new_with_cache time_run @@ -140,9 +162,7 @@ memory_start () { add_email_corpus - local timestamp=$(date +%Y%m%dT%H%M%S) - log_dir="${TEST_DIRECTORY}/log.$(basename $0)-$corpus_size-${timestamp}" - mkdir -p ${log_dir} + make_log_dir notmuch_new_with_cache memory_run } @@ -193,7 +213,13 @@ time_run () printf " %-22s" "$1" test_count=$(($test_count+1)) if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi - if ! eval >&3 "/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" ; then + if [[ "$use_perf" = 1 ]]; then + command_str="perf record --call-graph=${perf_callgraph} -o ${log_dir}/${test_count}.perf $2" + else + command_str="/usr/bin/time -f '%e\t%U\t%S\t%M\t%I/%O' $2" + fi + + if ! eval >&3 "$command_str" ; then test_failure=$(($test_failure + 1)) return 1 fi diff --git a/test/T000-basic.sh b/test/T000-basic.sh index 7fbdcfa3..a2f4d93f 100755 --- a/test/T000-basic.sh +++ b/test/T000-basic.sh @@ -33,7 +33,7 @@ test_begin_subtest 'failure to clean up causes the test to fail' test_expect_code 2 'test_when_finished "(exit 2)"' EXPECTED=$NOTMUCH_SRCDIR/test/test.expected-output -suppress_diff_date() { +suppress_diff_date () { sed -e 's/\(.*\-\-\- test-verbose\.4\.\expected\).*/\1/' \ -e 's/\(.*\+\+\+ test-verbose\.4\.\output\).*/\1/' } diff --git a/test/T070-insert.sh b/test/T070-insert.sh index b37a9b67..208deb1c 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -15,7 +15,7 @@ notmuch new > /dev/null # They happen to be in the mail directory already but that is okay # since we do not call notmuch new hereafter. -gen_insert_msg() { +gen_insert_msg () { generate_message \ "[subject]=\"insert-subject\"" \ "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \ diff --git a/test/T140-excludes.sh b/test/T140-excludes.sh index acab5381..e9cc9cb0 100755 --- a/test/T140-excludes.sh +++ b/test/T140-excludes.sh @@ -5,8 +5,7 @@ test_description='"notmuch search, count and show" with excludes in several vari # Generates a thread consisting of a top level message and 'length' # replies. The subject of the top message 'subject: top message" # and the subject of the nth reply in the thread is "subject: reply n" -generate_thread () -{ +generate_thread () { local subject="$1" local length="$2" generate_message '[subject]="'"${subject}: top message"'"' '[body]="'"body of top message"'"' @@ -22,7 +21,7 @@ generate_thread () done notmuch new > /dev/null # We cannot retrieve the thread_id until after we have run notmuch new. - gen_thread_id=`notmuch search --output=threads id:${gen_thread_msg_id[0]}` + gen_thread_id=$(notmuch search --output=threads id:${gen_thread_msg_id[0]} 2>/dev/null) } ############################################# diff --git a/test/T160-json.sh b/test/T160-json.sh index e8b75605..638afb4d 100755 --- a/test/T160-json.sh +++ b/test/T160-json.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash test_description="--format=json output" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 test_begin_subtest "Show message: json" add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc@notmuchmail.org\"" "[reply-to]=\"test_suite+replyto@notmuchmail.org\"" "[body]=\"json-show-message\"" diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh index 24be8351..af8c4b44 100755 --- a/test/T170-sexp.sh +++ b/test/T170-sexp.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash test_description="--format=sexp output" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 test_begin_subtest "Show message: sexp" add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc@notmuchmail.org\"" "[reply-to]=\"test_suite+replyto@notmuchmail.org\"" "[body]=\"sexp-show-message\"" diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh index 6f715ff9..3545a599 100755 --- a/test/T190-multipart.sh +++ b/test/T190-multipart.sh @@ -725,8 +725,7 @@ EOF notmuch new > /dev/null -cat_expected_head () -{ +cat_expected_head () { cat <&1 | notmuch_show_sanitize) -test_expect_equal "$output" "thread:0000000000000003 2001-01-05 [1/1] Notmuch Test Suite; encoded word with spaces (inbox unread)" +output=$(notmuch search id:${gen_msg_id} 2>&1 | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; encoded word with spaces (inbox unread)" test_begin_subtest "RFC 2047 encoded words back to back" add_message '[subject]="=?utf-8?q?encoded-words-back?==?utf-8?q?to-back?="' -output=$(notmuch search id:${gen_msg_id} 2>&1 | notmuch_show_sanitize) -test_expect_equal "$output" "thread:0000000000000004 2001-01-05 [1/1] Notmuch Test Suite; encoded-words-backto-back (inbox unread)" +output=$(notmuch search id:${gen_msg_id} 2>&1 | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; encoded-words-backto-back (inbox unread)" test_begin_subtest "RFC 2047 encoded words without space before or after" add_message '[subject]="=?utf-8?q?encoded?=word without=?utf-8?q?space?=" ' -output=$(notmuch search id:${gen_msg_id} 2>&1 | notmuch_show_sanitize) -test_expect_equal "$output" "thread:0000000000000005 2001-01-05 [1/1] Notmuch Test Suite; encodedword withoutspace (inbox unread)" +output=$(notmuch search id:${gen_msg_id} 2>&1 | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; encodedword withoutspace (inbox unread)" test_begin_subtest "Mislabeled Windows-1252 encoding" add_message '[content-type]="text/plain; charset=iso-8859-1"' \ diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index e6489246..b94236fd 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -2,9 +2,11 @@ test_description="emacs interface" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output +test_require_emacs add_email_corpus # syntax errors in test-lib.el cause mysterious failures @@ -1057,7 +1059,6 @@ End of search results. === MESSAGES === YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details) === ERROR === -[XXX] YYY/notmuch_fail exited with status 1 command: YYY/notmuch_fail search --format\=sexp --format-version\=4 --sort\=newest-first tag\:inbox exit status: 1" diff --git a/test/T320-emacs-large-search-buffer.sh b/test/T320-emacs-large-search-buffer.sh index f61e8a97..d2638c8b 100755 --- a/test/T320-emacs-large-search-buffer.sh +++ b/test/T320-emacs-large-search-buffer.sh @@ -1,11 +1,14 @@ #!/usr/bin/env bash test_description="Emacs with large search results buffer" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 x=xxxxxxxxxx # 10 x=$x$x$x$x$x$x$x$x$x$x # 100 x=$x$x$x$x$x$x$x$x$x # 900 +test_require_emacs + # We generate a long subject here (over 900 bytes) so that the emacs # search results get large quickly. With 30 such messages we should # cross several 4kB page boundaries and see the bug. diff --git a/test/T330-emacs-subject-to-filename.sh b/test/T330-emacs-subject-to-filename.sh index eaf7c980..6e09a048 100755 --- a/test/T330-emacs-subject-to-filename.sh +++ b/test/T330-emacs-subject-to-filename.sh @@ -2,6 +2,9 @@ test_description="emacs: mail subject to filename" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 + +test_require_emacs # emacs server can't be started in a child process with $(test_emacs ...) test_emacs '(ignore)' > /dev/null diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh index 0aada4df..4508c984 100755 --- a/test/T350-crypto.sh +++ b/test/T350-crypto.sh @@ -6,9 +6,11 @@ test_description='PGP/MIME signature verification and decryption' . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 ################################################## +test_require_emacs add_gnupg_home test_begin_subtest "emacs delivery of signed message" diff --git a/test/T355-smime.sh b/test/T355-smime.sh index 8b2b52be..69bdcfac 100755 --- a/test/T355-smime.sh +++ b/test/T355-smime.sh @@ -2,7 +2,9 @@ test_description='S/MIME signature verification and decryption' . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 +test_require_emacs test_require_external_prereq openssl test_require_external_prereq gpgsm diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh index 1951ef78..0d30e566 100755 --- a/test/T357-index-decryption.sh +++ b/test/T357-index-decryption.sh @@ -4,9 +4,11 @@ test_description='indexing decrypted mail' . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 ################################################## +test_require_emacs add_gnupg_home # create a test encrypted message diff --git a/test/T358-emacs-protected-headers.sh b/test/T358-emacs-protected-headers.sh index bca78531..b25d7ea7 100755 --- a/test/T358-emacs-protected-headers.sh +++ b/test/T358-emacs-protected-headers.sh @@ -2,8 +2,10 @@ test_description="protected headers in emacs interface" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 # testing protected headers with emacs +test_require_emacs add_gnupg_home add_email_corpus protected-headers diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh index 45de2228..afe49d93 100755 --- a/test/T380-atomicity.sh +++ b/test/T380-atomicity.sh @@ -67,7 +67,7 @@ if test_require_external_prereq gdb; then ${TEST_GDB} -tty /dev/null -batch -x $NOTMUCH_SRCDIR/test/atomicity.py notmuch 1>gdb.out 2>&1 # Get the final, golden output - notmuch search '*' > expected + notmuch search '*' 2>/dev/null > expected # Check output against golden output outcount=$(cat outcount) diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh index a0b76eb8..d36d4aff 100755 --- a/test/T395-ruby.sh +++ b/test/T395-ruby.sh @@ -8,95 +8,78 @@ fi add_email_corpus +test_ruby() { + ( + cat <<-EOF + require 'notmuch' + db = Notmuch::Database.new('$MAIL_DIR') + EOF + cat + ) | $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT + test_expect_equal_file EXPECTED OUTPUT +} + test_begin_subtest "compare thread ids" +notmuch search --sort=oldest-first --output=threads tag:inbox > EXPECTED 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) -@q = @db.query('tag:inbox') -@q.sort = Notmuch::SORT_OLDEST_FIRST -for t in @q.search_threads do - print t.thread_id, "\n" +q = db.query('tag:inbox') +q.sort = Notmuch::SORT_OLDEST_FIRST +q.search_threads.each do |t| + puts 'thread:%s' % t.thread_id end EOF -notmuch search --sort=oldest-first --output=threads tag:inbox | sed s/^thread:// > EXPECTED -test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "compare message ids" +notmuch search --sort=oldest-first --output=messages tag:inbox > EXPECTED 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) -@q = @db.query('tag:inbox') -@q.sort = Notmuch::SORT_OLDEST_FIRST -for m in @q.search_messages do - print m.message_id, "\n" +q = db.query('tag:inbox') +q.sort = Notmuch::SORT_OLDEST_FIRST +q.search_messages.each do |m| + puts 'id:%s' % m.message_id end EOF -notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED -test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "get non-existent file" +echo nil > EXPECTED 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) -result = @db.find_message_by_filename('i-dont-exist') -print (result == nil) +p db.find_message_by_filename('i-dont-exist') EOF -test_expect_equal "$(cat OUTPUT)" "true" test_begin_subtest "count messages" +notmuch count --output=messages tag:inbox > EXPECTED 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) -@q = @db.query('tag:inbox') -print @q.count_messages(),"\n" +puts db.query('tag:inbox').count_messages() EOF -notmuch count --output=messages tag:inbox > EXPECTED -test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "count threads" +notmuch count --output=threads tag:inbox > EXPECTED 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) -@q = @db.query('tag:inbox') -print @q.count_threads(),"\n" +puts db.query('tag:inbox').count_threads() EOF -notmuch count --output=threads tag:inbox > EXPECTED -test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "get all tags" +notmuch search --output=tags '*' > EXPECTED test_ruby <<"EOF" -require 'notmuch' -$maildir = ENV['MAIL_DIR'] -if not $maildir then - abort('environment variable MAIL_DIR must be set') +db.all_tags.each do |tag| + puts tag end -@db = Notmuch::Database.new($maildir) -@t = @db.all_tags() -for tag in @t do - print tag,"\n" +EOF + +notmuch config set search.exclude_tags deleted +generate_message '[subject]="Good"' +generate_message '[subject]="Bad"' "[in-reply-to]=\<$gen_msg_id\>" +notmuch new > /dev/null +notmuch tag +deleted id:$gen_msg_id + +test_begin_subtest "omit excluded all" +notmuch search --output=threads --exclude=all tag:inbox > EXPECTED +test_ruby <<"EOF" +q = db.query('tag:inbox') +q.add_tag_exclude('deleted') +q.omit_excluded = Notmuch::EXCLUDE_ALL +q.search_threads.each do |t| + puts 'thread:%s' % t.thread_id end EOF -notmuch search --output=tags '*' > EXPECTED -test_expect_equal_file EXPECTED OUTPUT test_done diff --git a/test/T420-emacs-test-functions.sh b/test/T420-emacs-test-functions.sh index bfc10be3..22e4f01e 100755 --- a/test/T420-emacs-test-functions.sh +++ b/test/T420-emacs-test-functions.sh @@ -2,6 +2,7 @@ test_description="emacs test function sanity" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 test_begin_subtest "emacs test function sanity" test_emacs_expect_t 't' diff --git a/test/T430-emacs-address-cleaning.sh b/test/T430-emacs-address-cleaning.sh index 02d3b411..640bff3f 100755 --- a/test/T430-emacs-address-cleaning.sh +++ b/test/T430-emacs-address-cleaning.sh @@ -2,6 +2,9 @@ test_description="emacs address cleaning" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 + +test_require_emacs test_begin_subtest "notmuch-test-address-clean part 1" test_emacs_expect_t '(notmuch-test-address-cleaning-1)' diff --git a/test/T440-emacs-hello.sh b/test/T440-emacs-hello.sh index d23c1fca..642aa3cc 100755 --- a/test/T440-emacs-hello.sh +++ b/test/T440-emacs-hello.sh @@ -2,9 +2,11 @@ test_description="emacs notmuch-hello view" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output +test_require_emacs add_email_corpus test_begin_subtest "User-defined section with inbox tag" diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index cca56ca3..31be55f8 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -2,9 +2,11 @@ test_description="emacs notmuch-show view" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-show.expected-output +test_require_emacs add_email_corpus test_begin_subtest "Hiding Original Message region at beginning of a message" @@ -189,7 +191,6 @@ test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES E === MESSAGES === This is an error (see *Notmuch errors* for more details) === ERROR === -[XXX] This is an error command: YYY/notmuch_fail show --format\\=sexp --format-version\\=4 --decrypt\\=true --exclude\\=false \\' \\* \\' exit status: 1 diff --git a/test/T455-emacs-charsets.sh b/test/T455-emacs-charsets.sh index cb1297ca..a0f4dc24 100755 --- a/test/T455-emacs-charsets.sh +++ b/test/T455-emacs-charsets.sh @@ -2,11 +2,14 @@ test_description="emacs notmuch-show charset handling" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 UTF8_YEN=$'\xef\xbf\xa5' BIG5_YEN=$'\xa2\x44' +test_require_emacs + # Add four messages with unusual encoding requirements: # # 1) text/plain in quoted-printable big5 diff --git a/test/T460-emacs-tree.sh b/test/T460-emacs-tree.sh index cb2c90b8..dfc69049 100755 --- a/test/T460-emacs-tree.sh +++ b/test/T460-emacs-tree.sh @@ -2,9 +2,11 @@ test_description="emacs tree view interface" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-tree.expected-output +test_require_emacs add_email_corpus test_begin_subtest "Basic notmuch-tree view in emacs" diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh index d1c70cfa..f89755ed 100755 --- a/test/T490-parse-time-string.sh +++ b/test/T490-parse-time-string.sh @@ -4,13 +4,11 @@ test_description="date/time parser module" # Sanity/smoke tests for the date/time parser independent of notmuch -_date () -{ +_date () { date -d "$*" +%s } -_parse_time () -{ +_parse_time () { ${TEST_DIRECTORY}/parse-time --format=%s "$*" } diff --git a/test/T510-thread-replies.sh b/test/T510-thread-replies.sh index 2859d29f..cdb4be44 100755 --- a/test/T510-thread-replies.sh +++ b/test/T510-thread-replies.sh @@ -10,6 +10,7 @@ test_description='test of proper handling of in-reply-to and references headers' # non-RFC-compliant headers' . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 test_begin_subtest "Use References when In-Reply-To is broken" add_message '[id]="foo@one.com"' \ diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 745e1bb4..bc7298f8 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -5,6 +5,25 @@ test_description="library config API" add_email_corpus +_libconfig_sanitize() { + ${NOTMUCH_PYTHON} /dev/fd/3 3<<'EOF' +import os, sys, pwd, socket + +pw = pwd.getpwuid(os.getuid()) +user = pw.pw_name +name = pw.pw_gecos.partition(",")[0] +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0, + socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3] +for l in sys.stdin: + if l[:4] == "08: ": + l = l.replace(user, "USERNAME", 1).replace("@" + fqdn, "@FQDN", 1) + l = l.replace(".(none)", "", 1).replace(".localdomain", "", 1) + elif l[:4] == "10: ": + l = l.replace("'" + name, "'USER_FULL_NAME", 1) + sys.stdout.write(l) +EOF +} + cat < c_head #include #include @@ -380,26 +399,26 @@ cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} '' %NULL% key < NOTMUCH_CONFIG_LAST; key = (notmuch_config_key_t)(key + 1)) { const char *val = notmuch_config_get (db, key); - printf("%s\n", val ? val : "NULL" ); + printf("%02d: '%s'\n", key, val ? val : "NULL" ); } } EOF -notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean +_libconfig_sanitize < OUTPUT > OUTPUT.clean cat <<'EOF' >EXPECTED == stdout == -MAIL_DIR -MAIL_DIR -MAIL_DIR/.notmuch/hooks -MAIL_DIR/.notmuch/backups - -unread;inbox - -true -USERNAME@FQDN -NULL -USER_FULL_NAME +00: 'MAIL_DIR' +01: 'MAIL_DIR' +02: 'MAIL_DIR/.notmuch/hooks' +03: 'MAIL_DIR/.notmuch/backups' +04: '' +05: 'unread;inbox' +06: '' +07: 'true' +08: 'USERNAME@FQDN' +09: 'NULL' +10: 'USER_FULL_NAME' == stderr == EOF unset MAILDIR @@ -694,23 +713,23 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} %NULL% %NULL% key < NOTMUCH_CONFIG_LAST; key = (notmuch_config_key_t)(key + 1)) { const char *val = notmuch_config_get (db, key); - printf("%s\n", val ? val : "NULL" ); + printf("%x: '%s'\n", key, val ? val : "NULL" ); } } EOF cat <<'EOF' >EXPECTED == stdout == -MAIL_DIR -MAIL_DIR -MAIL_DIR/.notmuch/hooks -MAIL_DIR/.notmuch/backups -foo;bar;fub -unread;inbox -sekrit_junk -true -test_suite@notmuchmail.org -test_suite_other@notmuchmail.org;test_suite@otherdomain.org -Notmuch Test Suite +0: 'MAIL_DIR' +1: 'MAIL_DIR' +2: 'MAIL_DIR/.notmuch/hooks' +3: 'MAIL_DIR/.notmuch/backups' +4: 'foo;bar;fub' +5: 'unread;inbox' +6: 'sekrit_junk' +7: 'true' +8: 'test_suite@notmuchmail.org' +9: 'test_suite_other@notmuchmail.org;test_suite@otherdomain.org' +a: 'Notmuch Test Suite' == stderr == EOF test_expect_equal_file EXPECTED OUTPUT @@ -723,25 +742,26 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} /nonexistent %NULL% key < NOTMUCH_CONFIG_LAST; key = (notmuch_config_key_t)(key + 1)) { const char *val = notmuch_config_get (db, key); - printf("%s\n", val ? val : "NULL" ); + printf("%02d: '%s'\n", key, val ? val : "NULL" ); } } EOF -notmuch_passwd_sanitize < OUTPUT > OUTPUT.clean +_libconfig_sanitize < OUTPUT > OUTPUT.clean + cat <<'EOF' >EXPECTED == stdout == -MAIL_DIR -MAIL_DIR -MAIL_DIR/.notmuch/hooks -MAIL_DIR/.notmuch/backups - -unread;inbox - -true -USERNAME@FQDN -NULL -USER_FULL_NAME +00: 'MAIL_DIR' +01: 'MAIL_DIR' +02: 'MAIL_DIR/.notmuch/hooks' +03: 'MAIL_DIR/.notmuch/backups' +04: '' +05: 'unread;inbox' +06: '' +07: 'true' +08: 'USERNAME@FQDN' +09: 'NULL' +10: 'USER_FULL_NAME' == stderr == EOF test_expect_equal_file EXPECTED OUTPUT.clean diff --git a/test/T590-thread-breakage.sh b/test/T590-thread-breakage.sh index aeb82cf4..92a70e3e 100755 --- a/test/T590-thread-breakage.sh +++ b/test/T590-thread-breakage.sh @@ -21,7 +21,7 @@ test_description='thread breakage during reindexing' . $(dirname "$0")/test-lib.sh || exit 1 -message_a() { +message_a () { mkdir -p ${MAIL_DIR}/cur cat > ${MAIL_DIR}/cur/a < ${MAIL_DIR}/cur/b < initial-threads -notmuch search --output=messages '*' > initial-message-ids +notmuch search '*' 2>1 | notmuch_search_sanitize > initial-threads +notmuch search --output=messages '*' 2>/dev/null > initial-message-ids notmuch dump > initial-dump test_begin_subtest 'reindex preserves threads' @@ -83,4 +83,11 @@ notmuch reindex '*' notmuch search '*' | notmuch_search_sanitize > OUTPUT test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "reindex after removing corpus" +tar cf backup.tar mail/cur +find mail/cur -type f -delete +test_expect_success "notmuch reindex '*'" +tar xf backup.tar + test_done diff --git a/test/T720-emacs-attachment-warnings.sh b/test/T720-emacs-attachment-warnings.sh index c8d2bcc2..4e8c5d26 100755 --- a/test/T720-emacs-attachment-warnings.sh +++ b/test/T720-emacs-attachment-warnings.sh @@ -2,6 +2,9 @@ test_description="emacs attachment warnings" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 + +test_require_emacs test_begin_subtest "notmuch-test-attachment-warning part 1" test_emacs_expect_t '(notmuch-test-attachment-warning-1)' diff --git a/test/T730-emacs-forwarding.sh b/test/T730-emacs-forwarding.sh index 45e61568..378067ed 100755 --- a/test/T730-emacs-forwarding.sh +++ b/test/T730-emacs-forwarding.sh @@ -2,6 +2,9 @@ test_description="emacs forwarding" . $(dirname "$0")/test-lib.sh || exit 1 +. $(dirname "$0")/test-lib-emacs.sh || exit 1 + +test_require_emacs test_begin_subtest "Forward setting the correct references header" # Check that, when forwarding a message, the new message has diff --git a/test/T750-user-header.sh b/test/T750-user-header.sh index 05f80885..03c43656 100755 --- a/test/T750-user-header.sh +++ b/test/T750-user-header.sh @@ -4,8 +4,8 @@ test_description='indexing user specified headers' add_email_corpus -notmuch search '*' | notmuch_search_sanitize > initial-threads -notmuch search --output=messages '*' > initial-message-ids +notmuch search '*' 2>1 | notmuch_search_sanitize > initial-threads +notmuch search --output=messages '*' 2>/dev/null > initial-message-ids notmuch dump > initial-dump test_begin_subtest "adding illegal prefix name, bad utf8" diff --git a/test/export-dirs.sh b/test/export-dirs.sh index 0578b1e5..0a048e1f 100644 --- a/test/export-dirs.sh +++ b/test/export-dirs.sh @@ -9,8 +9,7 @@ if [[ -z "${NOTMUCH_SRCDIR}" ]]; then export NOTMUCH_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)" fi -find_builddir() -{ +find_builddir () { local dir="$1" while [[ -n "$dir" ]] && [[ "$dir" != "/" ]]; do diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh index 2f7950ac..ebbf4cdf 100644 --- a/test/test-lib-common.sh +++ b/test/test-lib-common.sh @@ -105,8 +105,7 @@ fi gen_msg_cnt=0 gen_msg_filename="" gen_msg_id="" -generate_message () -{ +generate_message () { # This is our (bash-specific) magic for doing named parameters local -A template="($@)" local additional_headers @@ -225,8 +224,7 @@ EOF # # All of the arguments and return values supported by generate_message # are also supported here, so see that function for details. -add_message () -{ +add_message () { generate_message "$@" && notmuch new > /dev/null } diff --git a/test/test-lib-emacs.sh b/test/test-lib-emacs.sh new file mode 100644 index 00000000..dde32177 --- /dev/null +++ b/test/test-lib-emacs.sh @@ -0,0 +1,209 @@ +# +# Copyright (c) 2010-2020 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 +# the Free Software Foundation, either version 2 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/ . + +test_require_emacs () { + local ret=0 + test_require_external_prereq "$TEST_EMACS" || ret=1 + test_require_external_prereq "$TEST_EMACSCLIENT" || ret=1 + test_require_external_prereq dtach || ret=1 + return $ret +} + +# Deliver a message with emacs and add it to the database +# +# Uses emacs to generate and deliver a message to the mail store. +# Accepts arbitrary extra emacs/elisp functions to modify the message +# before sending, which is useful to doing things like attaching files +# to the message and encrypting/signing. +emacs_deliver_message () { + local subject body smtp_dummy_pid smtp_dummy_port + subject="$1" + body="$2" + shift 2 + # before we can send a message, we have to prepare the FCC maildir + mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} + # eval'ing smtp-dummy --background will set smtp_dummy_pid and -_port + smtp_dummy_pid= smtp_dummy_port= + eval `$TEST_DIRECTORY/smtp-dummy --background sent_message` + test -n "$smtp_dummy_pid" || return 1 + test -n "$smtp_dummy_port" || return 1 + + test_emacs \ + "(let ((message-send-mail-function 'message-smtpmail-send-it) + (mail-host-address \"example.com\") + (smtpmail-smtp-server \"localhost\") + (smtpmail-smtp-service \"${smtp_dummy_port}\")) + (notmuch-mua-mail) + (message-goto-to) + (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") + (message-goto-subject) + (insert \"${subject}\") + (message-goto-body) + (insert \"${body}\") + $* + (notmuch-mua-send-and-exit))" + + # In case message was sent properly, client waits for confirmation + # before exiting and resuming control here; therefore making sure + # that server exits by sending (KILL) signal to it is safe. + kill -9 $smtp_dummy_pid + notmuch new >/dev/null +} + +# Pretend to deliver a message with emacs. Really save it to a file +# and add it to the database +# +# Uses emacs to generate and deliver a message to the mail store. +# Accepts arbitrary extra emacs/elisp functions to modify the message +# before sending, which is useful to doing things like attaching files +# to the message and encrypting/signing. +# +# If any GNU-style long-arguments (like --quiet or --decrypt=true) are +# at the head of the argument list, they are sent directly to "notmuch +# new" after message delivery +emacs_fcc_message () { + local nmn_args subject body + nmn_args='' + while [[ "$1" =~ ^-- ]]; do + nmn_args="$nmn_args $1" + shift + done + subject="$1" + body="$2" + shift 2 + # before we can send a message, we have to prepare the FCC maildir + mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} + + test_emacs \ + "(let ((message-send-mail-function (lambda () t)) + (mail-host-address \"example.com\")) + (notmuch-mua-mail) + (message-goto-to) + (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") + (message-goto-subject) + (insert \"${subject}\") + (message-goto-body) + (insert \"${body}\") + $* + (let ((mml-secure-smime-sign-with-sender t) + (mml-secure-openpgp-sign-with-sender t)) + (notmuch-mua-send-and-exit)))" || return 1 + notmuch new $nmn_args >/dev/null +} + +test_emacs_expect_t () { + local result + test "$#" = 1 || + error "bug in the test script: not 1 parameter to test_emacs_expect_t" + if [ -z "$inside_subtest" ]; then + error "bug in the test script: test_emacs_expect_t without test_begin_subtest" + fi + + # Run the test. + if ! test_skip "$test_subtest_name" + then + test_emacs "(notmuch-test-run $1)" >/dev/null + + # Restore state after the test. + exec 1>&6 2>&7 # Restore stdout and stderr + inside_subtest= + + # test_emacs may update missing external prerequisites + test_check_missing_external_prereqs_ "$test_subtest_name" && return + + # Report success/failure. + result=$(cat OUTPUT) + if [ "$result" = t ] + then + test_ok_ + else + test_failure_ "${result}" + fi + else + # Restore state after the (non) test. + exec 1>&6 2>&7 # Restore stdout and stderr + inside_subtest= + fi +} + +emacs_generate_script () { + # Construct a little test script here for the benefit of the user, + # (who can easily run "run_emacs" to get the same emacs environment + # for investigating any failures). + cat <"$TMP_DIRECTORY/run_emacs" +#!/bin/sh +export PATH=$PATH +export NOTMUCH_CONFIG=$NOTMUCH_CONFIG + +# Here's what we are using here: +# +# --quick Use minimal customization. This implies --no-init-file, +# --no-site-file and (emacs 24) --no-site-lisp +# +# --directory Ensure that the local elisp sources are found +# +# --load Force loading of notmuch.el and test-lib.el + +exec ${TEST_EMACS} --quick \ + --directory "$NOTMUCH_BUILDDIR/emacs" --load notmuch.el \ + --directory "$NOTMUCH_SRCDIR/test" --load test-lib.el \ + "\$@" +EOF + chmod a+x "$TMP_DIRECTORY/run_emacs" +} + +test_emacs () { + # test dependencies beforehand to avoid the waiting loop below + test_require_emacs || return + + if [ -z "$EMACS_SERVER" ]; then + emacs_tests="$NOTMUCH_SRCDIR/test/${this_test_bare}.el" + if [ -f "$emacs_tests" ]; then + load_emacs_tests="--eval '(load \"$emacs_tests\")'" + else + load_emacs_tests= + fi + server_name="notmuch-test-suite-$$" + # start a detached session with an emacs server + # user's TERM (or 'vt100' in case user's TERM is known dumb + # or unknown) is given to dtach which assumes a minimally + # VT100-compatible terminal -- and emacs inherits that + TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \ + sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \ + --no-window-system \ + $load_emacs_tests \ + --eval '(setq server-name \"$server_name\")' \ + --eval '(server-start)' \ + --eval '(orphan-watchdog $$)'" || return + EMACS_SERVER="$server_name" + # wait until the emacs server is up + until test_emacs '()' >/dev/null 2>/dev/null; do + sleep 1 + done + fi + + # Clear test-output output file. Most Emacs tests end with a + # call to (test-output). If the test code fails with an + # exception before this call, the output file won't get + # updated. Since we don't want to compare against an output + # file from another test, so start out with an empty file. + rm -f OUTPUT + touch OUTPUT + + ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(notmuch-test-progn $*)" +} + +emacs_generate_script diff --git a/test/test-lib.sh b/test/test-lib.sh index 4c9f2a21..0bca76df 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -112,9 +112,9 @@ unset ALTERNATE_EDITOR # for reproducibility unset EMAIL +unset NAME -add_gnupg_home () -{ +add_gnupg_home () { [ -e "${GNUPGHOME}/gpg.conf" ] && return _gnupg_exit () { gpgconf --kill all 2>/dev/null || true; } at_exit_function _gnupg_exit @@ -134,8 +134,7 @@ add_gnupg_home () printf '%s:6:\n' "$FINGERPRINT" | gpg --quiet --batch --no-tty --import-ownertrust } -add_gpgsm_home () -{ +add_gpgsm_home () { local fpr [ -e "$GNUPGHOME/gpgsm.conf" ] && return _gnupg_exit () { gpgconf --kill all 2>/dev/null || true; } @@ -194,56 +193,53 @@ do done if test -n "$debug"; then - print_subtest () { - printf " %-4s" "[$((test_count - 1))]" - } + fmt_subtest () { + printf -v $1 " %-4s" "[$((test_count - 1))]" + } else - print_subtest () { - true - } + fmt_subtest () { + printf -v $1 '' + } fi test -n "$COLORS_WITHOUT_TTY" || [ -t 1 ] || color= -if [ -n "$color" ] && [ "$ORIGINAL_TERM" != 'dumb' ] && ( - TERM=$ORIGINAL_TERM && - export TERM && - tput bold - tput setaf - tput sgr0 - ) >/dev/null 2>&1 +if [ -n "$color" ] && [ "$ORIGINAL_TERM" != 'dumb' ] && + tput -T "$ORIGINAL_TERM" -S <<<$'bold\nsetaf\nsgr0\n' >/dev/null 2>&1 then color=t else color= fi -if test -n "$color"; then +if test -n "$color" +then + # _tput run in subshell (``) only + _tput () { exec tput -T "$ORIGINAL_TERM" "$@"; } + unset BOLD RED GREEN BROWN SGR0 say_color () { - ( - TERM=$ORIGINAL_TERM - export TERM case "$1" in - error) tput bold; tput setaf 1;; # bold red - skip) tput bold; tput setaf 2;; # bold green - pass) tput setaf 2;; # green - info) tput setaf 3;; # brown - *) test -n "$quiet" && return;; + error) b=${BOLD=`_tput bold`} + c=${RED=`_tput setaf 1`} ;; # bold red + skip) b=${BOLD=`_tput bold`} + c=${GREEN=`_tput setaf 2`} ;; # bold green + pass) b= c=${GREEN=`_tput setaf 2`} ;; # green + info) b= c=${BROWN=`_tput setaf 3`} ;; # brown + *) b= c=; test -n "$quiet" && return ;; esac - shift - printf " " - printf "$@" - tput sgr0 - print_subtest - ) + f=$2 + shift 2 + sgr0=${SGR0=`_tput sgr0`} + fmt_subtest st + printf " ${b}${c}${f}${sgr0}${st}" "$@" } else say_color() { test -z "$1" && test -n "$quiet" && return - shift - printf " " - printf "$@" - print_subtest + f=$2 + shift 2 + fmt_subtest st + printf " ${f}${st}" "$@" } fi @@ -267,8 +263,7 @@ then fi test_description_printed= -print_test_description () -{ +print_test_description () { test -z "$test_description_printed" || return 0 echo echo $this_test: "Testing ${test_description}" @@ -342,90 +337,6 @@ export GNUPGHOME="${TEST_TMPDIR}/gnupg" trap 'trap_exit' EXIT trap 'trap_signal' HUP INT TERM -# Deliver a message with emacs and add it to the database -# -# Uses emacs to generate and deliver a message to the mail store. -# Accepts arbitrary extra emacs/elisp functions to modify the message -# before sending, which is useful to doing things like attaching files -# to the message and encrypting/signing. -emacs_deliver_message () -{ - local subject body smtp_dummy_pid smtp_dummy_port - subject="$1" - body="$2" - shift 2 - # before we can send a message, we have to prepare the FCC maildir - mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} - # eval'ing smtp-dummy --background will set smtp_dummy_pid and -_port - smtp_dummy_pid= smtp_dummy_port= - eval `$TEST_DIRECTORY/smtp-dummy --background sent_message` - test -n "$smtp_dummy_pid" || return 1 - test -n "$smtp_dummy_port" || return 1 - - test_emacs \ - "(let ((message-send-mail-function 'message-smtpmail-send-it) - (mail-host-address \"example.com\") - (smtpmail-smtp-server \"localhost\") - (smtpmail-smtp-service \"${smtp_dummy_port}\")) - (notmuch-mua-mail) - (message-goto-to) - (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") - (message-goto-subject) - (insert \"${subject}\") - (message-goto-body) - (insert \"${body}\") - $* - (notmuch-mua-send-and-exit))" - - # In case message was sent properly, client waits for confirmation - # before exiting and resuming control here; therefore making sure - # that server exits by sending (KILL) signal to it is safe. - kill -9 $smtp_dummy_pid - notmuch new >/dev/null -} - -# Pretend to deliver a message with emacs. Really save it to a file -# and add it to the database -# -# Uses emacs to generate and deliver a message to the mail store. -# Accepts arbitrary extra emacs/elisp functions to modify the message -# before sending, which is useful to doing things like attaching files -# to the message and encrypting/signing. -# -# If any GNU-style long-arguments (like --quiet or --decrypt=true) are -# at the head of the argument list, they are sent directly to "notmuch -# new" after message delivery -emacs_fcc_message () -{ - local nmn_args subject body - nmn_args='' - while [[ "$1" =~ ^-- ]]; do - nmn_args="$nmn_args $1" - shift - done - subject="$1" - body="$2" - shift 2 - # before we can send a message, we have to prepare the FCC maildir - mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} - - test_emacs \ - "(let ((message-send-mail-function (lambda () t)) - (mail-host-address \"example.com\")) - (notmuch-mua-mail) - (message-goto-to) - (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") - (message-goto-subject) - (insert \"${subject}\") - (message-goto-body) - (insert \"${body}\") - $* - (let ((mml-secure-smime-sign-with-sender t) - (mml-secure-openpgp-sign-with-sender t)) - (notmuch-mua-send-and-exit)))" || return 1 - notmuch new $nmn_args >/dev/null -} - # Add an existing, fixed corpus of email to the database. # # $1 is the corpus dir under corpora to add, using "default" if unset. @@ -434,8 +345,7 @@ emacs_fcc_message () # history of the notmuch mailing list, which allows for reliably # testing commands that need to operate on a not-totally-trivial # number of messages. -add_email_corpus () -{ +add_email_corpus () { local corpus corpus=${1:-default} @@ -444,8 +354,7 @@ add_email_corpus () notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus" } -test_begin_subtest () -{ +test_begin_subtest () { if [ -n "$inside_subtest" ]; then exec 1>&6 2>&7 # Restore stdout and stderr error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}" @@ -465,8 +374,7 @@ test_begin_subtest () # not accept a test name. Instead, the caller should call # test_begin_subtest before calling this function in order to set the # name. -test_expect_equal () -{ +test_expect_equal () { local output expected testname exec 1>&6 2>&7 # Restore stdout and stderr if [ -z "$inside_subtest" ]; then @@ -492,8 +400,7 @@ test_expect_equal () } # Like test_expect_equal, but takes two filenames. -test_expect_equal_file () -{ +test_expect_equal_file () { local file1 file2 testname basename1 basename2 exec 1>&6 2>&7 # Restore stdout and stderr if [ -z "$inside_subtest" ]; then @@ -574,51 +481,16 @@ test_json_nodes () { fi } -test_emacs_expect_t () { - local result - test "$#" = 1 || - error "bug in the test script: not 1 parameter to test_emacs_expect_t" - if [ -z "$inside_subtest" ]; then - error "bug in the test script: test_emacs_expect_t without test_begin_subtest" - fi - - # Run the test. - if ! test_skip "$test_subtest_name" - then - test_emacs "(notmuch-test-run $1)" >/dev/null - - # Restore state after the test. - exec 1>&6 2>&7 # Restore stdout and stderr - inside_subtest= - - # Report success/failure. - result=$(cat OUTPUT) - if [ "$result" = t ] - then - test_ok_ - else - test_failure_ "${result}" - fi - else - # Restore state after the (non) test. - exec 1>&6 2>&7 # Restore stdout and stderr - inside_subtest= - fi -} - -NOTMUCH_NEW () -{ +NOTMUCH_NEW () { notmuch new "${@}" | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file' } -NOTMUCH_DUMP_TAGS () -{ +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_drop_mail_headers () -{ +notmuch_drop_mail_headers () { $NOTMUCH_PYTHON -c ' import email, sys msg = email.message_from_file(sys.stdin) @@ -627,41 +499,39 @@ print(msg.as_string(False)) ' "$@" } -notmuch_exception_sanitize () -{ +notmuch_debug_sanitize () { + grep -v '^D.:' +} + +notmuch_exception_sanitize () { perl -pe 's/(A Xapian exception occurred at .*[.]cc?):([0-9]*)/\1:XXX/' } -notmuch_search_sanitize () -{ - perl -pe 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/' +notmuch_search_sanitize () { + notmuch_debug_sanitize | perl -pe 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/' } -notmuch_search_files_sanitize () -{ +notmuch_search_files_sanitize () { notmuch_dir_sanitize } -notmuch_dir_sanitize () -{ +notmuch_dir_sanitize () { sed -e "s,$MAIL_DIR,MAIL_DIR," -e "s,${PWD},CWD,g" "$@" } NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,' -notmuch_show_sanitize () -{ +notmuch_show_sanitize () { sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH" } -notmuch_show_sanitize_all () -{ +notmuch_show_sanitize_all () { + notmuch_debug_sanitize | \ sed \ -e 's| filename:.*| filename:XXXXX|' \ -e 's| id:[^ ]* | id:XXXXX |' | \ notmuch_date_sanitize } -notmuch_json_show_sanitize () -{ +notmuch_json_show_sanitize () { sed \ -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \ -e 's|"Date": "Fri, 05 Jan 2001 [^"]*0000"|"Date": "GENERATED_DATE"|g' \ @@ -671,58 +541,37 @@ notmuch_json_show_sanitize () -e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g' } -notmuch_emacs_error_sanitize () -{ +notmuch_emacs_error_sanitize () { local command command=$1 shift for file in "$@"; do echo "=== $file ===" - cat "$file" + notmuch_debug_sanitize < "$file" done | sed \ - -e 's/^\[.*\]$/[XXX]/' \ + -e '/^$/d' \ + -e '/^\[.*\]$/d' \ -e "s|^\(command: \)\{0,1\}/.*/$command|\1YYY/$command|" } -notmuch_date_sanitize () -{ +notmuch_date_sanitize () { sed \ -e 's/^Date: Fri, 05 Jan 2001 .*0000/Date: GENERATED_DATE/' } -notmuch_uuid_sanitize () -{ +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 () -{ +notmuch_built_with_sanitize () { sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/' } -notmuch_passwd_sanitize() -{ - ${NOTMUCH_PYTHON} -c' -import os, sys, pwd, socket - -pw = pwd.getpwuid(os.getuid()) -user = pw.pw_name -name = pw.pw_gecos.partition(",")[0] -fqdn = socket.getfqdn() - -for l in sys.stdin: - l = l.replace(user, "USERNAME").replace(fqdn, "FQDN").replace(".(none)","").replace(name, "USER_FULL_NAME") - sys.stdout.write(l) -' -} - -notmuch_config_sanitize () -{ +notmuch_config_sanitize () { notmuch_dir_sanitize | notmuch_built_with_sanitize } -notmuch_show_part () -{ +notmuch_show_part () { awk '/^\014part}/{ f=0 }; { if (f) { print $0 } } /^\014part{ ID: '"$1"'/{ f=1 }' } @@ -913,7 +762,7 @@ test_expect_success () { test_run_ "$1" run_ret="$?" # test_run_ may update missing external prerequisites - test_check_missing_external_prereqs_ "$@" || + test_check_missing_external_prereqs_ "$test_subtest_name" || if [ "$run_ret" = 0 -a "$eval_ret" = 0 ] then test_ok_ @@ -937,7 +786,7 @@ test_expect_code () { test_run_ "$2" run_ret="$?" # test_run_ may update missing external prerequisites, - test_check_missing_external_prereqs_ "$@" || + test_check_missing_external_prereqs_ "$test_subtest_name" || if [ "$run_ret" = 0 -a "$eval_ret" = "$1" ] then test_ok_ @@ -977,7 +826,7 @@ test_must_fail () { # - cmp's output is not nearly as easy to read as diff -u # - not all diff versions understand "-u" -test_cmp() { +test_cmp () { $GIT_TEST_CMP "$@" } @@ -1031,88 +880,13 @@ test_done () { fi } -emacs_generate_script () { - # Construct a little test script here for the benefit of the user, - # (who can easily run "run_emacs" to get the same emacs environment - # for investigating any failures). - cat <"$TMP_DIRECTORY/run_emacs" -#!/bin/sh -export PATH=$PATH -export NOTMUCH_CONFIG=$NOTMUCH_CONFIG - -# Here's what we are using here: -# -# --quick Use minimal customization. This implies --no-init-file, -# --no-site-file and (emacs 24) --no-site-lisp -# -# --directory Ensure that the local elisp sources are found -# -# --load Force loading of notmuch.el and test-lib.el - -exec ${TEST_EMACS} --quick \ - --directory "$NOTMUCH_BUILDDIR/emacs" --load notmuch.el \ - --directory "$NOTMUCH_SRCDIR/test" --load test-lib.el \ - "\$@" -EOF - chmod a+x "$TMP_DIRECTORY/run_emacs" -} - -test_emacs () { - # test dependencies beforehand to avoid the waiting loop below - missing_dependencies= - test_require_external_prereq dtach || missing_dependencies=1 - test_require_external_prereq emacs || missing_dependencies=1 - test_require_external_prereq ${TEST_EMACSCLIENT} || missing_dependencies=1 - test -z "$missing_dependencies" || return - - if [ -z "$EMACS_SERVER" ]; then - emacs_tests="$NOTMUCH_SRCDIR/test/${this_test_bare}.el" - if [ -f "$emacs_tests" ]; then - load_emacs_tests="--eval '(load \"$emacs_tests\")'" - else - load_emacs_tests= - fi - server_name="notmuch-test-suite-$$" - # start a detached session with an emacs server - # user's TERM (or 'vt100' in case user's TERM is known dumb - # or unknown) is given to dtach which assumes a minimally - # VT100-compatible terminal -- and emacs inherits that - TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \ - sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \ - --no-window-system \ - $load_emacs_tests \ - --eval '(setq server-name \"$server_name\")' \ - --eval '(server-start)' \ - --eval '(orphan-watchdog $$)'" || return - EMACS_SERVER="$server_name" - # wait until the emacs server is up - until test_emacs '()' >/dev/null 2>/dev/null; do - sleep 1 - done - fi - - # Clear test-output output file. Most Emacs tests end with a - # call to (test-output). If the test code fails with an - # exception before this call, the output file won't get - # updated. Since we don't want to compare against an output - # file from another test, so start out with an empty file. - rm -f OUTPUT - touch OUTPUT - - ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(notmuch-test-progn $*)" -} - -test_python() { +test_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="$NOTMUCH_SRCDIR/bindings/python${PYTHONPATH:+:$PYTHONPATH}" \ $NOTMUCH_PYTHON -B - > OUTPUT } -test_ruby() { - MAIL_DIR=$MAIL_DIR $NOTMUCH_RUBY -I "$NOTMUCH_BUILDDIR/bindings/ruby"> OUTPUT -} - test_C () { local exec_file test_file exec_file="test${test_count}" @@ -1122,7 +896,7 @@ test_C () { echo "== stdout ==" > OUTPUT.stdout echo "== stderr ==" > OUTPUT.stderr ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr - notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr | notmuch_exception_sanitize > OUTPUT + notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr | notmuch_exception_sanitize | notmuch_debug_sanitize > OUTPUT } make_shim () { @@ -1195,9 +969,6 @@ TEST_DIRECTORY=$NOTMUCH_BUILDDIR/test . "$NOTMUCH_SRCDIR/test/test-lib-common.sh" || exit 1 -emacs_generate_script - - # Use -P to resolve symlinks in our working directory so that the cwd # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$TMP_DIRECTORY" || error "Cannot set up test environment" diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 541698cd..c1c2f63d 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -317,6 +317,9 @@ ruby << EOF $curbuf.render do |b| q = $curbuf.query(get_cur_view) q.sort = Notmuch::SORT_OLDEST_FIRST + $exclude_tags.each { |t| + q.add_tag_exclude(t) + } msgs = q.search_messages msgs.each do |msg| m = Mail.read(msg.filename)