How to debug 'ignoring non-mail file' issues

2014-09-03 Thread Jani Nikula
On Wed, 03 Sep 2014, Perttu Luukko  wrote:
> What I mean that there would be a separate error for cases "Does not
> resemble an email message at all", i.e., some control file your mail
> server happens to store in the mailbox, and "Looks like mail but we
> can't parse it", i.e., better find out why it can't be parsed to avoid
> potentially important messages going missing from the database.

As I said, GMime does not tell us the difference between the two.

BR,
Jani.


[PATCH] cli: Be more helpful when .notmuch-config does not exist

2014-09-03 Thread Austin Clements
Previously, if the user ran any subcommand that required a
configuration (e.g., notmuch new) but didn't have a configuration,
notmuch would give the rather un-friendly and un-actionable message

  Error reading configuration file .notmuch-config: No such file or directory

Since this condition is expected for new users, this patch adds
specific handling for the file-not-found case to give a message that
is friendly and actionable.
---
 notmuch-config.c   | 26 --
 test/T040-setup.sh |  6 ++
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index db487db..a564bca 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -283,16 +283,22 @@ notmuch_config_open (void *ctx,
 G_KEY_FILE_KEEP_COMMENTS,
 ))
 {
-   /* If create_new is true, then the caller is prepared for a
-* default configuration file in the case of FILE NOT
-* FOUND. Otherwise, any read failure is an error.
-*/
-   if (create_new &&
-   error->domain == G_FILE_ERROR &&
-   error->code == G_FILE_ERROR_NOENT)
-   {
-   g_error_free (error);
-   config->is_new = TRUE;
+   if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT) 
{
+   /* 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) {
+   g_error_free (error);
+   config->is_new = TRUE;
+   } else {
+   fprintf (stderr, "Configuration file %s not found.\n"
+"Try running 'notmuch setup' to create a 
configuration.\n",
+config->filename);
+   talloc_free (config);
+   g_error_free (error);
+   return NULL;
+   }
}
else
{
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 124ef1c..b1972e7 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -3,6 +3,12 @@
 test_description='"notmuch setup"'
 . ./test-lib.sh

+test_begin_subtest "Notmuch new without a config suggests notmuch setup"
+output=$(notmuch --config=new-notmuch-config new 2>&1)
+test_expect_equal "$output" "\
+Configuration file new-notmuch-config not found.
+Try running 'notmuch setup' to create a configuration."
+
 test_begin_subtest "Create a new config interactively"
 notmuch --config=new-notmuch-config > /dev/null <

sending email using different server for different 'From:' field

2014-09-03 Thread David Belohrad
oukej. this seems to be exactly what I'm looking for. Is there a way how
to 'cycle' in notmuch different From: fields? I'd need to setup like 3
addresses, each of them with different signatures and be able to easily
switch between them

thanks
.d.


Keith Amidon  writes:

> On Tue, 2014-09-02 at 14:26 +0200, David Belohrad wrote:
>> could that scenario be somehow fitted automatically, so when I overwrite
>> the default 'From:' address (by hand. is it possible to do some
>> automatic cycling?) to work address, so that message sender in emacs
>> would automatically use work exchange server to deliver the mail?
>
> I think this is more of a message-mode question than a notmuch question.
> I use something very similar to code attached below, which is rather
> brute-force, but does the job for me.
>
>  --- Keith
>
> -
>
> (defun kea/send-mail-with-x ()
>   (interactive)
>   (setq smtpmail-smtp-server "smtp.x.com"
> smtpmail-smtp-service 587
> smtpmail-local-domain "x.com"
> smtpmail-auth-user nil
> smtpmail-stream-type 'starttls))
>
> (defun kea/send-mail-with-y ()
>   (interactive)
>   (setq smtpmail-smtp-server "email.y.com"
> smtpmail-smtp-service 587
> smtpmail-local-domain "y.com"
> smtpmail-auth-user nil
> smtpmail-stream-type 'starttls))
>
> (defun kea/message-select-mail-dest ()
>   (cond ((string-match ""
>(message-field-value "From"))
>  (kea/send-mail-with-x))
> (t
>  (kea/send-mail-with-y
>
> (kea/send-mail-with-y)
> (add-hook 'message-send-hook 'kea/message-select-mail-dest)


How to debug 'ignoring non-mail file' issues

2014-09-03 Thread Perttu Luukko
On 2014-09-02 23:37:12, Jani Nikula wrote:
> On Mon, 01 Sep 2014, Perttu Luukko  wrote:
> > Yes, upgrading to GMime 2.6.20 caused all the messages on my server
> > classified as mail.
> 
> What was the old version? If it was 2.4 we should probably consider
> dropping support for that in future notmuch.

It was 2.4.33. It might still work for other people, I don't know. I
still have some ignored mails. If I can nail down why they are ignored
we might now more about why GMime 2.4 ignored even more mail. They were
from around the same time period, so it might have something to do with
the email setup I had at that time.

> > Even more reason to give a separate warning for GMime parse errors.
> 
> Not sure. We only get a binary success/fail from GMime, and that gets
> printed for all non-email files. I'm not sure it's helpful.

What I mean that there would be a separate error for cases "Does not
resemble an email message at all", i.e., some control file your mail
server happens to store in the mailbox, and "Looks like mail but we
can't parse it", i.e., better find out why it can't be parsed to avoid
potentially important messages going missing from the database.

-- 
Perttu


How to debug 'ignoring non-mail file' issues

2014-09-03 Thread Jani Nikula
On Mon, 01 Sep 2014, Perttu Luukko  wrote:
> Yes, upgrading to GMime 2.6.20 caused all the messages on my server
> classified as mail.

What was the old version? If it was 2.4 we should probably consider
dropping support for that in future notmuch.

> Even more reason to give a separate warning for GMime parse errors.

Not sure. We only get a binary success/fail from GMime, and that gets
printed for all non-email files. I'm not sure it's helpful.

BR,
Jani.


[PATCH v2] emacs: jump: sort-order bugfix

2014-09-03 Thread Jani Nikula
On Tue, 02 Sep 2014, Mark Walters  wrote:
> default-value needs its argument to be quoted.
>
> Slightly strangely default-value of 't or nil is 't or nil
> respectively so the code
>
> (default-value notmuch-search-oldest-first)
>
> just gives the current value of notmuch-search-oldest-first rather
> than intended default-value of this variable.
>
> The symptom is that if you are in a search buffer and use notmuch jump
> to run a saved search which does not have an explicitly set sort order
> then the sort order of the saved-search is inherited from the current
> search buffer rather than being the default search order.
>
> Thanks to Jani for finding the bug.

This fixes the issue, thanks for the patch.

Jani.



> ---
>
> This time with a fuller commit message.
>
> (Part of the reason I did not send more before is I had not checked
> what the exact outcome of the buggy code was: it was obvious what the
> code was intended to do, and that with the extra quote it
> would do what it was intended to do.)
>
> Best wishes
>
> Mark
>
>
>
>
>
>
>
>  emacs/notmuch-jump.el |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
> index 5eb0949..0193f8c 100644
> --- a/emacs/notmuch-jump.el
> +++ b/emacs/notmuch-jump.el
> @@ -51,7 +51,7 @@ (defun notmuch-jump-search ()
>(case (plist-get saved-search :sort-order)
>  (newest-first nil)
>  (oldest-first t)
> -(otherwise (default-value notmuch-search-oldest-first)
> +(otherwise (default-value 'notmuch-search-oldest-first)
>   (push (list key name
>   `(lambda () (notmuch-search ',query ',oldest-first)))
> action-map)
> -- 
> 1.7.10.4
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Re: sending email using different server for different 'From:' field

2014-09-03 Thread David Belohrad
oukej. this seems to be exactly what I'm looking for. Is there a way how
to 'cycle' in notmuch different From: fields? I'd need to setup like 3
addresses, each of them with different signatures and be able to easily
switch between them

thanks
.d.


Keith Amidon cama...@picnicpark.org writes:

 On Tue, 2014-09-02 at 14:26 +0200, David Belohrad wrote:
 could that scenario be somehow fitted automatically, so when I overwrite
 the default 'From:' address (by hand. is it possible to do some
 automatic cycling?) to work address, so that message sender in emacs
 would automatically use work exchange server to deliver the mail?

 I think this is more of a message-mode question than a notmuch question.
 I use something very similar to code attached below, which is rather
 brute-force, but does the job for me.

  --- Keith

 -

 (defun kea/send-mail-with-x ()
   (interactive)
   (setq smtpmail-smtp-server smtp.x.com
 smtpmail-smtp-service 587
 smtpmail-local-domain x.com
 smtpmail-auth-user nil
 smtpmail-stream-type 'starttls))

 (defun kea/send-mail-with-y ()
   (interactive)
   (setq smtpmail-smtp-server email.y.com
 smtpmail-smtp-service 587
 smtpmail-local-domain y.com
 smtpmail-auth-user nil
 smtpmail-stream-type 'starttls))

 (defun kea/message-select-mail-dest ()
   (cond ((string-match k...@x.com
(message-field-value From))
  (kea/send-mail-with-x))
 (t
  (kea/send-mail-with-y

 (kea/send-mail-with-y)
 (add-hook 'message-send-hook 'kea/message-select-mail-dest)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: sending email using different server for different 'From:' field

2014-09-03 Thread Mark Walters

Hi

On Wed, 03 Sep 2014, David Belohrad da...@belohrad.ch wrote:
 oukej. this seems to be exactly what I'm looking for. Is there a way how
 to 'cycle' in notmuch different From: fields? I'd need to setup like 3
 addresses, each of them with different signatures and be able to easily
 switch between them

You might finding setting notmuch-always-prompt-for-sender to 't is
what you want (you can set if in customise or directly)

This prompts you for the sender address and takes options from your
notmuch config file (that is from user.primary_email and
user.other_email from .notmuch-config) so will quite possibly just work.



 (defun kea/message-select-mail-dest ()
   (cond ((string-match k...@x.com
(message-field-value From))
  (kea/send-mail-with-x))
 (t
  (kea/send-mail-with-y

 (kea/send-mail-with-y)
 (add-hook 'message-send-hook 'kea/message-select-mail-dest)

I will also mention an alternative approach to using hooks here. You
could customise message-send-mail-function to be your own function which
let binds the appropriate send-mail settings and have that call the
actual send-mail function (eg message-send-mail-with-sendmail)

Best wishes

Mark

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


[PATCH] cli: Be more helpful when .notmuch-config does not exist

2014-09-03 Thread Austin Clements
Previously, if the user ran any subcommand that required a
configuration (e.g., notmuch new) but didn't have a configuration,
notmuch would give the rather un-friendly and un-actionable message

  Error reading configuration file .notmuch-config: No such file or directory

Since this condition is expected for new users, this patch adds
specific handling for the file-not-found case to give a message that
is friendly and actionable.
---
 notmuch-config.c   | 26 --
 test/T040-setup.sh |  6 ++
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index db487db..a564bca 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -283,16 +283,22 @@ notmuch_config_open (void *ctx,
 G_KEY_FILE_KEEP_COMMENTS,
 error))
 {
-   /* If create_new is true, then the caller is prepared for a
-* default configuration file in the case of FILE NOT
-* FOUND. Otherwise, any read failure is an error.
-*/
-   if (create_new 
-   error-domain == G_FILE_ERROR 
-   error-code == G_FILE_ERROR_NOENT)
-   {
-   g_error_free (error);
-   config-is_new = TRUE;
+   if (error-domain == G_FILE_ERROR  error-code == G_FILE_ERROR_NOENT) 
{
+   /* 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) {
+   g_error_free (error);
+   config-is_new = TRUE;
+   } else {
+   fprintf (stderr, Configuration file %s not found.\n
+Try running 'notmuch setup' to create a 
configuration.\n,
+config-filename);
+   talloc_free (config);
+   g_error_free (error);
+   return NULL;
+   }
}
else
{
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 124ef1c..b1972e7 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -3,6 +3,12 @@
 test_description='notmuch setup'
 . ./test-lib.sh
 
+test_begin_subtest Notmuch new without a config suggests notmuch setup
+output=$(notmuch --config=new-notmuch-config new 21)
+test_expect_equal $output \
+Configuration file new-notmuch-config not found.
+Try running 'notmuch setup' to create a configuration.
+
 test_begin_subtest Create a new config interactively
 notmuch --config=new-notmuch-config  /dev/null EOF
 Test Suite
-- 
2.1.0

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


Re: How to debug 'ignoring non-mail file' issues

2014-09-03 Thread Jani Nikula
On Wed, 03 Sep 2014, Perttu Luukko perttu.luu...@iki.fi wrote:
 What I mean that there would be a separate error for cases Does not
 resemble an email message at all, i.e., some control file your mail
 server happens to store in the mailbox, and Looks like mail but we
 can't parse it, i.e., better find out why it can't be parsed to avoid
 potentially important messages going missing from the database.

As I said, GMime does not tell us the difference between the two.

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


Re: [PATCH] cli: Be more helpful when .notmuch-config does not exist

2014-09-03 Thread Carl Worth
Austin Clements amdra...@mit.edu writes:
 Since this condition is expected for new users, this patch adds
 specific handling for the file-not-found case to give a message that
 is friendly and actionable.
...
 + fprintf (stderr, Configuration file %s not found.\n
 +  Try running 'notmuch setup' to create a 
 configuration.\n,
 +  config-filename);

Thanks, Austin!

I've always wanted notmuch to provide as gentle an introduction as
possible, (since switching MUA and indexing all email[*] is already a
fairly invasive thing).

So I really appreciate improvements like this.

 +test_begin_subtest Notmuch new without a config suggests notmuch setup
 +output=$(notmuch --config=new-notmuch-config new 21)
 +test_expect_equal $output \
 +Configuration file new-notmuch-config not found.
 +Try running 'notmuch setup' to create a configuration.

And a test to boot. That really warms my heart.

-Carl

[*] A further possible improvement here would be some mechanism for
initially indexing only very recent email, (to let the user start
playing with notmuch right away), and then in some sort of ''offline''
fashion, completing the full indexing.


pgpf52pf6_z_w.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] emacs: jump: sort-order bugfix

2014-09-03 Thread Carl Worth
Mark Walters markwalters1...@gmail.com writes:
 The symptom is that if you are in a search buffer and use notmuch jump
 to run a saved search which does not have an explicitly set sort order
 then the sort order of the saved-search is inherited from the current
 search buffer rather than being the default search order.

 Thanks to Jani for finding the bug.

Thanks, Mark. The description above is just what I was looking for.

 (Part of the reason I did not send more before is I had not checked
 what the exact outcome of the buggy code was: it was obvious what the
 code was intended to do, and that with the extra quote it
 would do what it was intended to do.)

Yes. I understand now how the bug-fix was more obvious than the bug.

But thanks for doing the extra investigation nonetheless.

-Carl


pgpUyACD1apZc.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: How to debug 'ignoring non-mail file' issues

2014-09-03 Thread Perttu Luukko
On 2014-09-03 19:03:40, Jani Nikula wrote:
 On Wed, 03 Sep 2014, Perttu Luukko perttu.luu...@iki.fi wrote:
  What I mean that there would be a separate error for cases Does not
  resemble an email message at all, i.e., some control file your mail
  server happens to store in the mailbox, and Looks like mail but we
  can't parse it, i.e., better find out why it can't be parsed to avoid
  potentially important messages going missing from the database.
 
 As I said, GMime does not tell us the difference between the two.

There could be a separate parsing step that reads the first kilobyte or
so and checks whether it is text, and whether there is a line starting
with From:  and possibly other headers. This could be run if GMime
thinks the file is not mail so there would be negligible overhead.

This is just a suggestion. Notmuch users are probably quite experienced
so they can always investigate on their own why their emails are being
ignored. But there could be more warning about ignored messages.
Something like, at the end of each 'notmuch new' output: Note: some
files were ignored as non-mail. Check the list at
~/mail/.notmuch/ignored-files and adjust your ~/.notmuch-config.

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