--- /dev/null
+Return-Path: <bijan.chokoufe@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id BE0B76DE00EB\r
+ for <notmuch@notmuchmail.org>; Sun, 8 May 2016 11:50:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.469\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.469 tagged_above=-999 required=5\r
+ tests=[FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001,\r
+ HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id acRG5CZCUHQM for <notmuch@notmuchmail.org>;\r
+ Sun, 8 May 2016 11:50:51 -0700 (PDT)\r
+Received: from mail-ig0-f181.google.com (mail-ig0-f181.google.com\r
+ [209.85.213.181])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id CEF9C6DE0022\r
+ for <notmuch@notmuchmail.org>; Sun, 8 May 2016 11:50:50 -0700 (PDT)\r
+Received: by mail-ig0-f181.google.com with SMTP id bi2so87794004igb.0\r
+ for <notmuch@notmuchmail.org>; Sun, 08 May 2016 11:50:50 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:mime-version:references:in-reply-to:from:date\r
+ :message-id:subject:to;\r
+ bh=NGDpxcj6sKGZlBV7OaUWyVbyrUYcGEli/LR2N/qX1cM=;\r
+ b=XWnRhrTbm6SMl2nrv2nv6WRY956f1MFOuNknjPh2cJlNdhBtQWTlPq150f7oFmJpKz\r
+ 92qPlWPi/N+815BrmTe+IC4rAOOUInqDF0AUPWFYmCTZM3lyV7ntieFPPuT2BUx6V6QO\r
+ sAzhxoyKFx0wIflhxHiV/a+6iVpl++Xl1EDnKb1/EsdM8VAuWnaKY6Mao7ARpyPEMAg9\r
+ UQfH9lNE9YWv9COvAvJh2jHkSM7oC0WAqr9Kj6UyFDIyEBACZMt3osu0f4Xwx9ieWVQ+\r
+ Mh7B6nnvY5qvfS4VrOtFaoT0leZkA4+nVvmaWzFj1Klxl9rIGABsPbpS7Ittjf3HRsjt\r
+ fhog==\r
+X-Gm-Message-State: AOPr4FWWQPlt3k9LdRJtjrXS2oECufqS/9vZSTE94CDWMGLZhWiHE7pR/XuBsbSfuKRtiOwgiKbnPAwyU4SHig==\r
+X-Received: by 10.50.16.163 with SMTP id h3mr7451329igd.49.1462733449943; Sun,\r
+ 08 May 2016 11:50:49 -0700 (PDT)\r
+MIME-Version: 1.0\r
+References: <1462722574-4176-1-git-send-email-bijan@chokoufe.com>\r
+ <m2r3dc7azk.fsf@guru.guru-group.fi>\r
+In-Reply-To: <m2r3dc7azk.fsf@guru.guru-group.fi>\r
+From: Bijan Chokoufe <bijan@chokoufe.com>\r
+Date: Sun, 08 May 2016 18:50:40 +0000\r
+Message-ID:\r
+ <CAOsAL0pp+3b-sf_k5kdrN7r1W8EtkC2vJ44Mg-e+su-8V=H6bQ@mail.gmail.com>\r
+Subject: Re: [PATCH] config: Expand ~ to $HOME\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Content-Type: multipart/alternative; boundary=f46d04426cceaf612e0532592b3d\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 08 May 2016 18:50:59 -0000\r
+\r
+--f46d04426cceaf612e0532592b3d\r
+Content-Type: text/plain; charset=UTF-8\r
+\r
+Hi Tomi,\r
+\r
+Thanks for your detailled review. Please see questions below.\r
+\r
+Cheers,\r
+Bijan\r
+\r
+Tomi Ollila <tomi.ollila@iki.fi> schrieb am So., 8. Mai 2016 um 18:47 Uhr:\r
+\r
+> On Sun, May 08 2016, Bijan Chokoufe Nejad <bijan@chokoufe.com> wrote:\r
+>\r
+> > Very useful in case you want to keep your .notmuch-config synchronized\r
+> across\r
+> > machines where you have different user names.\r
+>\r
+> Thank you for your interest in improving notmuch!\r
+>\r
+> There are a few things that needs to be sorted out for this feature to be\r
+> good:\r
+>\r
+> This implementation does not handle ~user/ prefix: i.e. home directory of\r
+> 'user' (maybe this should not, but it should handle the case).\r
+>\r
+\r
+I don't get it. Is '~user" an alternative to '~'?\r
+\r
+Whether or not ~user is handled, it should check that slash (/) follows...\r
+>\r
+>\r
+So I guess you aim at the case where someone sets `path=~`? On the other\r
+hand why is this checking not necessary in the "normal" case where no\r
+expanding of `~` is done? Or is it maybe already handled in\r
+`lib/database.cc`. Just to be clear I tested that it works currently with\r
+`path=~/.mail`.\r
+\r
+\r
+> IIRC there is some ready-made implementations of the above -- but if not,\r
+> one option is to check how (expand-file-name) works in emacs for reference.\r
+>\r
+>\r
+Well there is wordexp (http://linux.die.net/man/3/wordexp) but I wasn't\r
+sure if I should use it. The getenv just seemed simpler but maybe it is\r
+necessary.\r
+\r
+\r
+>\r
+> Something more inline:\r
+>\r
+>\r
+> > ---\r
+> > Not sure this is completely plattform independent.\r
+>\r
+> The implementation looked like it is platform independent -- at least on\r
+> plattforms we care about...\r
+>\r
+> > I also don't know how to implement a unit test for this.\r
+>\r
+> I know... and I can do that if we get 1) decide that this feature will be\r
+> supported and 2) decide how this feature should work and 3) someone(tm)\r
+> does proper implementation ;)\r
+>\r
+> Tomi\r
+>\r
+> PS: still more to follow below.\r
+>\r
+>\r
+> > ---\r
+> > notmuch-config.c | 11 ++++++++++-\r
+> > 1 file changed, 10 insertions(+), 1 deletion(-)\r
+> >\r
+> > diff --git a/notmuch-config.c b/notmuch-config.c\r
+> > index d252bb2..c9f26ef 100644\r
+> > --- a/notmuch-config.c\r
+> > +++ b/notmuch-config.c\r
+> > @@ -605,7 +605,16 @@ _config_set_list (notmuch_config_t *config,\r
+> > const char *\r
+> > notmuch_config_get_database_path (notmuch_config_t *config)\r
+> > {\r
+> > - return _config_get (config, &config->database_path, "database",\r
+> "path");\r
+> > + const char* path = _config_get (config, &config->database_path,\r
+> "database", "path");\r
+> > + if (path != NULL && path[0] == '~') {\r
+> > + char *home_path = getenv("HOME");\r
+> > + char *shortened_path = malloc( sizeof(char) * ( strlen (path) -\r
+> 1 ) );\r
+> > + strncpy(shortened_path, path + 2, strlen(path));\r
+> > + return talloc_asprintf (NULL, "%s/%s", home_path,\r
+> shortened_path);\r
+>\r
+> In the implementation above matching free() for malloc() is not done -- but\r
+> actually the malloc is unnecessary -- path + 2 could have been used there\r
+> (after one checked that path[1] is '/' (provided that ~/ were the only\r
+> thing we supported...))\r
+>\r
+> In strncpy() above length arg is strlen(path) but there is 1 byte less\r
+> allocated in shortened_path -- if src arg in the above strncpy() were\r
+> something else it could overwrite the allocated space by 2 bytes.\r
+>\r
+>\r
+Yes, sorry. My C is a little rusty ;). I was happy when it worked. But when\r
+we agree that wordexp is the way to go, this can be removed anyhow.\r
+\r
+\r
+>\r
+>\r
+> > + }\r
+> > + else {\r
+> > + return path;\r
+> > + }\r
+> > }\r
+> >\r
+> > void\r
+> > --\r
+> > 1.9.1\r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > https://notmuchmail.org/mailman/listinfo/notmuch\r
+>\r
+\r
+--f46d04426cceaf612e0532592b3d\r
+Content-Type: text/html; charset=UTF-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+<div dir=3D"ltr">Hi Tomi,<div><br></div><div>Thanks for your detailled revi=\r
+ew. Please see questions below.</div><div><br></div><div>Cheers,</div><div>=\r
+Bijan<br><br><div class=3D"gmail_quote"><div dir=3D"ltr">Tomi Ollila <<a=\r
+ href=3D"mailto:tomi.ollila@iki.fi">tomi.ollila@iki.fi</a>> schrieb am S=\r
+o., 8. Mai 2016 um 18:47=C2=A0Uhr:<br></div><blockquote class=3D"gmail_quot=\r
+e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=\r
+On Sun, May 08 2016, Bijan Chokoufe Nejad <<a href=3D"mailto:bijan@choko=\r
+ufe.com" target=3D"_blank">bijan@chokoufe.com</a>> wrote:<br>\r
+<br>\r
+> Very useful in case you want to keep your .notmuch-config synchronized=\r
+ across<br>\r
+> machines where you have different user names.<br>\r
+<br>\r
+Thank you for your interest in improving notmuch!<br>\r
+<br>\r
+There are a few things that needs to be sorted out for this feature to be<b=\r
+r>\r
+good:<br>\r
+<br>\r
+This implementation does not handle ~user/ prefix: i.e. home directory of<b=\r
+r>\r
+'user' (maybe this should not, but it should handle the case).<span=\r
+ style=3D"line-height:1.5">=C2=A0</span><br></blockquote><div>=C2=A0</div><=\r
+div>I don't get it. Is '~user" an alternative to '~'?<=\r
+/div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=\r
+ .8ex;border-left:1px #ccc solid;padding-left:1ex">\r
+Whether or not ~user is handled, it should check that slash (/) follows...<=\r
+br>\r
+<br></blockquote><div><br></div><div>So I guess you aim at the case where s=\r
+omeone sets `path=3D~`? On the other hand why is this checking not necessar=\r
+y in the "normal" case where no expanding of `~` is done? Or is i=\r
+t maybe already handled in `lib/database.cc`. Just to be clear I tested tha=\r
+t it works currently with `path=3D~/.mail`.</div><div>=C2=A0</div><blockquo=\r
+te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=\r
+lid;padding-left:1ex">\r
+IIRC there is some ready-made implementations of the above -- but if not,<b=\r
+r>\r
+one option is to check how (expand-file-name) works in emacs for reference.=\r
+<br>\r
+<br></blockquote><div><br></div><div>Well there is wordexp (<a href=3D"http=\r
+://linux.die.net/man/3/wordexp">http://linux.die.net/man/3/wordexp</a>) but=\r
+ I wasn't sure if I should use it. The getenv just seemed simpler but m=\r
+aybe it is necessary.</div><div>=C2=A0</div><blockquote class=3D"gmail_quot=\r
+e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">\r
+<br>\r
+Something more inline:<br>\r
+<br>\r
+<br>\r
+> ---<br>\r
+> Not sure this is completely plattform independent.<br>\r
+<br>\r
+The implementation looked like it is platform independent -- at least on<br=\r
+>\r
+plattforms we care about...<br>\r
+<br>\r
+> I also don't know how to implement a unit test for this.<br>\r
+<br>\r
+I know... and I can do that if we get 1) decide that this feature will be<b=\r
+r>\r
+supported and 2) decide how this feature should work and 3) someone(tm)<br>\r
+does proper implementation ;)<br>\r
+<br>\r
+Tomi<br>\r
+<br>\r
+PS: still more to follow below.<br>\r
+<br>\r
+<br>\r
+> ---<br>\r
+>=C2=A0 notmuch-config.c | 11 ++++++++++-<br>\r
+>=C2=A0 1 file changed, 10 insertions(+), 1 deletion(-)<br>\r
+><br>\r
+> diff --git a/notmuch-config.c b/notmuch-config.c<br>\r
+> index d252bb2..c9f26ef 100644<br>\r
+> --- a/notmuch-config.c<br>\r
+> +++ b/notmuch-config.c<br>\r
+> @@ -605,7 +605,16 @@ _config_set_list (notmuch_config_t *config,<br>\r
+>=C2=A0 const char *<br>\r
+>=C2=A0 notmuch_config_get_database_path (notmuch_config_t *config)<br>\r
+>=C2=A0 {<br>\r
+> -=C2=A0 =C2=A0 return _config_get (config, &config->database_pa=\r
+th, "database", "path");<br>\r
+> +=C2=A0 =C2=A0 const char* path =3D _config_get (config, &config-&=\r
+gt;database_path, "database", "path");<br>\r
+> +=C2=A0 =C2=A0 if (path !=3D NULL && path[0] =3D=3D '~'=\r
+;) {<br>\r
+> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *home_path =3D getenv("HOME&quo=\r
+t;);<br>\r
+> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *shortened_path =3D malloc( sizeof(c=\r
+har) * ( strlen (path) - 1 ) );<br>\r
+> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 strncpy(shortened_path, path + 2, strlen(=\r
+path));<br>\r
+> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return talloc_asprintf (NULL, "%s/%s=\r
+", home_path, shortened_path);<br>\r
+<br>\r
+In the implementation above matching free() for malloc() is not done -- but=\r
+<br>\r
+actually the malloc is unnecessary -- path + 2 could have been used there<b=\r
+r>\r
+(after one checked that path[1] is '/' (provided that ~/ were the o=\r
+nly<br>\r
+thing we supported...))<br>\r
+<br>\r
+In strncpy() above length arg is strlen(path) but there is 1 byte less<br>\r
+allocated in shortened_path -- if src arg in the above strncpy() were<br>\r
+something else it could overwrite the allocated space by 2 bytes.<br>\r
+<br></blockquote><div><br></div><div>Yes, sorry. My C is a little rusty ;).=\r
+ I was happy when it worked. But when we agree that wordexp is the way to g=\r
+o, this can be removed anyhow.</div><div>=C2=A0</div><blockquote class=3D"g=\r
+mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=\r
+eft:1ex">\r
+<br>\r
+<br>\r
+> +=C2=A0 =C2=A0 }<br>\r
+> +=C2=A0 =C2=A0 else {<br>\r
+> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return path;<br>\r
+> +=C2=A0 =C2=A0 }<br>\r
+>=C2=A0 }<br>\r
+><br>\r
+>=C2=A0 void<br>\r
+> --<br>\r
+> 1.9.1<br>\r
+><br>\r
+> _______________________________________________<br>\r
+> notmuch mailing list<br>\r
+> <a href=3D"mailto:notmuch@notmuchmail.org" target=3D"_blank">notmuch@n=\r
+otmuchmail.org</a><br>\r
+> <a href=3D"https://notmuchmail.org/mailman/listinfo/notmuch" rel=3D"no=\r
+referrer" target=3D"_blank">https://notmuchmail.org/mailman/listinfo/notmuc=\r
+h</a><br>\r
+</blockquote></div></div></div>\r
+\r
+--f46d04426cceaf612e0532592b3d--\r