[PATCH 2/2] NEWS: news for notmuch-insert error handling

2016-12-07 Thread David Bremner
---
 NEWS | 12 
 1 file changed, 12 insertions(+)

diff --git a/NEWS b/NEWS
index 99ef277..c0aa479 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+Notmuch 0.23.4 (UNRELEASED)
+===
+
+Command Line Interface
+--
+
+Improve error handling in notmuch insert
+
+  Database lock errors no longer prevent message file delivery to the
+  filesystem.  Certain errors during `notmuch insert` most likely to
+  be temporary return EX_TEMPFAIL.
+
 Notmuch 0.23.3 (2016-11-27)
 ===
 
-- 
2.10.2

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


[PATCH 1/2] cli/insert: document the use of EX_TEMPFAIL

2016-12-07 Thread David Bremner
---
 doc/man1/notmuch-insert.rst | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/doc/man1/notmuch-insert.rst b/doc/man1/notmuch-insert.rst
index 9e7afc3..9847e67 100644
--- a/doc/man1/notmuch-insert.rst
+++ b/doc/man1/notmuch-insert.rst
@@ -60,6 +60,13 @@ indexing to Notmuch database, changing tags, and 
synchronizing tags to
 maildir flags. The ``--keep`` option may be used to settle for
 successful message file delivery.
 
+This command supports the following special exit status code for
+errors most likely to be temporary in nature, e.g. failure to get a
+database write lock.
+
+``75 (EX_TEMPFAIL)``
+A temporary failure occured; the user is invited to retry.
+
 The exit status of the **post-insert** hook does not affect the exit
 status of the **insert** command.
 
-- 
2.10.2

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


NEWS/docs for insert tempfail changes

2016-12-07 Thread David Bremner
I went back and forth few times, but eventually decided to go with
Tomi's version of the test quoting, the better to share the blame.
The patches will be merged to release and master, in prep for another
bugfix release.  Here are some proposed news and manpage changes.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


search for squre bracket

2016-12-07 Thread Jian Fan
Hi,

I want to search

subject:[Release]

i.e. emails whose subject is like:

[Release] fix a bug

Notmuch seems to return those and many other emails. I tried to escape,
quote and nothing seems working.

Thanks.

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


remove attachments

2016-12-07 Thread Daniele Arosio

Dear all,
I come across notmuch only recently and I am about to switch to it, but 
I still missing a way to detach files (like pdf, docx...) from my emails 
sitting say in inbox.


Is there any way to accomplish attachment deletion through emacs front 
end or any other command line approach?


Thanks

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


Re: search for squre bracket

2016-12-07 Thread David Bremner
Jian Fan  writes:

> Hi,
>
> I want to search
>
> subject:[Release]
>
> i.e. emails whose subject is like:
>
> [Release] fix a bug
>
> Notmuch seems to return those and many other emails. I tried to escape,
> quote and nothing seems working.

by default xapian (and hence notmuch) uses a word based search that
essentially ignored punctation.

There is a patch to support (slower) regular expression search

  id:20161114214651.19770-1-da...@tethera.net


  http://mid.tethera.net/notmuch/20161114214651.19770-1-da...@tethera.net/

If you help test it, maybe it will be merged into notmuch.

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


Re: remove attachments

2016-12-07 Thread MaDhAt2r

When you say detach, do you mean to open them, save them, or delete them
from the actual email?

On Dec 07 at 02:02 PM, Daniele Arosio said thus:
> Dear all,
> I come across notmuch only recently and I am about to switch to it, but 
> I still missing a way to detach files (like pdf, docx...) from my emails 
> sitting say in inbox.
>
> Is there any way to accomplish attachment deletion through emacs front 
> end or any other command line approach?
>
> Thanks
>
> daniele
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v4 2/2] notmuch-config: replace config reading function

2016-12-07 Thread Tomi Ollila
On Mon, Dec 05 2016, Ioan-Adrian Ratiu  wrote:

> Config files are currently read using glib's g_key_file_load_from_file
> function which is very inconvenient because it's limited by design to read
> only from "regular data files" in a filesystem. Because of this limitation
> notmuch can't read configs from pipes, fifos, sockets, stdin, etc. Not even
> "notmuch --config=/dev/stdin" works:
>
> Error reading configuration file /dev/stdin: Not a regular file
>
> So replace g_key_file_load_from_file with g_key_file_load_from_data which
> gives us much more freedom to read configs from multiple sources.
>
> This also helps the more security sensitive users: If someone has private
> information in the config file, it can be encrypted on disk, then decrypted
> in RAM and passed through a pipe directly to notmuch without the use of
> intermediate plain text files.
>
> Signed-off-by: Ioan-Adrian Ratiu 
> ---
>  notmuch-config.c | 58 
> ++--
>  1 file changed, 48 insertions(+), 10 deletions(-)
>
> diff --git a/notmuch-config.c b/notmuch-config.c
> index bd52790..fe16fa3 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -205,32 +205,70 @@ get_username_from_passwd_file (void *ctx)
>  static notmuch_bool_t
>  get_config_from_file (notmuch_config_t *config, notmuch_bool_t create_new)
>  {
> +#define BUF_SIZE 4096
> +char *config_str = NULL;
> +int config_len = 0;
> +int config_bufsize = BUF_SIZE;
> +size_t len;
>  GError *error = NULL;
>  notmuch_bool_t ret = FALSE;
>  
> -if (g_key_file_load_from_file (config->key_file, config->filename,
> -G_KEY_FILE_KEEP_COMMENTS, &error))
> - return TRUE;
> -
> -if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT) {
> +FILE *fp = fopen(config->filename, "r");
> +if (fp == NULL) {
>   /* If create_new is true, then the caller is prepared for a
>* default configuration file in the case of FILE NOT FOUND.
>*/
>   if (create_new) {
>   config->is_new = TRUE;
>   ret = TRUE;
> + goto out;
>   } else {
> - fprintf (stderr, "Configuration file %s not found.\n"
> + fprintf (stderr, "Error opening config file '%s': %s\n"
>"Try running 'notmuch setup' to create a configuration.\n",
> -  config->filename);
> +  config->filename, strerror(errno));
> + goto out;
>   }
> -} else {
> - fprintf (stderr, "Error reading configuration file %s: %s\n",
> -  config->filename, error->message);
>  }
>  
> +config_str = talloc_zero_array (config, char, config_bufsize);
> +if (config_str == NULL) {
> + fprintf (stderr, "Error reading '%s': Out of memory\n", 
> config->filename);
> + goto out;
> +}
> +
> +while ((len = fread (config_str + config_len, 1,
> +  config_bufsize - config_len, fp)) > 0) {
> + config_len += len;
> + if (config_len == config_bufsize) {
> + config_bufsize += BUF_SIZE;
> + config_str = talloc_realloc (config, config_str, char, 
> config_bufsize);
> + if (config_str == NULL) {
> + fprintf (stderr, "Error reading '%s': Failed to reallocate 
> memory\n",
> +  config->filename);
> + goto out;
> + }
> + }
> +}
> +
> +if (ferror (fp)) {
> + fprintf (stderr, "Error reading '%s': I/O error\n", config->filename);
> + goto out;
> +}
> +
> +if (g_key_file_load_from_data (config->key_file, config_str, 
> strlen(config_str),

How sticky can this strlen() be ? config_len !

> +G_KEY_FILE_KEEP_COMMENTS, &error)) {
> + ret = TRUE;
> + goto out;
> +}
> +
> +fprintf (stderr, "Error parsing config file '%s': %s\n",
> +  config->filename, error->message);
> +
>  g_error_free (error);
>  
> +out:
> +fclose(fp);

need to check that fp != NULL -- fclose() manual page does not state
calling fclose(NULL) is supported.

> +if (config_str) talloc_free(config_str);

You copied my code verbatim ;/ better write if() and talloc_free() to
separate lines (also fclose() when updated)

no other comments from me.

Tomi

>  return ret;
>  }
>  
> -- 
> 2.10.2
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: remove attachments

2016-12-07 Thread Daniele Arosio

I mean delete.

On 12/07/2016 04:05 PM, MaDhAt2r wrote:


When you say detach, do you mean to open them, save them, or delete them
from the actual email?

On Dec 07 at 02:02 PM, Daniele Arosio said thus:

Dear all,
I come across notmuch only recently and I am about to switch to it, but
I still missing a way to detach files (like pdf, docx...) from my emails
sitting say in inbox.

Is there any way to accomplish attachment deletion through emacs front
end or any other command line approach?

Thanks

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

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


[PATCH 1/2] emacs: restore autoload cookie for notmuch-search

2016-12-07 Thread David Bremner
The cookie only applies to next form, so in the previous location it
applied to the put, rather than the function.
---
 emacs/notmuch.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 68a4c0b..46f14fe 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -931,8 +931,8 @@ PROMPT is the string to prompt with."
   "Return the current query in this search buffer"
   notmuch-search-query-string)
 
-;;;###autoload
 (put 'notmuch-search 'notmuch-doc "Search for messages.")
+;;;###autoload
 (defun notmuch-search (&optional query oldest-first target-thread target-line)
   "Display threads matching QUERY in a notmuch-search buffer.
 
-- 
2.10.2

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


[PATCH 2/2] NEWS: announce autoload fix

2016-12-07 Thread David Bremner
---
 NEWS | 5 +
 1 file changed, 5 insertions(+)

diff --git a/NEWS b/NEWS
index c0aa479..a7d4c20 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,11 @@ Improve error handling in notmuch insert
   filesystem.  Certain errors during `notmuch insert` most likely to
   be temporary return EX_TEMPFAIL.
 
+Emacs
+-
+
+Restore autoload cookie for notmuch-search.
+
 Notmuch 0.23.3 (2016-11-27)
 ===
 
-- 
2.10.2

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


Fix for notmuch-search autoload cookie

2016-12-07 Thread David Bremner
If your using the elpa packages (e.g. in recent debian packages), you might have
noticed that the autoloading of notmuch-search was not working.

This is a fix for that. You can test it by running:

emacs -q
M-x package-initialize
M-x notmuch-search

Before this patch, it won't work; after, it will (assuming you install
the elpa package).

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