[PATCH v2 2/2] lib: modify notmuch.h for automatic document generation

2014-01-01 Thread Jani Nikula
Minimal changes to produce a sensible result.
---
 lib/notmuch.h | 443 +++---
 1 file changed, 302 insertions(+), 141 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index d30768d..02604c5 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -18,9 +18,19 @@
  * Author: Carl Worth 
  */

+/**
+ * @defgroup notmuch The notmuch API
+ *
+ * Not much of an email library, (just index and search)
+ *
+ * @{
+ */
+
 #ifndef NOTMUCH_H
 #define NOTMUCH_H

+#ifndef __DOXYGEN__
+
 #ifdef  __cplusplus
 # define NOTMUCH_BEGIN_DECLS  extern "C" {
 # define NOTMUCH_END_DECLS}
@@ -49,19 +59,28 @@ NOTMUCH_BEGIN_DECLS
 #define LIBNOTMUCH_MINOR_VERSION   1
 #define LIBNOTMUCH_MICRO_VERSION   0

-/*
+#endif /* __DOXYGEN__ */
+
+/**
  * Check the version of the notmuch library being compiled against.
  *
  * Return true if the library being compiled against is of the
  * specified version or above. For example:
  *
+ * @code
  * #if LIBNOTMUCH_CHECK_VERSION(3, 1, 0)
  * (code requiring libnotmuch 3.1.0 or above)
  * #endif
+ * @endcode
+ *
+ * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; to
+ * check for versions prior to that, use:
  *
- * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; you
- * can use #if !defined(NOTMUCH_CHECK_VERSION) to check for versions
- * prior to that.
+ * @code
+ * #if !defined(NOTMUCH_CHECK_VERSION)
+ * (code requiring libnotmuch prior to 3.1.0)
+ * #endif
+ * @endcode
  */
 #define LIBNOTMUCH_CHECK_VERSION (major, minor, micro) \
 (LIBNOTMUCH_MAJOR_VERSION > (major) || 
\
@@ -69,72 +88,86 @@ NOTMUCH_BEGIN_DECLS
  (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION == 
(minor) && \
   LIBNOTMUCH_MICRO_VERSION >= (micro)))

+/**
+ * Notmuch boolean type.
+ */
 typedef int notmuch_bool_t;

-/* Status codes used for the return values of most functions.
+/**
+ * Status codes used for the return values of most functions.
  *
  * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
- * completed without error. Any other value indicates an error as
- * follows:
- *
- * NOTMUCH_STATUS_SUCCESS: No error occurred.
- *
- * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory
- *
- * XXX: We don't really want to expose this lame XAPIAN_EXCEPTION
- * value. Instead we should map to things like DATABASE_LOCKED or
- * whatever.
- *
- * NOTMUCH_STATUS_READ_ONLY_DATABASE: An attempt was made to write to
- * a database opened in read-only mode.
- *
- * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
- *
- * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to read or
- * write to a file (this could be file not found, permission
- * denied, etc.)
- *
- * NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
- * appear to be an email message.
- *
- * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: A file contains a message ID
- * that is identical to a message already in the database.
- *
- * NOTMUCH_STATUS_NULL_POINTER: The user erroneously passed a NULL
- * pointer to a notmuch function.
- *
- * NOTMUCH_STATUS_TAG_TOO_LONG: A tag value is too long (exceeds
- * NOTMUCH_TAG_MAX)
- *
- * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: The notmuch_message_thaw
- * function has been called more times than notmuch_message_freeze.
- *
- * NOTMUCH_STATUS_UNBALANCED_ATOMIC: notmuch_database_end_atomic has
- * been called more times than notmuch_database_begin_atomic.
- *
- * And finally:
- *
- * NOTMUCH_STATUS_LAST_STATUS: Not an actual status value. Just a way
- * to find out how many valid status values there are.
+ * completed without error. Any other value indicates an error.
  */
 typedef enum _notmuch_status {
+/**
+ * No error occurred.
+ */
 NOTMUCH_STATUS_SUCCESS = 0,
+/**
+ * Out of memory.
+ */
 NOTMUCH_STATUS_OUT_OF_MEMORY,
+/**
+ * An attempt was made to write to a database opened in read-only
+ * mode.
+ */
 NOTMUCH_STATUS_READ_ONLY_DATABASE,
+/**
+ * A Xapian exception occurred.
+ */
 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
+/**
+ * An error occurred trying to read or write to a file (this could
+ * be file not found, permission denied, etc.)
+ *
+ * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
+ * value. Instead we should map to things like DATABASE_LOCKED or
+ * whatever.
+ */
 NOTMUCH_STATUS_FILE_ERROR,
+/**
+ * A file was presented that doesn't appear to be an email
+ * message.
+ */
 NOTMUCH_STATUS_FILE_NOT_EMAIL,
+/**
+ * A file contains a message ID that is identical to a message
+ * already in the database.
+ */
 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
+/**
+ * The user erroneously passed a NULL pointer to a notmuch
+ * function.
+ */
 NOTMUCH_STATUS_NULL_POINTER,
+/**
+ * A tag value is too 

[PATCH v2 1/2] devel: add doxygen configuration file

2014-01-01 Thread Jani Nikula
This is a pretty basic config to get started, generated using 'doxygen
-s -g' and mildly tweaked.

To generate the library man page man/man3/notmuch.3 from lib/notmuch.h
use:

$ doxygen devel/doxygen.cfg
---
 devel/doxygen.cfg | 304 ++
 1 file changed, 304 insertions(+)
 create mode 100644 devel/doxygen.cfg

diff --git a/devel/doxygen.cfg b/devel/doxygen.cfg
new file mode 100644
index 000..65d5fb5
--- /dev/null
+++ b/devel/doxygen.cfg
@@ -0,0 +1,304 @@
+# Doxyfile 1.8.4
+
+#---
+# Project related configuration options
+#---
+DOXYFILE_ENCODING  = UTF-8
+PROJECT_NAME   = "Notmuch 0.17"
+PROJECT_NUMBER =
+PROJECT_BRIEF  =
+PROJECT_LOGO   =
+OUTPUT_DIRECTORY   =
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE= English
+BRIEF_MEMBER_DESC  = YES
+REPEAT_BRIEF   = YES
+ABBREVIATE_BRIEF   =
+ALWAYS_DETAILED_SEC= NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES= NO
+STRIP_FROM_PATH=
+STRIP_FROM_INC_PATH=
+SHORT_NAMES= NO
+JAVADOC_AUTOBRIEF  = YES
+QT_AUTOBRIEF   = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS   = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE   = 8
+ALIASES=
+TCL_SUBST  =
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+OPTIMIZE_FOR_FORTRAN   = NO
+OPTIMIZE_OUTPUT_VHDL   = NO
+EXTENSION_MAPPING  =
+MARKDOWN_SUPPORT   = YES
+AUTOLINK_SUPPORT   = YES
+BUILTIN_STL_SUPPORT= NO
+CPP_CLI_SUPPORT= NO
+SIP_SUPPORT= NO
+IDL_PROPERTY_SUPPORT   = YES
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING= YES
+INLINE_GROUPED_CLASSES = NO
+INLINE_SIMPLE_STRUCTS  = NO
+TYPEDEF_HIDES_STRUCT   = YES
+LOOKUP_CACHE_SIZE  = 0
+#---
+# Build related configuration options
+#---
+EXTRACT_ALL= NO
+EXTRACT_PRIVATE= NO
+EXTRACT_PACKAGE= NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+EXTRACT_ANON_NSPACES   = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS  = NO
+INTERNAL_DOCS  = NO
+CASE_SENSE_NAMES   = YES
+HIDE_SCOPE_NAMES   = NO
+SHOW_INCLUDE_FILES = NO
+FORCE_LOCAL_INCLUDES   = NO
+INLINE_INFO= YES
+SORT_MEMBER_DOCS   = NO
+SORT_BRIEF_DOCS= NO
+SORT_MEMBERS_CTORS_1ST = NO
+SORT_GROUP_NAMES   = NO
+SORT_BY_SCOPE_NAME = NO
+STRICT_PROTO_MATCHING  = NO
+GENERATE_TODOLIST  = NO
+GENERATE_TESTLIST  = NO
+GENERATE_BUGLIST   = NO
+GENERATE_DEPRECATEDLIST= NO
+ENABLED_SECTIONS   =
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES= NO
+SHOW_FILES = NO
+SHOW_NAMESPACES= NO
+FILE_VERSION_FILTER=
+LAYOUT_FILE=
+CITE_BIB_FILES =
+#---
+# configuration options related to warning and progress messages
+#---
+QUIET  = YES
+WARNINGS   = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR  = YES
+WARN_NO_PARAMDOC   = NO
+WARN_FORMAT= "$file:$line: $text"
+WARN_LOGFILE   =
+#---
+# configuration options related to the input files
+#---
+INPUT  = lib/notmuch.h
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS  =
+RECURSIVE  = NO
+EXCLUDE=
+EXCLUDE_SYMLINKS   = NO
+EXCLUDE_PATTERNS   =
+EXCLUDE_SYMBOLS=
+EXAMPLE_PATH   =
+EXAMPLE_PATTERNS   =
+EXAMPLE_RECURSIVE  = NO
+IMAGE_PATH =
+INPUT_FILTER   =
+FILTER_PATTERNS=
+FILTER_SOURCE_FILES= NO
+FILTER_SOURCE_PATTERNS =
+USE_MDFILE_AS_MAINPAGE =
+#---
+# configuration options related to source browsing
+#---
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS= YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION= NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS  = NO
+VERBATIM_HEADERS   = NO
+#---
+# configuration options related to the alphabetical class index
+#---
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX= 5
+IGNOR

[PATCH v2 0/2] doxygen generated library reference man page

2014-01-01 Thread Jani Nikula
v2 of id:cover.1385826040.git.jani at nikula.org

Rebase, minor tweaks since v1; the TODO in the referenced message above
is still valid. I suggest we get this merged as a starting point, so we
can collaborate on including a nice API man page (and possibly a HTML
API reference on the web page) for 0.18.

BR,
Jani.


Jani Nikula (2):
  devel: add doxygen configuration file
  lib: modify notmuch.h for automatic document generation

 devel/doxygen.cfg | 304 +
 lib/notmuch.h | 443 +-
 2 files changed, 606 insertions(+), 141 deletions(-)
 create mode 100644 devel/doxygen.cfg

-- 
1.8.5.2



[PATCH 2/2] insert: respect maildir.synchronize_flags

2014-01-01 Thread Tomi Ollila
On Wed, Jan 01 2014, Jani Nikula  wrote:

> Don't synchronize maildir flags if the user doesn't want it.
> ---

Looks good, tests pass.

Tomi


>  notmuch-insert.c | 24 
>  test/insert  |  1 -
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/notmuch-insert.c b/notmuch-insert.c
> index 2207b1e..55384e3 100644
> --- a/notmuch-insert.c
> +++ b/notmuch-insert.c
> @@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout)
>   * The file is renamed to encode notmuch tags as maildir flags. */
>  static void
>  add_file_to_database (notmuch_database_t *notmuch, const char *path,
> -   tag_op_list_t *tag_ops)
> +   tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags)
>  {
>  notmuch_message_t *message;
>  notmuch_status_t status;
> @@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, 
> const char *path,
>  
>  if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
>   /* Don't change tags of an existing message. */
> - status = notmuch_message_tags_to_maildir_flags (message);
> - if (status != NOTMUCH_STATUS_SUCCESS)
> - fprintf (stderr, "Error: failed to sync tags to maildir flags\n");
> + if (synchronize_flags) {
> + status = notmuch_message_tags_to_maildir_flags (message);
> + if (status != NOTMUCH_STATUS_SUCCESS)
> + fprintf (stderr, "Error: failed to sync tags to maildir 
> flags\n");
> + }
>  } else {
> - tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC);
> + tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0;
> +
> + tag_op_list_apply (message, tag_ops, flags);
>  }
>  
>  notmuch_message_destroy (message);
> @@ -335,7 +339,8 @@ add_file_to_database (notmuch_database_t *notmuch, const 
> char *path,
>  
>  static notmuch_bool_t
>  insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
> - const char *dir, tag_op_list_t *tag_ops)
> + const char *dir, tag_op_list_t *tag_ops,
> + notmuch_bool_t synchronize_flags)
>  {
>  char *tmppath;
>  char *newpath;
> @@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, 
> int fdin,
>  
>  /* Even if adding the message to the notmuch database fails,
>   * the message is on disk and we consider the delivery completed. */
> -add_file_to_database (notmuch, newpath, tag_ops);
> +add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags);
>  
>  return TRUE;
>  
> @@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  char *query_string = NULL;
>  const char *folder = NULL;
>  notmuch_bool_t create_folder = FALSE;
> +notmuch_bool_t synchronize_flags;
>  const char *maildir;
>  int opt_index;
>  unsigned int i;
> @@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  
>  db_path = notmuch_config_get_database_path (config);
>  new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
> +synchronize_flags = notmuch_config_get_maildir_synchronize_flags 
> (config);
>  
>  tag_ops = tag_op_list_create (config);
>  if (tag_ops == NULL) {
> @@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
>   return 1;
>  
> -ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);
> +ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops,
> +   synchronize_flags);
>  
>  notmuch_database_destroy (notmuch);
>  
> diff --git a/test/insert b/test/insert
> index 9283e70..e8dc4c0 100755
> --- a/test/insert
> +++ b/test/insert
> @@ -114,7 +114,6 @@ dirname=$(dirname "$output")
>  test_expect_equal "$dirname" "$MAIL_DIR/cur"
>  
>  test_begin_subtest "Insert message with maildir sync off goes to new/"
> -test_subtest_known_broken
>  OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
>  notmuch config set maildir.synchronize_flags false
>  gen_insert_msg
> -- 
> 1.8.5.2
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/1] test: support for generating decreasing dates with bash 4.0 and 4.1

2014-01-01 Thread Tomi Ollila
The printf builtin "%(fmt)T" specifier (which allows time values
to use strftime-like formatting) is introduced in bash 4.2.

Added a new function `secs_to_rfc2822date` which uses the above specifier
with post 4.1 bash and perl(1) construct with pre-4.2 bash.
---
 test/test-lib.sh | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2fcaba6..7d88867 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -272,6 +272,21 @@ remove_cr () {
tr '\015' Q | sed -e 's/Q$//'
 }

+# The printf '%(fmt)T' specifier is bash 4.2+ feature.
+if [[ ${BASH_VERSINFO[0]} -gt 4 || ${BASH_VERSINFO[1]} -ge 2 ]]
+then
+   secs_to_rfc2822date ()
+   {
+   TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" "$1"
+   }
+else
+   secs_to_rfc2822date ()
+   {
+   perl -le 'use POSIX "strftime"; @time = gmtime $ARGV[0];
+   print strftime "%a, %d %b %Y %T +", @time' "$1"
+   }
+fi
+
 # Generate a new message in the mail directory, with a unique message
 # ID and subject. The message is not added to the index.
 #
@@ -373,8 +388,8 @@ generate_message ()
# we use decreasing timestamps here for historical reasons;
# the existing test suite when we converted to unique timestamps just
# happened to have signicantly fewer failures with that choice.
-   template[date]=$(TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" \
-   $((978709437 - gen_msg_cnt)))
+
+   template[date]=$(secs_to_rfc2822date $((978709437 - gen_msg_cnt)))
 fi

 additional_headers=""
-- 
1.8.0



[PATCH 2/2] insert: respect maildir.synchronize_flags

2014-01-01 Thread Jani Nikula
Don't synchronize maildir flags if the user doesn't want it.
---
 notmuch-insert.c | 24 
 test/insert  |  1 -
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 2207b1e..55384e3 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout)
  * The file is renamed to encode notmuch tags as maildir flags. */
 static void
 add_file_to_database (notmuch_database_t *notmuch, const char *path,
- tag_op_list_t *tag_ops)
+ tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags)
 {
 notmuch_message_t *message;
 notmuch_status_t status;
@@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, const 
char *path,

 if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
/* Don't change tags of an existing message. */
-   status = notmuch_message_tags_to_maildir_flags (message);
-   if (status != NOTMUCH_STATUS_SUCCESS)
-   fprintf (stderr, "Error: failed to sync tags to maildir flags\n");
+   if (synchronize_flags) {
+   status = notmuch_message_tags_to_maildir_flags (message);
+   if (status != NOTMUCH_STATUS_SUCCESS)
+   fprintf (stderr, "Error: failed to sync tags to maildir 
flags\n");
+   }
 } else {
-   tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC);
+   tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0;
+
+   tag_op_list_apply (message, tag_ops, flags);
 }

 notmuch_message_destroy (message);
@@ -335,7 +339,8 @@ add_file_to_database (notmuch_database_t *notmuch, const 
char *path,

 static notmuch_bool_t
 insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
-   const char *dir, tag_op_list_t *tag_ops)
+   const char *dir, tag_op_list_t *tag_ops,
+   notmuch_bool_t synchronize_flags)
 {
 char *tmppath;
 char *newpath;
@@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int 
fdin,

 /* Even if adding the message to the notmuch database fails,
  * the message is on disk and we consider the delivery completed. */
-add_file_to_database (notmuch, newpath, tag_ops);
+add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags);

 return TRUE;

@@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
 char *query_string = NULL;
 const char *folder = NULL;
 notmuch_bool_t create_folder = FALSE;
+notmuch_bool_t synchronize_flags;
 const char *maildir;
 int opt_index;
 unsigned int i;
@@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])

 db_path = notmuch_config_get_database_path (config);
 new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
+synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);

 tag_ops = tag_op_list_create (config);
 if (tag_ops == NULL) {
@@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
   NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
return 1;

-ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);
+ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops,
+ synchronize_flags);

 notmuch_database_destroy (notmuch);

diff --git a/test/insert b/test/insert
index 9283e70..e8dc4c0 100755
--- a/test/insert
+++ b/test/insert
@@ -114,7 +114,6 @@ dirname=$(dirname "$output")
 test_expect_equal "$dirname" "$MAIL_DIR/cur"

 test_begin_subtest "Insert message with maildir sync off goes to new/"
-test_subtest_known_broken
 OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
 notmuch config set maildir.synchronize_flags false
 gen_insert_msg
-- 
1.8.5.2



[PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false

2014-01-01 Thread Jani Nikula
Known broken, notmuch insert does not respect the config option.
---
 test/insert | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/test/insert b/test/insert
index 550b413..9283e70 100755
--- a/test/insert
+++ b/test/insert
@@ -113,6 +113,17 @@ output=$(notmuch search --output=files id:$gen_msg_id)
 dirname=$(dirname "$output")
 test_expect_equal "$dirname" "$MAIL_DIR/cur"

+test_begin_subtest "Insert message with maildir sync off goes to new/"
+test_subtest_known_broken
+OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
+notmuch config set maildir.synchronize_flags false
+gen_insert_msg
+notmuch insert +flagged < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+notmuch config set maildir.synchronize_flags $OLDCONFIG
+test_expect_equal "$dirname" "$MAIL_DIR/new"
+
 test_begin_subtest "Insert message into folder"
 gen_insert_msg
 notmuch insert --folder=Drafts < "$gen_msg_filename"
-- 
1.8.5.2



[PATCH 2/2] lib: modify notmuch.h for automatic document generation

2014-01-01 Thread Tomi Ollila
On Sat, Nov 30 2013, Jani Nikula  wrote:

> Minimal changes to produce a sensible result.
> ---

Looks good but does not apply anymore (blame Austin)
Also the doxygen -s -g (+ edits) looks good ;D

Tomi


>  lib/notmuch.h | 436 
> +++---
>  1 file changed, 296 insertions(+), 140 deletions(-)
>
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 7c3a30c..708b603 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -18,9 +18,19 @@
>   * Author: Carl Worth 
>   */
>  
> +/**
> + * @defgroup notmuch The notmuch API
> + *
> + * Not much of an email library, (just index and search)
> + *
> + * @{
> + */
> +
>  #ifndef NOTMUCH_H
>  #define NOTMUCH_H
>  
> +#ifndef __DOXYGEN__
> +
>  #ifdef  __cplusplus
>  # define NOTMUCH_BEGIN_DECLS  extern "C" {
>  # define NOTMUCH_END_DECLS}
> @@ -45,18 +55,20 @@ NOTMUCH_BEGIN_DECLS
>  #define NOTMUCH_MINOR_VERSION17
>  #define NOTMUCH_MICRO_VERSION0
>  
> -/*
> +#endif /* __DOXYGEN__ */
> +
> +/**
>   * Check the version of the notmuch library being compiled against.
>   *
>   * Return true if the library being compiled against is of the
>   * specified version or above. For example:
>   *
> - * #if NOTMUCH_CHECK_VERSION(0, 18, 0)
> + * \#if NOTMUCH_CHECK_VERSION(0, 18, 0)
>   * (code requiring notmuch 0.18 or above)
> - * #endif
> + * \#endif
>   *
>   * NOTMUCH_CHECK_VERSION has been defined since version 0.17.0; you
> - * can use #if !defined(NOTMUCH_CHECK_VERSION) to check for versions
> + * can use \#if !defined(NOTMUCH_CHECK_VERSION) to check for versions
>   * prior to that.
>   */
>  #define NOTMUCH_CHECK_VERSION (major, minor, micro)  \
> @@ -65,80 +77,97 @@ NOTMUCH_BEGIN_DECLS
>   (NOTMUCH_MAJOR_VERSION == (major) && NOTMUCH_MINOR_VERSION == (minor) 
> && \
>NOTMUCH_MICRO_VERSION >= (micro)))
>  
> +/**
> + * Notmuch boolean type.
> + */
>  typedef int notmuch_bool_t;
>  
> -/* Status codes used for the return values of most functions.
> +/**
> + * Status codes used for the return values of most functions.
>   *
>   * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
> - * completed without error. Any other value indicates an error as
> - * follows:
> - *
> - * NOTMUCH_STATUS_SUCCESS: No error occurred.
> - *
> - * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory
> - *
> - * XXX: We don't really want to expose this lame XAPIAN_EXCEPTION
> - * value. Instead we should map to things like DATABASE_LOCKED or
> - * whatever.
> - *
> - * NOTMUCH_STATUS_READ_ONLY_DATABASE: An attempt was made to write to
> - *   a database opened in read-only mode.
> + * completed without error. Any other value indicates an error.
>   *
> - * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
> - *
> - * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to read or
> - *   write to a file (this could be file not found, permission
> - *   denied, etc.)
> - *
> - * NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
> - *   appear to be an email message.
> - *
> - * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: A file contains a message ID
> - *   that is identical to a message already in the database.
> - *
> - * NOTMUCH_STATUS_NULL_POINTER: The user erroneously passed a NULL
> - *   pointer to a notmuch function.
> - *
> - * NOTMUCH_STATUS_TAG_TOO_LONG: A tag value is too long (exceeds
> - *   NOTMUCH_TAG_MAX)
> - *
> - * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: The notmuch_message_thaw
> - *   function has been called more times than notmuch_message_freeze.
> - *
> - * NOTMUCH_STATUS_UNBALANCED_ATOMIC: notmuch_database_end_atomic has
> - *   been called more times than notmuch_database_begin_atomic.
> - *
> - * And finally:
> - *
> - * NOTMUCH_STATUS_LAST_STATUS: Not an actual status value. Just a way
> - *   to find out how many valid status values there are.
>   */
>  typedef enum _notmuch_status {
> +/**
> + * No error occurred.
> + */
>  NOTMUCH_STATUS_SUCCESS = 0,
> +/**
> + * Out of memory.
> + */
>  NOTMUCH_STATUS_OUT_OF_MEMORY,
> +/**
> + * An attempt was made to write to a database opened in read-only
> + * mode.
> + */
>  NOTMUCH_STATUS_READ_ONLY_DATABASE,
> +/**
> + * A Xapian exception occurred.
> + */
>  NOTMUCH_STATUS_XAPIAN_EXCEPTION,
> +/**
> + * An error occurred trying to read or write to a file (this could
> + * be file not found, permission denied, etc.)
> + *
> + * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
> + * value. Instead we should map to things like DATABASE_LOCKED or
> + * whatever.
> + */
>  NOTMUCH_STATUS_FILE_ERROR,
> +/**
> + * A file was presented that doesn't appear to be an email
> + * message.
> + */
>  NOTMUCH_STATUS_FILE_NOT_EMAIL,
> +/**
> + * A file contains a message ID that is identical to a message
> + * already in the database.
> + */
>  NOTMUCH_STATUS_

[PATCH] emacs: tree: bare-id in tree

2014-01-01 Thread Tomi Ollila
On Thu, Dec 19 2013, Mark Walters  wrote:

> Previously notmuch-tree-get-message-id always returned the id
> including the prefix "id:". Modify the function to take an optional
> `bare' argument saying to return the raw string.
>
> This will be useful later and brings the function in line with
> notmuch-show-get-message-id.
> ---

LGTM.

Tomi


> This functionality will be useful later. I think it reasonable to put
> it in now as it does bring notmuch-tree-get-message-id in line with
> notmuch-show-get-message-id which already has this option.
>
> Best wishes
>
> Mark
>
>
>  emacs/notmuch-tree.el |6 --
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 8d59e65..1dde9a7 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -319,11 +319,13 @@ correct message properties."
>"Return the tags of the current message."
>(notmuch-tree-get-prop :tags))
>  
> -(defun notmuch-tree-get-message-id ()
> +(defun notmuch-tree-get-message-id (&optional bare)
>"Return the message id of the current message."
>(let ((id (notmuch-tree-get-prop :id)))
>  (if id
> - (notmuch-id-to-query id)
> + (if bare
> + id
> +   (notmuch-id-to-query id))
>nil)))
>  
>  (defun notmuch-tree-get-match ()
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] test: tree: pick remnants removed

2014-01-01 Thread Tomi Ollila
On Sun, Dec 15 2013, Mark Walters  wrote:

> Some no longer needed traces of pick remain in the emacs-tree
> test. Remove these.
> ---
> When playing with tree read/unread things I found these remnants in
> the emacs-tree test. They do no harm but should be removed. Sorry I
> missed these in the pick/tree merge.

LGTM. tests pass.

>
> Best wishes
>
> Mark

Tomi

>
>
>
>  test/emacs-tree |   38 +++---
>  1 files changed, 11 insertions(+), 27 deletions(-)
>
> diff --git a/test/emacs-tree b/test/emacs-tree
> index 4bdfddd..8e9f37c 100755
> --- a/test/emacs-tree
> +++ b/test/emacs-tree
> @@ -8,16 +8,14 @@ EXPECTED=$TEST_DIRECTORY/tree.expected-output
>  add_email_corpus
>  
>  test_begin_subtest "Basic notmuch-tree view in emacs"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (test-output)
>   (delete-other-windows)'
>  test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
>  
>  test_begin_subtest "Refreshed notmuch-tree view in emacs"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (notmuch-tree-refresh-view)
>   (notmuch-test-wait)
> @@ -30,8 +28,7 @@ test_expect_equal_file OUTPUT 
> $EXPECTED/notmuch-tree-tag-inbox
>  # correctly.
>  
>  test_begin_subtest "Tag message in notmuch tree view (display)"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (forward-line)
>   (notmuch-tree-tag (list "+test_tag"))
> @@ -44,8 +41,7 @@ output=$(notmuch search --output=messages 'tag:test_tag')
>  test_expect_equal "$output" "id:877h1wv7mg.fsf at inf-8657.int-evry.fr"
>  
>  test_begin_subtest "Untag message in notmuch tree view"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (forward-line)
>   (notmuch-tree-tag (list "-test_tag"))
> @@ -58,8 +54,7 @@ output=$(notmuch search --output=messages 'tag:test_tag')
>  test_expect_equal "$output" ""
>  
>  test_begin_subtest "Tag thread in notmuch tree view"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   ;; move to a sizable thread
>   (forward-line 26)
> @@ -80,8 +75,7 @@ id:87iqd9rn3l.fsf at vertex.dottedmag
>  id:20091117190054.GU3165 at dottiness.seas.harvard.edu"
>  
>  test_begin_subtest "Untag thread in notmuch tree view"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   ;; move to the same sizable thread as above
>   (forward-line 26)
> @@ -147,26 +141,20 @@ cp OUTPUT /tmp/mjwout
>  test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-show-window
>  
>  test_begin_subtest "Stash id"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> -  (notmuch-tree "id:1258498485-sup-142 at elly")
> +output=$(test_emacs '(notmuch-tree "id:1258498485-sup-142 at elly")
>(notmuch-test-wait)
>(notmuch-show-stash-message-id)')
>  test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142 at elly\""
>  
>  test_begin_subtest "Move to next matching message"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> -  (notmuch-tree "from:cworth")
> +output=$(test_emacs '(notmuch-tree "from:cworth")
>(notmuch-test-wait)
>(notmuch-tree-next-matching-message)
>(notmuch-show-stash-message-id)')
>  test_expect_equal "$output" "\"Stashed: id:878we4qdqf.fsf at 
> yoom.home.cworth.org\""
>  
>  test_begin_subtest "Move to next thread"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> -  (notmuch-tree "tag:inbox")
> +output=$(test_emacs '(notmuch-tree "tag:inbox")
>(notmuch-test-wait)
>(forward-line 26)
>(notmuch-tree-next-thread)
> @@ -174,9 +162,7 @@ output=$(test_emacs '(add-to-list (quote load-path) 
> "'$PICK_DIR'")
>  test_expect_equal "$output" "\"Stashed: 
> id:1258471718-6781-1-git-send-email-dottedmag at dottedmag.net\""
>  
>  test_begin_subtest "Move to previous thread"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote

[PATCH 0/2] library reference man page

2014-01-01 Thread Tomi Ollila
On Sat, Nov 30 2013, Jani Nikula  wrote:

> On Sat, 30 Nov 2013, David Bremner  wrote:
>> Jani Nikula  writes:
>>>
>>>  devel/doxygen.cfg | 1890 
>>> +
>>>  lib/notmuch.h |  436 
>>
>> A 2K line config file is kindof gross, but other than that, I think the
>> idea has merit. Do we really need that much configuration info?
>
> The config file is basically a template generated with 'doxygen -g' and
> adjusted to our needs. It could be significantly reduced by dropping
> comments, defaults, and unused settings. Maybe that would be the right
> thing to do, even if the comments and defaults that are set explicitly
> serve as documentation.
>
>> Perhaps a quibble, but at least for me the summary part of the resulting
>> manpage is almost unreadable because of the amount of underlining.
>
> Agreed, it's not optimal. I was hoping someone more experienced with
> doxygen would fix that after I shared this initial work. ;)

$ doxygen -g -s
...
$ wc Doxyfile
  305   861 10677 Doxyfile

;)

Maybe keeping the defaults is better than hassle with just the changed
options ?


> BR,
> Jani.

Tomi


[PATCH] new: Detect dirent.d_type support at configure time

2014-01-01 Thread Jani Nikula
On Sun, 24 Nov 2013, Austin Clements  wrote:
> Support for dirent.d_type is OS-specific.  Previously, we used
> _DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently
> a glic-ism (FreeBSD, for example, supports d_type, but does not define
> this).  Since there's no cross-platform way to detect support for
> dirent.d_type, detect it using a test compile at configure time.
> ---
>  compat/have_d_type.c | 10 ++
>  configure| 16 
>  notmuch-new.c|  2 +-
>  3 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 compat/have_d_type.c
>
> diff --git a/compat/have_d_type.c b/compat/have_d_type.c
> new file mode 100644
> index 000..9ca6c6e
> --- /dev/null
> +++ b/compat/have_d_type.c
> @@ -0,0 +1,10 @@
> +#include 
> +
> +int main()
> +{
> +struct dirent ent;
> +
> +(void) ent.d_type;
> +
> +return 0;
> +}
> diff --git a/configure b/configure
> index 1a8e939..d2d193c 100755
> --- a/configure
> +++ b/configure
> @@ -557,6 +557,17 @@ else
>  fi
>  rm -f compat/have_timegm
>  
> +printf "Checking for dirent.d_type... "
> +if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 
> 2>&1
> +then
> +printf "Yes.\n"
> +have_d_type="1"
> +else
> +printf "No (will use stat instead).\n"
> +have_d_type="0"
> +fi
> +rm -f compat/have_d_type
> +
>  printf "Checking for standard version of getpwuid_r... "
>  if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > 
> /dev/null 2>&1
>  then
> @@ -745,6 +756,9 @@ HAVE_STRCASESTR = ${have_strcasestr}
>  # build its own version)
>  HAVE_STRSEP = ${have_strsep}
>  
> +# Whether struct dirent has d_type (if not, then notmuch will use stat)
> +HAVE_D_TYPE = ${have_d_type}
> +
>  # Whether the Xapian version in use supports compaction
>  HAVE_XAPIAN_COMPACT = ${have_xapian_compact}
>  
> @@ -805,6 +819,7 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) 
> \$(GMIME_CFLAGS)  \\
>  \$(VALGRIND_CFLAGS)   \\
>  -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
>  -DHAVE_STRSEP=\$(HAVE_STRSEP) \\
> +-DHAVE_D_TYPE=\$(HAVE_D_TYPE) \\
>  -DSTD_GETPWUID=\$(STD_GETPWUID)   \\
>  -DSTD_ASCTIME=\$(STD_ASCTIME) \\
>  -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)
> @@ -813,6 +828,7 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) 
> \$(GMIME_CFLAGS)\\
>\$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
>-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)   \\
>-DHAVE_STRSEP=\$(HAVE_STRSEP)   \\
> +  -DHAVE_D_TYPE=\$(HAVE_D_TYPE)   \\
>-DSTD_GETPWUID=\$(STD_GETPWUID) \\
>-DSTD_ASCTIME=\$(STD_ASCTIME)   \\
>-DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)

The patch looks good, but the above two hunks no longer apply
cleanly. Please repost.

BR,
Jani.



> diff --git a/notmuch-new.c b/notmuch-new.c
> index ba05cb4..423e188 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -167,7 +167,7 @@ dirent_type (const char *path, const struct dirent *entry)
>  char *abspath;
>  int err, saved_errno;
>  
> -#ifdef _DIRENT_HAVE_D_TYPE
> +#if HAVE_D_TYPE
>  /* Mapping from d_type to stat mode_t.  We omit DT_LNK so that
>   * we'll fall through to stat and get the real file type. */
>  static const mode_t modes[] = {
> -- 
> 1.8.4.rc3
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] insert: respect maildir.synchronize_flags

2014-01-01 Thread Austin Clements
LGTM.

Quoth Jani Nikula on Jan 01 at  5:20 pm:
> Don't synchronize maildir flags if the user doesn't want it.


[PATCH] lib: Add a new prefix "list" to the search-terms syntax

2014-01-01 Thread Jani Nikula
On Tue, 17 Dec 2013, "Kirill A. Shutemov"  wrote:
> On Thu, Oct 17, 2013 at 05:17:00PM +0300, Jani Nikula wrote:
>> On Wed, 10 Apr 2013, "Alexey I. Froloff"  wrote:
>> > From: "Alexey I. Froloff" 
>> >
>> > Add support for indexing and searching the message's List-Id header.
>> > This is useful when matching all the messages belonging to a particular
>> > mailing list.
>> 
>> There's an issue with our duplicate message-id handling that is likely
>> to cause confusion with List-Id: searches. If you receive several
>> duplicates of the same message (judged by the message-id), only the
>> first one of them gets indexed, and the rest are ignored. This means
>> that for messages you receive both directly and through a list, it will
>> be arbitrary whether the List-Id: gets indexed or not. Therefore a list:
>> search might not return all the messages you'd expect.
>
> I've tried to address this. The patch also adds few tests for the feature.
>
> There's still missing functionality: re-indexing existing messages for
> list-id, handling message removal, etc.
>
> Any comments?

Hi Kirill, sorry it took me so long to get to this!

I've looked into our duplicate message-id handling and indexing before,
and it's not very good.

First, we should pay more attention to checking whether the messages
really are duplicates or not. This is not trivial, but we should go a
bit further than just comparing the message-ids. Sadly, handling the
case of colliding message-ids on clearly different messages is not
trivial either, as we rely on the message-ids being unique all around.

Second, we should be more clever about indexing duplicates that we think
are the same message. This is orthogonal to the first point. Currently,
only the first duplicate gets indexed, and will remain indexed even if
it's deleted and other copies remain. A message that matches a search
might end up not having the matching search terms, for example. A
rebuild of the database might index a different duplicate from the last
time.

Having said that (partially just to write the thoughts down somewhere!),
I think your basic approach of indexing the list-id for duplicates is
sane, and we can grow more smarts to _notmuch_message_index_file() for
duplicate == true in the future, checking more headers etc. One thing I
wonder about though: what if more than one duplicate has list-id, and
_index_list_id() gets called multiple times on a message? (CC Austin, he
probably has more clues on this than me.)

For merging, you should also address the previous comments to the
original patch. There's been plenty of dropping the ball here it
seems... I think we've also agreed (perhaps only on IRC, I forget) that
we should use "listid" as the prefix, not "list" (sadly hyphens are not
allowed). Splitting the patch to code, test, and man parts might be a
good idea too.

BR,
Jani.


>
> diff --git a/lib/database.cc b/lib/database.cc
> index f395061e3a73..196243e15d1a 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -205,6 +205,7 @@ static prefix_t BOOLEAN_PREFIX_INTERNAL[] = {
>  };
>  
>  static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
> +{ "list","XLIST"},
>  { "thread",  "G" },
>  { "tag", "K" },
>  { "is",  "K" },
> @@ -2025,10 +2026,13 @@ notmuch_database_add_message (notmuch_database_t 
> *notmuch,
>   date = notmuch_message_file_get_header (message_file, "date");
>   _notmuch_message_set_header_values (message, date, from, subject);
>  
> - ret = _notmuch_message_index_file (message, filename);
> + ret = _notmuch_message_index_file (message, filename, false);
>   if (ret)
>   goto DONE;
>   } else {
> + ret = _notmuch_message_index_file (message, filename, true);
> + if (ret)
> + goto DONE;
>   ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
>   }
>  
> diff --git a/lib/index.cc b/lib/index.cc
> index 78c18cf36d10..9fe1ad6502ed 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -304,6 +304,47 @@ _index_address_list (notmuch_message_t *message,
>  }
>  }
>  
> +static void
> +_index_list_id (notmuch_message_t *message,
> +   const char *list_id_header)
> +{
> +const char *begin_list_id, *end_list_id, *list_id;
> +void *local;
> +
> +if (list_id_header == NULL)
> + return;
> +
> +/* RFC2919 says that the list-id is found at the end of the header
> + * and enclosed between angle brackets. If we cannot find a
> + * matching pair of brackets containing at least one character,
> + * we ignore the list id header. */
> +begin_list_id = strrchr (list_id_header, '<');
> +if (!begin_list_id) {
> + fprintf (stderr, "Warning: Not indexing mailformed List-Id tag.\n");
> + return;
> +}
> +
> +end_list_id = strrchr(begin_list_id, '>');
> +if (!end_list_id || (end_list_id - begin_list_id < 2)) {
> + fprintf (stderr, "Warn

[PATCH 1/2] test: delay watchdog checks in emacs.

2014-01-01 Thread David Bremner
david at tethera.net writes:

> From: David Bremner 
>
> Instead of checking immediately for the watched process, delay a
> minute, or in the case that process-attributes returns nil, for two
> minutes.  This is intended to cope with the case that
> process-attributes is unimplimented, and returns always returns nil.
> In this case, the watchdog check is the same as the two minute limit
> imposed by timeout.
> ---

It seems there are still lingering problems with this.

On a Debian Hurd system, the following consistently dies after running
for two minutes. It seems like our test harness can't cope with the
emacs server dying as well as it ought to.  I'm not sure what the right
answer is. A crude workaround would be to increase the hardcoded
timeout. Alternatively, maybe test_emacs should make some effort to
restart the server if it is no longer running.

#!/usr/bin/env bash
test_description="emacs fcc"
. ./test-lib.sh

for ((count=1; count<=1000; count++)); do
id=fub.$count
subject=meh
echo attempting $count
emacs_fcc_message \
"$subject" \
'This is a test message with inline attachment with a filename' \
"(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")
 (message-goto-eoh)
 (insert \"Message-ID: <$id>\n\")"
delivered=$(find $MAIL_DIR/sent -type f | wc -l)
if [[ $delivered != $count ]]; then
GIT_EXIT_OK=1
echo FATAL: $count attempted $delivered delivered
exit 1;
fi
done

test_done




Re: [PATCH 2/2] insert: respect maildir.synchronize_flags

2014-01-01 Thread Austin Clements
LGTM.

Quoth Jani Nikula on Jan 01 at  5:20 pm:
> Don't synchronize maildir flags if the user doesn't want it.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 2/2] lib: modify notmuch.h for automatic document generation

2014-01-01 Thread Jani Nikula
Minimal changes to produce a sensible result.
---
 lib/notmuch.h | 443 +++---
 1 file changed, 302 insertions(+), 141 deletions(-)

diff --git a/lib/notmuch.h b/lib/notmuch.h
index d30768d..02604c5 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -18,9 +18,19 @@
  * Author: Carl Worth 
  */
 
+/**
+ * @defgroup notmuch The notmuch API
+ *
+ * Not much of an email library, (just index and search)
+ *
+ * @{
+ */
+
 #ifndef NOTMUCH_H
 #define NOTMUCH_H
 
+#ifndef __DOXYGEN__
+
 #ifdef  __cplusplus
 # define NOTMUCH_BEGIN_DECLS  extern "C" {
 # define NOTMUCH_END_DECLS}
@@ -49,19 +59,28 @@ NOTMUCH_BEGIN_DECLS
 #define LIBNOTMUCH_MINOR_VERSION   1
 #define LIBNOTMUCH_MICRO_VERSION   0
 
-/*
+#endif /* __DOXYGEN__ */
+
+/**
  * Check the version of the notmuch library being compiled against.
  *
  * Return true if the library being compiled against is of the
  * specified version or above. For example:
  *
+ * @code
  * #if LIBNOTMUCH_CHECK_VERSION(3, 1, 0)
  * (code requiring libnotmuch 3.1.0 or above)
  * #endif
+ * @endcode
+ *
+ * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; to
+ * check for versions prior to that, use:
  *
- * LIBNOTMUCH_CHECK_VERSION has been defined since version 3.1.0; you
- * can use #if !defined(NOTMUCH_CHECK_VERSION) to check for versions
- * prior to that.
+ * @code
+ * #if !defined(NOTMUCH_CHECK_VERSION)
+ * (code requiring libnotmuch prior to 3.1.0)
+ * #endif
+ * @endcode
  */
 #define LIBNOTMUCH_CHECK_VERSION (major, minor, micro) \
 (LIBNOTMUCH_MAJOR_VERSION > (major) || 
\
@@ -69,72 +88,86 @@ NOTMUCH_BEGIN_DECLS
  (LIBNOTMUCH_MAJOR_VERSION == (major) && LIBNOTMUCH_MINOR_VERSION == 
(minor) && \
   LIBNOTMUCH_MICRO_VERSION >= (micro)))
 
+/**
+ * Notmuch boolean type.
+ */
 typedef int notmuch_bool_t;
 
-/* Status codes used for the return values of most functions.
+/**
+ * Status codes used for the return values of most functions.
  *
  * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
- * completed without error. Any other value indicates an error as
- * follows:
- *
- * NOTMUCH_STATUS_SUCCESS: No error occurred.
- *
- * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory
- *
- * XXX: We don't really want to expose this lame XAPIAN_EXCEPTION
- * value. Instead we should map to things like DATABASE_LOCKED or
- * whatever.
- *
- * NOTMUCH_STATUS_READ_ONLY_DATABASE: An attempt was made to write to
- * a database opened in read-only mode.
- *
- * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
- *
- * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to read or
- * write to a file (this could be file not found, permission
- * denied, etc.)
- *
- * NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
- * appear to be an email message.
- *
- * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: A file contains a message ID
- * that is identical to a message already in the database.
- *
- * NOTMUCH_STATUS_NULL_POINTER: The user erroneously passed a NULL
- * pointer to a notmuch function.
- *
- * NOTMUCH_STATUS_TAG_TOO_LONG: A tag value is too long (exceeds
- * NOTMUCH_TAG_MAX)
- *
- * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: The notmuch_message_thaw
- * function has been called more times than notmuch_message_freeze.
- *
- * NOTMUCH_STATUS_UNBALANCED_ATOMIC: notmuch_database_end_atomic has
- * been called more times than notmuch_database_begin_atomic.
- *
- * And finally:
- *
- * NOTMUCH_STATUS_LAST_STATUS: Not an actual status value. Just a way
- * to find out how many valid status values there are.
+ * completed without error. Any other value indicates an error.
  */
 typedef enum _notmuch_status {
+/**
+ * No error occurred.
+ */
 NOTMUCH_STATUS_SUCCESS = 0,
+/**
+ * Out of memory.
+ */
 NOTMUCH_STATUS_OUT_OF_MEMORY,
+/**
+ * An attempt was made to write to a database opened in read-only
+ * mode.
+ */
 NOTMUCH_STATUS_READ_ONLY_DATABASE,
+/**
+ * A Xapian exception occurred.
+ */
 NOTMUCH_STATUS_XAPIAN_EXCEPTION,
+/**
+ * An error occurred trying to read or write to a file (this could
+ * be file not found, permission denied, etc.)
+ *
+ * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
+ * value. Instead we should map to things like DATABASE_LOCKED or
+ * whatever.
+ */
 NOTMUCH_STATUS_FILE_ERROR,
+/**
+ * A file was presented that doesn't appear to be an email
+ * message.
+ */
 NOTMUCH_STATUS_FILE_NOT_EMAIL,
+/**
+ * A file contains a message ID that is identical to a message
+ * already in the database.
+ */
 NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID,
+/**
+ * The user erroneously passed a NULL pointer to a notmuch
+ * function.
+ */
 NOTMUCH_STATUS_NULL_POINTER,
+/**
+ * A tag value is

[PATCH v2 1/2] devel: add doxygen configuration file

2014-01-01 Thread Jani Nikula
This is a pretty basic config to get started, generated using 'doxygen
-s -g' and mildly tweaked.

To generate the library man page man/man3/notmuch.3 from lib/notmuch.h
use:

$ doxygen devel/doxygen.cfg
---
 devel/doxygen.cfg | 304 ++
 1 file changed, 304 insertions(+)
 create mode 100644 devel/doxygen.cfg

diff --git a/devel/doxygen.cfg b/devel/doxygen.cfg
new file mode 100644
index 000..65d5fb5
--- /dev/null
+++ b/devel/doxygen.cfg
@@ -0,0 +1,304 @@
+# Doxyfile 1.8.4
+
+#---
+# Project related configuration options
+#---
+DOXYFILE_ENCODING  = UTF-8
+PROJECT_NAME   = "Notmuch 0.17"
+PROJECT_NUMBER =
+PROJECT_BRIEF  =
+PROJECT_LOGO   =
+OUTPUT_DIRECTORY   =
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE= English
+BRIEF_MEMBER_DESC  = YES
+REPEAT_BRIEF   = YES
+ABBREVIATE_BRIEF   =
+ALWAYS_DETAILED_SEC= NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES= NO
+STRIP_FROM_PATH=
+STRIP_FROM_INC_PATH=
+SHORT_NAMES= NO
+JAVADOC_AUTOBRIEF  = YES
+QT_AUTOBRIEF   = NO
+MULTILINE_CPP_IS_BRIEF = NO
+INHERIT_DOCS   = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE   = 8
+ALIASES=
+TCL_SUBST  =
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+OPTIMIZE_FOR_FORTRAN   = NO
+OPTIMIZE_OUTPUT_VHDL   = NO
+EXTENSION_MAPPING  =
+MARKDOWN_SUPPORT   = YES
+AUTOLINK_SUPPORT   = YES
+BUILTIN_STL_SUPPORT= NO
+CPP_CLI_SUPPORT= NO
+SIP_SUPPORT= NO
+IDL_PROPERTY_SUPPORT   = YES
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING= YES
+INLINE_GROUPED_CLASSES = NO
+INLINE_SIMPLE_STRUCTS  = NO
+TYPEDEF_HIDES_STRUCT   = YES
+LOOKUP_CACHE_SIZE  = 0
+#---
+# Build related configuration options
+#---
+EXTRACT_ALL= NO
+EXTRACT_PRIVATE= NO
+EXTRACT_PACKAGE= NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+EXTRACT_ANON_NSPACES   = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS  = NO
+INTERNAL_DOCS  = NO
+CASE_SENSE_NAMES   = YES
+HIDE_SCOPE_NAMES   = NO
+SHOW_INCLUDE_FILES = NO
+FORCE_LOCAL_INCLUDES   = NO
+INLINE_INFO= YES
+SORT_MEMBER_DOCS   = NO
+SORT_BRIEF_DOCS= NO
+SORT_MEMBERS_CTORS_1ST = NO
+SORT_GROUP_NAMES   = NO
+SORT_BY_SCOPE_NAME = NO
+STRICT_PROTO_MATCHING  = NO
+GENERATE_TODOLIST  = NO
+GENERATE_TESTLIST  = NO
+GENERATE_BUGLIST   = NO
+GENERATE_DEPRECATEDLIST= NO
+ENABLED_SECTIONS   =
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES= NO
+SHOW_FILES = NO
+SHOW_NAMESPACES= NO
+FILE_VERSION_FILTER=
+LAYOUT_FILE=
+CITE_BIB_FILES =
+#---
+# configuration options related to warning and progress messages
+#---
+QUIET  = YES
+WARNINGS   = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR  = YES
+WARN_NO_PARAMDOC   = NO
+WARN_FORMAT= "$file:$line: $text"
+WARN_LOGFILE   =
+#---
+# configuration options related to the input files
+#---
+INPUT  = lib/notmuch.h
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS  =
+RECURSIVE  = NO
+EXCLUDE=
+EXCLUDE_SYMLINKS   = NO
+EXCLUDE_PATTERNS   =
+EXCLUDE_SYMBOLS=
+EXAMPLE_PATH   =
+EXAMPLE_PATTERNS   =
+EXAMPLE_RECURSIVE  = NO
+IMAGE_PATH =
+INPUT_FILTER   =
+FILTER_PATTERNS=
+FILTER_SOURCE_FILES= NO
+FILTER_SOURCE_PATTERNS =
+USE_MDFILE_AS_MAINPAGE =
+#---
+# configuration options related to source browsing
+#---
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS= YES
+REFERENCED_BY_RELATION = NO
+REFERENCES_RELATION= NO
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS  = NO
+VERBATIM_HEADERS   = NO
+#---
+# configuration options related to the alphabetical class index
+#---
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX= 5
+IGNOR

[PATCH v2 0/2] doxygen generated library reference man page

2014-01-01 Thread Jani Nikula
v2 of id:cover.1385826040.git.j...@nikula.org

Rebase, minor tweaks since v1; the TODO in the referenced message above
is still valid. I suggest we get this merged as a starting point, so we
can collaborate on including a nice API man page (and possibly a HTML
API reference on the web page) for 0.18.

BR,
Jani.


Jani Nikula (2):
  devel: add doxygen configuration file
  lib: modify notmuch.h for automatic document generation

 devel/doxygen.cfg | 304 +
 lib/notmuch.h | 443 +-
 2 files changed, 606 insertions(+), 141 deletions(-)
 create mode 100644 devel/doxygen.cfg

-- 
1.8.5.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] insert: respect maildir.synchronize_flags

2014-01-01 Thread Tomi Ollila
On Wed, Jan 01 2014, Jani Nikula  wrote:

> Don't synchronize maildir flags if the user doesn't want it.
> ---

Looks good, tests pass.

Tomi


>  notmuch-insert.c | 24 
>  test/insert  |  1 -
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/notmuch-insert.c b/notmuch-insert.c
> index 2207b1e..55384e3 100644
> --- a/notmuch-insert.c
> +++ b/notmuch-insert.c
> @@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout)
>   * The file is renamed to encode notmuch tags as maildir flags. */
>  static void
>  add_file_to_database (notmuch_database_t *notmuch, const char *path,
> -   tag_op_list_t *tag_ops)
> +   tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags)
>  {
>  notmuch_message_t *message;
>  notmuch_status_t status;
> @@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, 
> const char *path,
>  
>  if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
>   /* Don't change tags of an existing message. */
> - status = notmuch_message_tags_to_maildir_flags (message);
> - if (status != NOTMUCH_STATUS_SUCCESS)
> - fprintf (stderr, "Error: failed to sync tags to maildir flags\n");
> + if (synchronize_flags) {
> + status = notmuch_message_tags_to_maildir_flags (message);
> + if (status != NOTMUCH_STATUS_SUCCESS)
> + fprintf (stderr, "Error: failed to sync tags to maildir 
> flags\n");
> + }
>  } else {
> - tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC);
> + tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0;
> +
> + tag_op_list_apply (message, tag_ops, flags);
>  }
>  
>  notmuch_message_destroy (message);
> @@ -335,7 +339,8 @@ add_file_to_database (notmuch_database_t *notmuch, const 
> char *path,
>  
>  static notmuch_bool_t
>  insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
> - const char *dir, tag_op_list_t *tag_ops)
> + const char *dir, tag_op_list_t *tag_ops,
> + notmuch_bool_t synchronize_flags)
>  {
>  char *tmppath;
>  char *newpath;
> @@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, 
> int fdin,
>  
>  /* Even if adding the message to the notmuch database fails,
>   * the message is on disk and we consider the delivery completed. */
> -add_file_to_database (notmuch, newpath, tag_ops);
> +add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags);
>  
>  return TRUE;
>  
> @@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  char *query_string = NULL;
>  const char *folder = NULL;
>  notmuch_bool_t create_folder = FALSE;
> +notmuch_bool_t synchronize_flags;
>  const char *maildir;
>  int opt_index;
>  unsigned int i;
> @@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  
>  db_path = notmuch_config_get_database_path (config);
>  new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
> +synchronize_flags = notmuch_config_get_maildir_synchronize_flags 
> (config);
>  
>  tag_ops = tag_op_list_create (config);
>  if (tag_ops == NULL) {
> @@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int 
> argc, char *argv[])
>  NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
>   return 1;
>  
> -ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);
> +ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops,
> +   synchronize_flags);
>  
>  notmuch_database_destroy (notmuch);
>  
> diff --git a/test/insert b/test/insert
> index 9283e70..e8dc4c0 100755
> --- a/test/insert
> +++ b/test/insert
> @@ -114,7 +114,6 @@ dirname=$(dirname "$output")
>  test_expect_equal "$dirname" "$MAIL_DIR/cur"
>  
>  test_begin_subtest "Insert message with maildir sync off goes to new/"
> -test_subtest_known_broken
>  OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
>  notmuch config set maildir.synchronize_flags false
>  gen_insert_msg
> -- 
> 1.8.5.2
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/1] test: support for generating decreasing dates with bash 4.0 and 4.1

2014-01-01 Thread Tomi Ollila
The printf builtin "%(fmt)T" specifier (which allows time values
to use strftime-like formatting) is introduced in bash 4.2.

Added a new function `secs_to_rfc2822date` which uses the above specifier
with post 4.1 bash and perl(1) construct with pre-4.2 bash.
---
 test/test-lib.sh | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2fcaba6..7d88867 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -272,6 +272,21 @@ remove_cr () {
tr '\015' Q | sed -e 's/Q$//'
 }
 
+# The printf '%(fmt)T' specifier is bash 4.2+ feature.
+if [[ ${BASH_VERSINFO[0]} -gt 4 || ${BASH_VERSINFO[1]} -ge 2 ]]
+then
+   secs_to_rfc2822date ()
+   {
+   TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" "$1"
+   }
+else
+   secs_to_rfc2822date ()
+   {
+   perl -le 'use POSIX "strftime"; @time = gmtime $ARGV[0];
+   print strftime "%a, %d %b %Y %T +", @time' "$1"
+   }
+fi
+
 # Generate a new message in the mail directory, with a unique message
 # ID and subject. The message is not added to the index.
 #
@@ -373,8 +388,8 @@ generate_message ()
# we use decreasing timestamps here for historical reasons;
# the existing test suite when we converted to unique timestamps just
# happened to have signicantly fewer failures with that choice.
-   template[date]=$(TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" \
-   $((978709437 - gen_msg_cnt)))
+
+   template[date]=$(secs_to_rfc2822date $((978709437 - gen_msg_cnt)))
 fi
 
 additional_headers=""
-- 
1.8.0

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] test: delay watchdog checks in emacs.

2014-01-01 Thread David Bremner
da...@tethera.net writes:

> From: David Bremner 
>
> Instead of checking immediately for the watched process, delay a
> minute, or in the case that process-attributes returns nil, for two
> minutes.  This is intended to cope with the case that
> process-attributes is unimplimented, and returns always returns nil.
> In this case, the watchdog check is the same as the two minute limit
> imposed by timeout.
> ---

It seems there are still lingering problems with this.

On a Debian Hurd system, the following consistently dies after running
for two minutes. It seems like our test harness can't cope with the
emacs server dying as well as it ought to.  I'm not sure what the right
answer is. A crude workaround would be to increase the hardcoded
timeout. Alternatively, maybe test_emacs should make some effort to
restart the server if it is no longer running.

#!/usr/bin/env bash
test_description="emacs fcc"
. ./test-lib.sh

for ((count=1; count<=1000; count++)); do
id=fub.$count
subject=meh
echo attempting $count
emacs_fcc_message \
"$subject" \
'This is a test message with inline attachment with a filename' \
"(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")
 (message-goto-eoh)
 (insert \"Message-ID: <$id>\n\")"
delivered=$(find $MAIL_DIR/sent -type f | wc -l)
if [[ $delivered != $count ]]; then
GIT_EXIT_OK=1
echo FATAL: $count attempted $delivered delivered
exit 1;
fi
done

test_done


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] insert: respect maildir.synchronize_flags

2014-01-01 Thread Jani Nikula
Don't synchronize maildir flags if the user doesn't want it.
---
 notmuch-insert.c | 24 
 test/insert  |  1 -
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 2207b1e..55384e3 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -295,7 +295,7 @@ copy_stdin (int fdin, int fdout)
  * The file is renamed to encode notmuch tags as maildir flags. */
 static void
 add_file_to_database (notmuch_database_t *notmuch, const char *path,
- tag_op_list_t *tag_ops)
+ tag_op_list_t *tag_ops, notmuch_bool_t synchronize_flags)
 {
 notmuch_message_t *message;
 notmuch_status_t status;
@@ -323,11 +323,15 @@ add_file_to_database (notmuch_database_t *notmuch, const 
char *path,
 
 if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {
/* Don't change tags of an existing message. */
-   status = notmuch_message_tags_to_maildir_flags (message);
-   if (status != NOTMUCH_STATUS_SUCCESS)
-   fprintf (stderr, "Error: failed to sync tags to maildir flags\n");
+   if (synchronize_flags) {
+   status = notmuch_message_tags_to_maildir_flags (message);
+   if (status != NOTMUCH_STATUS_SUCCESS)
+   fprintf (stderr, "Error: failed to sync tags to maildir 
flags\n");
+   }
 } else {
-   tag_op_list_apply (message, tag_ops, TAG_FLAG_MAILDIR_SYNC);
+   tag_op_flag_t flags = synchronize_flags ? TAG_FLAG_MAILDIR_SYNC : 0;
+
+   tag_op_list_apply (message, tag_ops, flags);
 }
 
 notmuch_message_destroy (message);
@@ -335,7 +339,8 @@ add_file_to_database (notmuch_database_t *notmuch, const 
char *path,
 
 static notmuch_bool_t
 insert_message (void *ctx, notmuch_database_t *notmuch, int fdin,
-   const char *dir, tag_op_list_t *tag_ops)
+   const char *dir, tag_op_list_t *tag_ops,
+   notmuch_bool_t synchronize_flags)
 {
 char *tmppath;
 char *newpath;
@@ -377,7 +382,7 @@ insert_message (void *ctx, notmuch_database_t *notmuch, int 
fdin,
 
 /* Even if adding the message to the notmuch database fails,
  * the message is on disk and we consider the delivery completed. */
-add_file_to_database (notmuch, newpath, tag_ops);
+add_file_to_database (notmuch, newpath, tag_ops, synchronize_flags);
 
 return TRUE;
 
@@ -400,6 +405,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
 char *query_string = NULL;
 const char *folder = NULL;
 notmuch_bool_t create_folder = FALSE;
+notmuch_bool_t synchronize_flags;
 const char *maildir;
 int opt_index;
 unsigned int i;
@@ -420,6 +426,7 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
 
 db_path = notmuch_config_get_database_path (config);
 new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
+synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
 
 tag_ops = tag_op_list_create (config);
 if (tag_ops == NULL) {
@@ -471,7 +478,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, 
char *argv[])
   NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
return 1;
 
-ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops);
+ret = insert_message (config, notmuch, STDIN_FILENO, maildir, tag_ops,
+ synchronize_flags);
 
 notmuch_database_destroy (notmuch);
 
diff --git a/test/insert b/test/insert
index 9283e70..e8dc4c0 100755
--- a/test/insert
+++ b/test/insert
@@ -114,7 +114,6 @@ dirname=$(dirname "$output")
 test_expect_equal "$dirname" "$MAIL_DIR/cur"
 
 test_begin_subtest "Insert message with maildir sync off goes to new/"
-test_subtest_known_broken
 OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
 notmuch config set maildir.synchronize_flags false
 gen_insert_msg
-- 
1.8.5.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] test: notmuch insert with maildir.synchronize_flags=false

2014-01-01 Thread Jani Nikula
Known broken, notmuch insert does not respect the config option.
---
 test/insert | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/test/insert b/test/insert
index 550b413..9283e70 100755
--- a/test/insert
+++ b/test/insert
@@ -113,6 +113,17 @@ output=$(notmuch search --output=files id:$gen_msg_id)
 dirname=$(dirname "$output")
 test_expect_equal "$dirname" "$MAIL_DIR/cur"
 
+test_begin_subtest "Insert message with maildir sync off goes to new/"
+test_subtest_known_broken
+OLDCONFIG=$(notmuch config get maildir.synchronize_flags)
+notmuch config set maildir.synchronize_flags false
+gen_insert_msg
+notmuch insert +flagged < "$gen_msg_filename"
+output=$(notmuch search --output=files id:$gen_msg_id)
+dirname=$(dirname "$output")
+notmuch config set maildir.synchronize_flags $OLDCONFIG
+test_expect_equal "$dirname" "$MAIL_DIR/new"
+
 test_begin_subtest "Insert message into folder"
 gen_insert_msg
 notmuch insert --folder=Drafts < "$gen_msg_filename"
-- 
1.8.5.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] lib: modify notmuch.h for automatic document generation

2014-01-01 Thread Tomi Ollila
On Sat, Nov 30 2013, Jani Nikula  wrote:

> Minimal changes to produce a sensible result.
> ---

Looks good but does not apply anymore (blame Austin)
Also the doxygen -s -g (+ edits) looks good ;D

Tomi


>  lib/notmuch.h | 436 
> +++---
>  1 file changed, 296 insertions(+), 140 deletions(-)
>
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 7c3a30c..708b603 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -18,9 +18,19 @@
>   * Author: Carl Worth 
>   */
>  
> +/**
> + * @defgroup notmuch The notmuch API
> + *
> + * Not much of an email library, (just index and search)
> + *
> + * @{
> + */
> +
>  #ifndef NOTMUCH_H
>  #define NOTMUCH_H
>  
> +#ifndef __DOXYGEN__
> +
>  #ifdef  __cplusplus
>  # define NOTMUCH_BEGIN_DECLS  extern "C" {
>  # define NOTMUCH_END_DECLS}
> @@ -45,18 +55,20 @@ NOTMUCH_BEGIN_DECLS
>  #define NOTMUCH_MINOR_VERSION17
>  #define NOTMUCH_MICRO_VERSION0
>  
> -/*
> +#endif /* __DOXYGEN__ */
> +
> +/**
>   * Check the version of the notmuch library being compiled against.
>   *
>   * Return true if the library being compiled against is of the
>   * specified version or above. For example:
>   *
> - * #if NOTMUCH_CHECK_VERSION(0, 18, 0)
> + * \#if NOTMUCH_CHECK_VERSION(0, 18, 0)
>   * (code requiring notmuch 0.18 or above)
> - * #endif
> + * \#endif
>   *
>   * NOTMUCH_CHECK_VERSION has been defined since version 0.17.0; you
> - * can use #if !defined(NOTMUCH_CHECK_VERSION) to check for versions
> + * can use \#if !defined(NOTMUCH_CHECK_VERSION) to check for versions
>   * prior to that.
>   */
>  #define NOTMUCH_CHECK_VERSION (major, minor, micro)  \
> @@ -65,80 +77,97 @@ NOTMUCH_BEGIN_DECLS
>   (NOTMUCH_MAJOR_VERSION == (major) && NOTMUCH_MINOR_VERSION == (minor) 
> && \
>NOTMUCH_MICRO_VERSION >= (micro)))
>  
> +/**
> + * Notmuch boolean type.
> + */
>  typedef int notmuch_bool_t;
>  
> -/* Status codes used for the return values of most functions.
> +/**
> + * Status codes used for the return values of most functions.
>   *
>   * A zero value (NOTMUCH_STATUS_SUCCESS) indicates that the function
> - * completed without error. Any other value indicates an error as
> - * follows:
> - *
> - * NOTMUCH_STATUS_SUCCESS: No error occurred.
> - *
> - * NOTMUCH_STATUS_OUT_OF_MEMORY: Out of memory
> - *
> - * XXX: We don't really want to expose this lame XAPIAN_EXCEPTION
> - * value. Instead we should map to things like DATABASE_LOCKED or
> - * whatever.
> - *
> - * NOTMUCH_STATUS_READ_ONLY_DATABASE: An attempt was made to write to
> - *   a database opened in read-only mode.
> + * completed without error. Any other value indicates an error.
>   *
> - * NOTMUCH_STATUS_XAPIAN_EXCEPTION: A Xapian exception occurred
> - *
> - * NOTMUCH_STATUS_FILE_ERROR: An error occurred trying to read or
> - *   write to a file (this could be file not found, permission
> - *   denied, etc.)
> - *
> - * NOTMUCH_STATUS_FILE_NOT_EMAIL: A file was presented that doesn't
> - *   appear to be an email message.
> - *
> - * NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: A file contains a message ID
> - *   that is identical to a message already in the database.
> - *
> - * NOTMUCH_STATUS_NULL_POINTER: The user erroneously passed a NULL
> - *   pointer to a notmuch function.
> - *
> - * NOTMUCH_STATUS_TAG_TOO_LONG: A tag value is too long (exceeds
> - *   NOTMUCH_TAG_MAX)
> - *
> - * NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW: The notmuch_message_thaw
> - *   function has been called more times than notmuch_message_freeze.
> - *
> - * NOTMUCH_STATUS_UNBALANCED_ATOMIC: notmuch_database_end_atomic has
> - *   been called more times than notmuch_database_begin_atomic.
> - *
> - * And finally:
> - *
> - * NOTMUCH_STATUS_LAST_STATUS: Not an actual status value. Just a way
> - *   to find out how many valid status values there are.
>   */
>  typedef enum _notmuch_status {
> +/**
> + * No error occurred.
> + */
>  NOTMUCH_STATUS_SUCCESS = 0,
> +/**
> + * Out of memory.
> + */
>  NOTMUCH_STATUS_OUT_OF_MEMORY,
> +/**
> + * An attempt was made to write to a database opened in read-only
> + * mode.
> + */
>  NOTMUCH_STATUS_READ_ONLY_DATABASE,
> +/**
> + * A Xapian exception occurred.
> + */
>  NOTMUCH_STATUS_XAPIAN_EXCEPTION,
> +/**
> + * An error occurred trying to read or write to a file (this could
> + * be file not found, permission denied, etc.)
> + *
> + * @todo We don't really want to expose this lame XAPIAN_EXCEPTION
> + * value. Instead we should map to things like DATABASE_LOCKED or
> + * whatever.
> + */
>  NOTMUCH_STATUS_FILE_ERROR,
> +/**
> + * A file was presented that doesn't appear to be an email
> + * message.
> + */
>  NOTMUCH_STATUS_FILE_NOT_EMAIL,
> +/**
> + * A file contains a message ID that is identical to a message
> + * already in the database.
> + */
>  NOTMUCH_STATUS_

Re: [PATCH] emacs: tree: bare-id in tree

2014-01-01 Thread Tomi Ollila
On Thu, Dec 19 2013, Mark Walters  wrote:

> Previously notmuch-tree-get-message-id always returned the id
> including the prefix "id:". Modify the function to take an optional
> `bare' argument saying to return the raw string.
>
> This will be useful later and brings the function in line with
> notmuch-show-get-message-id.
> ---

LGTM.

Tomi


> This functionality will be useful later. I think it reasonable to put
> it in now as it does bring notmuch-tree-get-message-id in line with
> notmuch-show-get-message-id which already has this option.
>
> Best wishes
>
> Mark
>
>
>  emacs/notmuch-tree.el |6 --
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 8d59e65..1dde9a7 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -319,11 +319,13 @@ correct message properties."
>"Return the tags of the current message."
>(notmuch-tree-get-prop :tags))
>  
> -(defun notmuch-tree-get-message-id ()
> +(defun notmuch-tree-get-message-id (&optional bare)
>"Return the message id of the current message."
>(let ((id (notmuch-tree-get-prop :id)))
>  (if id
> - (notmuch-id-to-query id)
> + (if bare
> + id
> +   (notmuch-id-to-query id))
>nil)))
>  
>  (defun notmuch-tree-get-match ()
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: tree: pick remnants removed

2014-01-01 Thread Tomi Ollila
On Sun, Dec 15 2013, Mark Walters  wrote:

> Some no longer needed traces of pick remain in the emacs-tree
> test. Remove these.
> ---
> When playing with tree read/unread things I found these remnants in
> the emacs-tree test. They do no harm but should be removed. Sorry I
> missed these in the pick/tree merge.

LGTM. tests pass.

>
> Best wishes
>
> Mark

Tomi

>
>
>
>  test/emacs-tree |   38 +++---
>  1 files changed, 11 insertions(+), 27 deletions(-)
>
> diff --git a/test/emacs-tree b/test/emacs-tree
> index 4bdfddd..8e9f37c 100755
> --- a/test/emacs-tree
> +++ b/test/emacs-tree
> @@ -8,16 +8,14 @@ EXPECTED=$TEST_DIRECTORY/tree.expected-output
>  add_email_corpus
>  
>  test_begin_subtest "Basic notmuch-tree view in emacs"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (test-output)
>   (delete-other-windows)'
>  test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
>  
>  test_begin_subtest "Refreshed notmuch-tree view in emacs"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (notmuch-tree-refresh-view)
>   (notmuch-test-wait)
> @@ -30,8 +28,7 @@ test_expect_equal_file OUTPUT 
> $EXPECTED/notmuch-tree-tag-inbox
>  # correctly.
>  
>  test_begin_subtest "Tag message in notmuch tree view (display)"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (forward-line)
>   (notmuch-tree-tag (list "+test_tag"))
> @@ -44,8 +41,7 @@ output=$(notmuch search --output=messages 'tag:test_tag')
>  test_expect_equal "$output" "id:877h1wv7mg@inf-8657.int-evry.fr"
>  
>  test_begin_subtest "Untag message in notmuch tree view"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   (forward-line)
>   (notmuch-tree-tag (list "-test_tag"))
> @@ -58,8 +54,7 @@ output=$(notmuch search --output=messages 'tag:test_tag')
>  test_expect_equal "$output" ""
>  
>  test_begin_subtest "Tag thread in notmuch tree view"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   ;; move to a sizable thread
>   (forward-line 26)
> @@ -80,8 +75,7 @@ id:87iqd9rn3l.fsf@vertex.dottedmag
>  id:20091117190054.gu3...@dottiness.seas.harvard.edu"
>  
>  test_begin_subtest "Untag thread in notmuch tree view"
> -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> - (notmuch-tree "tag:inbox")
> +test_emacs '(notmuch-tree "tag:inbox")
>   (notmuch-test-wait)
>   ;; move to the same sizable thread as above
>   (forward-line 26)
> @@ -147,26 +141,20 @@ cp OUTPUT /tmp/mjwout
>  test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-show-window
>  
>  test_begin_subtest "Stash id"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> -  (notmuch-tree "id:1258498485-sup-142@elly")
> +output=$(test_emacs '(notmuch-tree "id:1258498485-sup-142@elly")
>(notmuch-test-wait)
>(notmuch-show-stash-message-id)')
>  test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142@elly\""
>  
>  test_begin_subtest "Move to next matching message"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> -  (notmuch-tree "from:cworth")
> +output=$(test_emacs '(notmuch-tree "from:cworth")
>(notmuch-test-wait)
>(notmuch-tree-next-matching-message)
>(notmuch-show-stash-message-id)')
>  test_expect_equal "$output" "\"Stashed: 
> id:878we4qdqf@yoom.home.cworth.org\""
>  
>  test_begin_subtest "Move to next thread"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> -  (notmuch-tree "tag:inbox")
> +output=$(test_emacs '(notmuch-tree "tag:inbox")
>(notmuch-test-wait)
>(forward-line 26)
>(notmuch-tree-next-thread)
> @@ -174,9 +162,7 @@ output=$(test_emacs '(add-to-list (quote load-path) 
> "'$PICK_DIR'")
>  test_expect_equal "$output" "\"Stashed: 
> id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net\""
>  
>  test_begin_subtest "Move to previous thread"
> -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
> -  (require (quote notmuch-tree))
> - 

Re: [PATCH 0/2] library reference man page

2014-01-01 Thread Tomi Ollila
On Sat, Nov 30 2013, Jani Nikula  wrote:

> On Sat, 30 Nov 2013, David Bremner  wrote:
>> Jani Nikula  writes:
>>>
>>>  devel/doxygen.cfg | 1890 
>>> +
>>>  lib/notmuch.h |  436 
>>
>> A 2K line config file is kindof gross, but other than that, I think the
>> idea has merit. Do we really need that much configuration info?
>
> The config file is basically a template generated with 'doxygen -g' and
> adjusted to our needs. It could be significantly reduced by dropping
> comments, defaults, and unused settings. Maybe that would be the right
> thing to do, even if the comments and defaults that are set explicitly
> serve as documentation.
>
>> Perhaps a quibble, but at least for me the summary part of the resulting
>> manpage is almost unreadable because of the amount of underlining.
>
> Agreed, it's not optimal. I was hoping someone more experienced with
> doxygen would fix that after I shared this initial work. ;)

$ doxygen -g -s
...
$ wc Doxyfile
  305   861 10677 Doxyfile

;)

Maybe keeping the defaults is better than hassle with just the changed
options ?


> BR,
> Jani.

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] new: Detect dirent.d_type support at configure time

2014-01-01 Thread Jani Nikula
On Sun, 24 Nov 2013, Austin Clements  wrote:
> Support for dirent.d_type is OS-specific.  Previously, we used
> _DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently
> a glic-ism (FreeBSD, for example, supports d_type, but does not define
> this).  Since there's no cross-platform way to detect support for
> dirent.d_type, detect it using a test compile at configure time.
> ---
>  compat/have_d_type.c | 10 ++
>  configure| 16 
>  notmuch-new.c|  2 +-
>  3 files changed, 27 insertions(+), 1 deletion(-)
>  create mode 100644 compat/have_d_type.c
>
> diff --git a/compat/have_d_type.c b/compat/have_d_type.c
> new file mode 100644
> index 000..9ca6c6e
> --- /dev/null
> +++ b/compat/have_d_type.c
> @@ -0,0 +1,10 @@
> +#include 
> +
> +int main()
> +{
> +struct dirent ent;
> +
> +(void) ent.d_type;
> +
> +return 0;
> +}
> diff --git a/configure b/configure
> index 1a8e939..d2d193c 100755
> --- a/configure
> +++ b/configure
> @@ -557,6 +557,17 @@ else
>  fi
>  rm -f compat/have_timegm
>  
> +printf "Checking for dirent.d_type... "
> +if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 
> 2>&1
> +then
> +printf "Yes.\n"
> +have_d_type="1"
> +else
> +printf "No (will use stat instead).\n"
> +have_d_type="0"
> +fi
> +rm -f compat/have_d_type
> +
>  printf "Checking for standard version of getpwuid_r... "
>  if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > 
> /dev/null 2>&1
>  then
> @@ -745,6 +756,9 @@ HAVE_STRCASESTR = ${have_strcasestr}
>  # build its own version)
>  HAVE_STRSEP = ${have_strsep}
>  
> +# Whether struct dirent has d_type (if not, then notmuch will use stat)
> +HAVE_D_TYPE = ${have_d_type}
> +
>  # Whether the Xapian version in use supports compaction
>  HAVE_XAPIAN_COMPACT = ${have_xapian_compact}
>  
> @@ -805,6 +819,7 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) 
> \$(GMIME_CFLAGS)  \\
>  \$(VALGRIND_CFLAGS)   \\
>  -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
>  -DHAVE_STRSEP=\$(HAVE_STRSEP) \\
> +-DHAVE_D_TYPE=\$(HAVE_D_TYPE) \\
>  -DSTD_GETPWUID=\$(STD_GETPWUID)   \\
>  -DSTD_ASCTIME=\$(STD_ASCTIME) \\
>  -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)
> @@ -813,6 +828,7 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) 
> \$(GMIME_CFLAGS)\\
>\$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
>-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)   \\
>-DHAVE_STRSEP=\$(HAVE_STRSEP)   \\
> +  -DHAVE_D_TYPE=\$(HAVE_D_TYPE)   \\
>-DSTD_GETPWUID=\$(STD_GETPWUID) \\
>-DSTD_ASCTIME=\$(STD_ASCTIME)   \\
>-DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)

The patch looks good, but the above two hunks no longer apply
cleanly. Please repost.

BR,
Jani.



> diff --git a/notmuch-new.c b/notmuch-new.c
> index ba05cb4..423e188 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -167,7 +167,7 @@ dirent_type (const char *path, const struct dirent *entry)
>  char *abspath;
>  int err, saved_errno;
>  
> -#ifdef _DIRENT_HAVE_D_TYPE
> +#if HAVE_D_TYPE
>  /* Mapping from d_type to stat mode_t.  We omit DT_LNK so that
>   * we'll fall through to stat and get the real file type. */
>  static const mode_t modes[] = {
> -- 
> 1.8.4.rc3
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] lib: Add a new prefix "list" to the search-terms syntax

2014-01-01 Thread Jani Nikula
On Tue, 17 Dec 2013, "Kirill A. Shutemov"  wrote:
> On Thu, Oct 17, 2013 at 05:17:00PM +0300, Jani Nikula wrote:
>> On Wed, 10 Apr 2013, "Alexey I. Froloff"  wrote:
>> > From: "Alexey I. Froloff" 
>> >
>> > Add support for indexing and searching the message's List-Id header.
>> > This is useful when matching all the messages belonging to a particular
>> > mailing list.
>> 
>> There's an issue with our duplicate message-id handling that is likely
>> to cause confusion with List-Id: searches. If you receive several
>> duplicates of the same message (judged by the message-id), only the
>> first one of them gets indexed, and the rest are ignored. This means
>> that for messages you receive both directly and through a list, it will
>> be arbitrary whether the List-Id: gets indexed or not. Therefore a list:
>> search might not return all the messages you'd expect.
>
> I've tried to address this. The patch also adds few tests for the feature.
>
> There's still missing functionality: re-indexing existing messages for
> list-id, handling message removal, etc.
>
> Any comments?

Hi Kirill, sorry it took me so long to get to this!

I've looked into our duplicate message-id handling and indexing before,
and it's not very good.

First, we should pay more attention to checking whether the messages
really are duplicates or not. This is not trivial, but we should go a
bit further than just comparing the message-ids. Sadly, handling the
case of colliding message-ids on clearly different messages is not
trivial either, as we rely on the message-ids being unique all around.

Second, we should be more clever about indexing duplicates that we think
are the same message. This is orthogonal to the first point. Currently,
only the first duplicate gets indexed, and will remain indexed even if
it's deleted and other copies remain. A message that matches a search
might end up not having the matching search terms, for example. A
rebuild of the database might index a different duplicate from the last
time.

Having said that (partially just to write the thoughts down somewhere!),
I think your basic approach of indexing the list-id for duplicates is
sane, and we can grow more smarts to _notmuch_message_index_file() for
duplicate == true in the future, checking more headers etc. One thing I
wonder about though: what if more than one duplicate has list-id, and
_index_list_id() gets called multiple times on a message? (CC Austin, he
probably has more clues on this than me.)

For merging, you should also address the previous comments to the
original patch. There's been plenty of dropping the ball here it
seems... I think we've also agreed (perhaps only on IRC, I forget) that
we should use "listid" as the prefix, not "list" (sadly hyphens are not
allowed). Splitting the patch to code, test, and man parts might be a
good idea too.

BR,
Jani.


>
> diff --git a/lib/database.cc b/lib/database.cc
> index f395061e3a73..196243e15d1a 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -205,6 +205,7 @@ static prefix_t BOOLEAN_PREFIX_INTERNAL[] = {
>  };
>  
>  static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
> +{ "list","XLIST"},
>  { "thread",  "G" },
>  { "tag", "K" },
>  { "is",  "K" },
> @@ -2025,10 +2026,13 @@ notmuch_database_add_message (notmuch_database_t 
> *notmuch,
>   date = notmuch_message_file_get_header (message_file, "date");
>   _notmuch_message_set_header_values (message, date, from, subject);
>  
> - ret = _notmuch_message_index_file (message, filename);
> + ret = _notmuch_message_index_file (message, filename, false);
>   if (ret)
>   goto DONE;
>   } else {
> + ret = _notmuch_message_index_file (message, filename, true);
> + if (ret)
> + goto DONE;
>   ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID;
>   }
>  
> diff --git a/lib/index.cc b/lib/index.cc
> index 78c18cf36d10..9fe1ad6502ed 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -304,6 +304,47 @@ _index_address_list (notmuch_message_t *message,
>  }
>  }
>  
> +static void
> +_index_list_id (notmuch_message_t *message,
> +   const char *list_id_header)
> +{
> +const char *begin_list_id, *end_list_id, *list_id;
> +void *local;
> +
> +if (list_id_header == NULL)
> + return;
> +
> +/* RFC2919 says that the list-id is found at the end of the header
> + * and enclosed between angle brackets. If we cannot find a
> + * matching pair of brackets containing at least one character,
> + * we ignore the list id header. */
> +begin_list_id = strrchr (list_id_header, '<');
> +if (!begin_list_id) {
> + fprintf (stderr, "Warning: Not indexing mailformed List-Id tag.\n");
> + return;
> +}
> +
> +end_list_id = strrchr(begin_list_id, '>');
> +if (!end_list_id || (end_list_id - begin_list_id < 2)) {
> + fprintf (stderr, "Warn