Search for "has an attachment"

2016-05-09 Thread Xu Wang
Hi,

I would like to search for messages from Jiang that have an attachment. I tried

from:Jiang attachment:
from:Jiang attachment:*
from:Jiang attachment:.*

and none seems to do what I want.

Perhaps the problem is that I want to search for "real' attachments
(e.g. not the multipart email things that are really the message).

Kind regards,

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


Re: [PATCH] config: Expand ~ to $HOME

2016-05-09 Thread Bijan Chokoufe Nejad
On 16-05-09, Tomi Ollila wrote:
> On Sun, May 08 2016, Bijan Chokoufe  wrote:
> 
> > Hi Tomi,
> >
> > Thanks for your detailled review. Please see questions below.
> >
> > Cheers,
> > Bijan
> >
> > Tomi Ollila  schrieb am So., 8. Mai 2016 um 18:47 Uhr:
> >
> >> On Sun, May 08 2016, Bijan Chokoufe Nejad  wrote:
> >>
> >> > Very useful in case you want to keep your .notmuch-config synchronized
> >> across
> >> > machines where you have different user names.
> >>
> >> Thank you for your interest in improving notmuch!
> >>
> >> There are a few things that needs to be sorted out for this feature to be
> >> good:
> >>
> >> This implementation does not handle ~user/ prefix: i.e. home directory of
> >> 'user' (maybe this should not, but it should handle the case).
> >
> > I don't get it. Is '~user" an alternative to '~'?
> 
> ~user is ~ in case you're 'user' -- except that now that I think of it
> ~user could read home directory from /etc/passwd and not using $HOME.
> If you're 'eve', then ~alice should definitely be different than ~

OK I see. I never used ~user instead of ~ and don't see any advantage in using
~user but good to know it's there.

> 
> >
> >> Whether or not ~user is handled, it should check that slash (/) follows...
> >>
> >>
> > So I guess you aim at the case where someone sets `path=~`? On the other
> > hand why is this checking not necessary in the "normal" case where no
> > expanding of `~` is done? Or is it maybe already handled in
> > `lib/database.cc`. Just to be clear I tested that it works currently with
> > `path=~/.mail`.
> 
> your code checked that path[0] == '~', but nothing else, e.g.
> 
> ~123randomstuff/... would expand as /home/user23randomstuff/... 
> 
> ... and you have good point path being set as single '~' !
> 
> >> IIRC there is some ready-made implementations of the above -- but if not,
> >> one option is to check how (expand-file-name) works in emacs for reference.
> >>
> >>
> > Well there is wordexp (http://linux.die.net/man/3/wordexp) but I wasn't
> > sure if I should use it. The getenv just seemed simpler but maybe it is
> > necessary.
> 
> For the time being we could simply do checking that path[0] == '~' and
> path[1] == '/' and then do expansion based on getenv ("HOME") -- and
> comment that ~any_user is just not supported there.

alright, done. I am still a bit confused by the way you do pull request here.
I am attaching the rebased commit as git patch. Is this correct or should I use
git send-email again? How do you keep track of lengthy PRs with this workflow?

Cheers,
Bijan

> 
> From testing point of view doing one positive test which ensures that when
> HOME is a string pointing to valid directory (and does not end with
> trailing slash as it usually is) and path in configuration starts with '~/'
> (and does not have multiple slashes following) works as expected...
> 
> (as a special case, from softare functionality point I don't see problem
> setting path=~/ but from usability point that might not be the best -- but
> some users may have peculiar preferences... ;D)
> 
> Tomi
>From ca6a86c6456d7fce2f18da8ec92d6d7ff14dc5f8 Mon Sep 17 00:00:00 2001
From: Bijan Chokoufe Nejad 
Date: Sun, 8 May 2016 15:47:50 +0200
Subject: [PATCH v2] config: Expand ~ to $HOME

Very useful in case you want to keep your .notmuch-config synchronized across
machines where you have different user names.

---
Check for '~/' instead of checking for '~' and fix memory issue.

Unit test is still pending
---
 notmuch-config.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index d252bb2..e97d5b0 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -605,7 +605,15 @@ _config_set_list (notmuch_config_t *config,
 const char *
 notmuch_config_get_database_path (notmuch_config_t *config)
 {
-return _config_get (config, &config->database_path, "database", "path");
+const char* path = _config_get (config, &config->database_path, "database", "path");
+/* '~user/some/path' is not supported but only '~/some/path' */
+if (path != NULL && path[0] == '~' && path[1] == '/') {
+char *home_path = getenv("HOME");
+return talloc_asprintf (NULL, "%s/%s", home_path, path + 2);
+}
+else {
+return path;
+}
 }
 
 void
-- 
1.9.1

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


Re: [PATCH] config: Expand ~ to $HOME

2016-05-09 Thread Tomi Ollila
On Mon, May 09 2016, Tomi Ollila  wrote:

> your code checked that path[0] == '~', but nothing else, e.g.
>
> ~123randomstuff/... would expand as /home/user23randomstuff/...

actually /home/user/23randomstuff/...

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


Re: [PATCH] config: Expand ~ to $HOME

2016-05-09 Thread Tomi Ollila
On Sun, May 08 2016, Bijan Chokoufe  wrote:

> Hi Tomi,
>
> Thanks for your detailled review. Please see questions below.
>
> Cheers,
> Bijan
>
> Tomi Ollila  schrieb am So., 8. Mai 2016 um 18:47 Uhr:
>
>> On Sun, May 08 2016, Bijan Chokoufe Nejad  wrote:
>>
>> > Very useful in case you want to keep your .notmuch-config synchronized
>> across
>> > machines where you have different user names.
>>
>> Thank you for your interest in improving notmuch!
>>
>> There are a few things that needs to be sorted out for this feature to be
>> good:
>>
>> This implementation does not handle ~user/ prefix: i.e. home directory of
>> 'user' (maybe this should not, but it should handle the case).
>
> I don't get it. Is '~user" an alternative to '~'?

~user is ~ in case you're 'user' -- except that now that I think of it
~user could read home directory from /etc/passwd and not using $HOME.
If you're 'eve', then ~alice should definitely be different than ~

>
>> Whether or not ~user is handled, it should check that slash (/) follows...
>>
>>
> So I guess you aim at the case where someone sets `path=~`? On the other
> hand why is this checking not necessary in the "normal" case where no
> expanding of `~` is done? Or is it maybe already handled in
> `lib/database.cc`. Just to be clear I tested that it works currently with
> `path=~/.mail`.

your code checked that path[0] == '~', but nothing else, e.g.

~123randomstuff/... would expand as /home/user23randomstuff/... 

... and you have good point path being set as single '~' !

>> IIRC there is some ready-made implementations of the above -- but if not,
>> one option is to check how (expand-file-name) works in emacs for reference.
>>
>>
> Well there is wordexp (http://linux.die.net/man/3/wordexp) but I wasn't
> sure if I should use it. The getenv just seemed simpler but maybe it is
> necessary.

For the time being we could simply do checking that path[0] == '~' and
path[1] == '/' and then do expansion based on getenv ("HOME") -- and
comment that ~any_user is just not supported there.

From testing point of view doing one positive test which ensures that when
HOME is a string pointing to valid directory (and does not end with
trailing slash as it usually is) and path in configuration starts with '~/'
(and does not have multiple slashes following) works as expected...

(as a special case, from softare functionality point I don't see problem
setting path=~/ but from usability point that might not be the best -- but
some users may have peculiar preferences... ;D)

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