Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / de / 4e91d8640d0f3a6f33850b8ce47ec361e84519
1 Return-Path: <bijan.chokoufe@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id AD9906DE0173\r
6  for <notmuch@notmuchmail.org>; Mon,  9 May 2016 14:57:39 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.82\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.82 tagged_above=-999 required=5\r
12  tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
14  RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled\r
15 Received: from arlo.cworth.org ([127.0.0.1])\r
16  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
17  with ESMTP id HgjtoxGPjqgU for <notmuch@notmuchmail.org>;\r
18  Mon,  9 May 2016 14:57:30 -0700 (PDT)\r
19 Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com\r
20  [74.125.82.44]) by arlo.cworth.org (Postfix) with ESMTPS id D2B846DE00DB for\r
21  <notmuch@notmuchmail.org>; Mon,  9 May 2016 14:57:29 -0700 (PDT)\r
22 Received: by mail-wm0-f44.google.com with SMTP id e201so154658009wme.0\r
23  for <notmuch@notmuchmail.org>; Mon, 09 May 2016 14:57:29 -0700 (PDT)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
25  h=date:from:to:cc:subject:message-id:references:mime-version\r
26  :content-disposition:in-reply-to:user-agent;\r
27  bh=rL/zsVsC0UgazDnXZ/73RVtYwEuNWltJGlZPul6vkPQ=;\r
28  b=mRRyC5O6gW2gZ9IeOFCPVlbS4J2qSDff2z08aGVz8g8BabjnWMfp9p+s7shk9KjiPJ\r
29  /0WNwfvaoqXyBfBflV+tkzwY+6OelK0T+VMU5wRKmgxaZcCNOMWj09YEjLrtRJoGTpqY\r
30  X45nMAqMu7coXGJkoLVv6ZPCK7OQqck0LMW9faaT1zasaYIvelhSdbL/EjNaHBbMVicO\r
31  fByxFXw8lUQrreLyBmfv/VIze3qCEi1YJA2GS6tFxM6Si7HGNZafpXUiyjwdJGPLybMK\r
32  bQHLUtlH2s7ivuGz2ZfQ95jfJyKf/zgFhllsZm7p0Kr+/D6/Hno2zIoaMGZjzejH79VO\r
33  Ii/A==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:date:from:to:cc:subject:message-id:references\r
37  :mime-version:content-disposition:in-reply-to:user-agent;\r
38  bh=rL/zsVsC0UgazDnXZ/73RVtYwEuNWltJGlZPul6vkPQ=;\r
39  b=aJ1V6za7SrkYTpANwT4s0CoO92wyyxhQ3iz4gRkkNd60UwDA6h+k412xyZbWzQi4hI\r
40  R8ngtKZKrJv9He55tELw/t1fqQ+W3nCdDm6phPtkg9mL9FJ4Zxm/uO+byRODbbwj6U3G\r
41  xIuiOArDqo0miZZBmlg9akYsu0OE28OLzsNpzjAMcHBmQhePJdMFfrnjVJPbmosxexXI\r
42  /gIw0+GIYePTfIuAon53nBgNaLm9d+XyThgEt+Zy20Wb9ir7wJHs7h8oQQmtCgbJB5ZH\r
43  CFflFdc78lh+cerEvssBLY9DhvJ6yiHGau/sqplddkTI2CXpRxv+ESJa1wEPVGEioLzT\r
44  HBcw==\r
45 X-Gm-Message-State:\r
46  AOPr4FXw9CAxPkKDq6/zK9lN4blUG8YEcZV9cggPLQT37EWvhPe/Y9XppEIemuRZnjpzlQ==\r
47 X-Received: by 10.194.248.135 with SMTP id ym7mr35496223wjc.174.1462831048115;\r
48   Mon, 09 May 2016 14:57:28 -0700 (PDT)\r
49 Received: from localhost (ip5f5be327.dynamic.kabel-deutschland.de.\r
50  [95.91.227.39])\r
51  by smtp.gmail.com with ESMTPSA id z125sm16796108wmg.24.2016.05.09.14.57.26\r
52  (version=TLS1_2 cipher=AES128-SHA bits=128/128);\r
53  Mon, 09 May 2016 14:57:26 -0700 (PDT)\r
54 Date: Mon, 9 May 2016 23:57:24 +0200\r
55 From: Bijan Chokoufe Nejad <bijan.chokoufe@gmail.com>\r
56 To: Tomi Ollila <tomi.ollila@iki.fi>\r
57 Cc: notmuch@notmuchmail.org\r
58 Subject: Re: [PATCH] config: Expand ~ to $HOME\r
59 Message-ID: <20160509215724.GA3634@600B5B>\r
60 References: <1462722574-4176-1-git-send-email-bijan@chokoufe.com>\r
61  <m2r3dc7azk.fsf@guru.guru-group.fi>\r
62  <CAOsAL0pp+3b-sf_k5kdrN7r1W8EtkC2vJ44Mg-e+su-8V=H6bQ@mail.gmail.com>\r
63  <m21t5bll8y.fsf@guru.guru-group.fi>\r
64 MIME-Version: 1.0\r
65 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd"\r
66 Content-Disposition: inline\r
67 In-Reply-To: <m21t5bll8y.fsf@guru.guru-group.fi>\r
68 User-Agent: Mutt/1.5.21 (2010-09-15)\r
69 X-Mailman-Approved-At: Mon, 09 May 2016 21:23:46 -0700\r
70 X-BeenThere: notmuch@notmuchmail.org\r
71 X-Mailman-Version: 2.1.20\r
72 Precedence: list\r
73 List-Id: "Use and development of the notmuch mail system."\r
74  <notmuch.notmuchmail.org>\r
75 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
76  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
77 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
78 List-Post: <mailto:notmuch@notmuchmail.org>\r
79 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
80 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
81  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
82 X-List-Received-Date: Mon, 09 May 2016 21:57:39 -0000\r
83 \r
84 \r
85 --ZPt4rx8FFjLCG7dd\r
86 Content-Type: text/plain; charset=us-ascii\r
87 Content-Disposition: inline\r
88 \r
89 On 16-05-09, Tomi Ollila wrote:\r
90 > On Sun, May 08 2016, Bijan Chokoufe <bijan@chokoufe.com> wrote:\r
91\r
92 > > Hi Tomi,\r
93 > >\r
94 > > Thanks for your detailled review. Please see questions below.\r
95 > >\r
96 > > Cheers,\r
97 > > Bijan\r
98 > >\r
99 > > Tomi Ollila <tomi.ollila@iki.fi> schrieb am So., 8. Mai 2016 um 18:47 Uhr:\r
100 > >\r
101 > >> On Sun, May 08 2016, Bijan Chokoufe Nejad <bijan@chokoufe.com> wrote:\r
102 > >>\r
103 > >> > Very useful in case you want to keep your .notmuch-config synchronized\r
104 > >> across\r
105 > >> > machines where you have different user names.\r
106 > >>\r
107 > >> Thank you for your interest in improving notmuch!\r
108 > >>\r
109 > >> There are a few things that needs to be sorted out for this feature to be\r
110 > >> good:\r
111 > >>\r
112 > >> This implementation does not handle ~user/ prefix: i.e. home directory of\r
113 > >> 'user' (maybe this should not, but it should handle the case).\r
114 > >\r
115 > > I don't get it. Is '~user" an alternative to '~'?\r
116\r
117 > ~user is ~ in case you're 'user' -- except that now that I think of it\r
118 > ~user could read home directory from /etc/passwd and not using $HOME.\r
119 > If you're 'eve', then ~alice should definitely be different than ~\r
120 \r
121 OK I see. I never used ~user instead of ~ and don't see any advantage in using\r
122 ~user but good to know it's there.\r
123 \r
124\r
125 > >\r
126 > >> Whether or not ~user is handled, it should check that slash (/) follows...\r
127 > >>\r
128 > >>\r
129 > > So I guess you aim at the case where someone sets `path=~`? On the other\r
130 > > hand why is this checking not necessary in the "normal" case where no\r
131 > > expanding of `~` is done? Or is it maybe already handled in\r
132 > > `lib/database.cc`. Just to be clear I tested that it works currently with\r
133 > > `path=~/.mail`.\r
134\r
135 > your code checked that path[0] == '~', but nothing else, e.g.\r
136\r
137 > ~123randomstuff/... would expand as /home/user23randomstuff/... \r
138\r
139 > ... and you have good point path being set as single '~' !\r
140\r
141 > >> IIRC there is some ready-made implementations of the above -- but if not,\r
142 > >> one option is to check how (expand-file-name) works in emacs for reference.\r
143 > >>\r
144 > >>\r
145 > > Well there is wordexp (http://linux.die.net/man/3/wordexp) but I wasn't\r
146 > > sure if I should use it. The getenv just seemed simpler but maybe it is\r
147 > > necessary.\r
148\r
149 > For the time being we could simply do checking that path[0] == '~' and\r
150 > path[1] == '/' and then do expansion based on getenv ("HOME") -- and\r
151 > comment that ~any_user is just not supported there.\r
152 \r
153 alright, done. I am still a bit confused by the way you do pull request here.\r
154 I am attaching the rebased commit as git patch. Is this correct or should I use\r
155 git send-email again? How do you keep track of lengthy PRs with this workflow?\r
156 \r
157 Cheers,\r
158 Bijan\r
159 \r
160\r
161 > From testing point of view doing one positive test which ensures that when\r
162 > HOME is a string pointing to valid directory (and does not end with\r
163 > trailing slash as it usually is) and path in configuration starts with '~/'\r
164 > (and does not have multiple slashes following) works as expected...\r
165\r
166 > (as a special case, from softare functionality point I don't see problem\r
167 > setting path=~/ but from usability point that might not be the best -- but\r
168 > some users may have peculiar preferences... ;D)\r
169\r
170 > Tomi\r
171 \r
172 --ZPt4rx8FFjLCG7dd\r
173 Content-Type: text/x-diff; charset=us-ascii\r
174 Content-Disposition: attachment;\r
175  filename="v2-0001-config-Expand-to-HOME.patch"\r
176 \r
177 >From ca6a86c6456d7fce2f18da8ec92d6d7ff14dc5f8 Mon Sep 17 00:00:00 2001\r
178 From: Bijan Chokoufe Nejad <bijan@chokoufe.com>\r
179 Date: Sun, 8 May 2016 15:47:50 +0200\r
180 Subject: [PATCH v2] config: Expand ~ to $HOME\r
181 \r
182 Very useful in case you want to keep your .notmuch-config synchronized across\r
183 machines where you have different user names.\r
184 \r
185 ---\r
186 Check for '~/' instead of checking for '~' and fix memory issue.\r
187 \r
188 Unit test is still pending\r
189 ---\r
190  notmuch-config.c | 10 +++++++++-\r
191  1 file changed, 9 insertions(+), 1 deletion(-)\r
192 \r
193 diff --git a/notmuch-config.c b/notmuch-config.c\r
194 index d252bb2..e97d5b0 100644\r
195 --- a/notmuch-config.c\r
196 +++ b/notmuch-config.c\r
197 @@ -605,7 +605,15 @@ _config_set_list (notmuch_config_t *config,\r
198  const char *\r
199  notmuch_config_get_database_path (notmuch_config_t *config)\r
200  {\r
201 -    return _config_get (config, &config->database_path, "database", "path");\r
202 +    const char* path = _config_get (config, &config->database_path, "database", "path");\r
203 +    /* '~user/some/path' is not supported but only '~/some/path' */\r
204 +    if (path != NULL && path[0] == '~' && path[1] == '/') {\r
205 +        char *home_path = getenv("HOME");\r
206 +        return talloc_asprintf (NULL, "%s/%s", home_path, path + 2);\r
207 +    }\r
208 +    else {\r
209 +        return path;\r
210 +    }\r
211  }\r
212  \r
213  void\r
214 -- \r
215 1.9.1\r
216 \r
217 \r
218 --ZPt4rx8FFjLCG7dd--\r