Re: [notmuch] Debian package

2010-03-04 Thread martin f krafft
also sprach Xavier Maillard  [2010.03.05.0611 +0100]:
> I am using Debian GNU/linux SID and notmuch and I'd like to be
> bleading edge with notmuch. So I am trying to figure out whether
> someone is maintaining a Debian package against notmuch git
> repository or not. If the former, that's nice.

http://packages.debian.org/search?keywords=notmuch

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"ah, but a man's reach should exceed his grasp,
 or what's a heaven for?"
-- robert browning
 
spamtraps: madduck.bo...@madduck.net


digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] Debian package

2010-03-04 Thread Xavier Maillard
Hi,

I am using Debian GNU/linux SID and notmuch and I'd like to be
bleading edge with notmuch. So I am trying to figure out whether
someone is maintaining a Debian package against notmuch git
repository or not. If the former, that's nice.

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


[notmuch] [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line

2010-03-04 Thread Michal Sojka
Hi again,

On Tue, 02 Mar 2010, Sebastian Spaeth wrote:
> Previously, we would output:
> 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth  SSpaeth.de> wrote:' now it is:
> 'On 2010-02-25, Sebastian Spaeth wrote:'
> 
> In case we don't find a '<' (as indicator for 'Realname '), we still 
> use the whole from address.
> 
> Signed-off-by: Sebastian Spaeth 
> ---
> This probably shows my lack of C skills quite nicely but it does the job for 
> me.
> 
>  notmuch-reply.c |   21 ++---
>  1 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 98f6442..929572f 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
> *config, notmuch_query_
>  GMimeMessage *reply;
>  notmuch_messages_t *messages;
>  notmuch_message_t *message;
> -const char *subject, *from_addr = NULL;
> +const char *subject, *from_addr = NULL, *short_from;
>  const char *in_reply_to, *orig_references, *references;
>  char *reply_headers;
> +time_t date;
> +struct tm *datetm;
> +char *datestr;
>  
>  for (messages = notmuch_query_search_messages (query);
>notmuch_messages_has_more (messages);
> @@ -346,10 +349,21 @@ notmuch_reply_format_default(void *ctx, 
> notmuch_config_t *config, notmuch_query_

I tried your patch. The first problem is that it doesn't apply. I had to
change the number 10 to 9 in the line above.

> + /* If from contains '<' (not as first char),
> +  * only use the preceding real name */
> + short_from = talloc_strdup(ctx, from_addr);
> + if (strstr(short_from, "<") > short_from) {
> +   *(strstr(short_from, "<")-1) = 0;
> + }
> +
>   printf ("On %s, %s wrote:\n",
> - notmuch_message_get_header (message, "date"),
> - notmuch_message_get_header (message, "from"));
> + datestr,
> + short_from);

The second problem is that the value of from_addr doesn't (always?)
contain sender's addres. When I wanded to reply to this email with you
patch applied, I got: "On 2010-03-02, Michal Sojka wrote:". So I fixed
that in your patch and added removal of "" around name.

>From 0555ba560fdaad3780c186b01b102670451585fb Mon Sep 17 00:00:00 2001
From: Sebastian Spaeth 
Date: Tue, 2 Mar 2010 13:37:42 +0100
Subject: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line

Previously, we would output:
'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth  
wrote:' now it is:
'On 2010-02-25, Sebastian Spaeth wrote:'

In case we don't find a '<' (as indicator for 'Realname '), we still use 
the whole from address.

Signed-off-by: Sebastian Spaeth 

Modified to use proper From header and strip "".
Signed-off-by: Michal Sojka 
---
 notmuch-reply.c |   28 +---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 98f6442..0ef4954 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
*config, notmuch_query_
 GMimeMessage *reply;
 notmuch_messages_t *messages;
 notmuch_message_t *message;
-const char *subject, *from_addr = NULL;
+const char *subject, *from_addr = NULL, *short_from;
 const char *in_reply_to, *orig_references, *references;
 char *reply_headers;
+time_t date;
+struct tm *datetm;
+char *datestr, *angle;

 for (messages = notmuch_query_search_messages (query);
 notmuch_messages_has_more (messages);
@@ -346,9 +349,28 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
*config, notmuch_query_
g_object_unref (G_OBJECT (reply));
reply = NULL;

+   date = notmuch_message_get_date(message);
+   datetm = gmtime( &date );
+   datestr = talloc_array(ctx, char, 11);
+   strftime(datestr, 11, "%Y-%m-%d", datetm);
+
+   /* If from contains '<' (not as first char), only use the
+* preceding real name without "" (if present). */
+   short_from = notmuch_message_get_header (message, "from");
+   if ((angle = strchr(short_from, '<')) > short_from) {
+   while (angle-1 >= short_from && *(angle-1) == ' ')
+   angle--;
+   *angle = '\0';
+   if (*short_from == '"' && *(angle-1) == '"' &&
+   angle-1 > short_from) {
+   short_from++;
+   *(angle-1) = '\0';
+   }
+   }
+
printf ("On %s, %s wrote:\n",
-   notmuch_message_get_header (message, "date"),
-   notmuch_message_get_header (message, "from"));
+   datestr,
+   short_from);

show_message_body (notmuch_message_get_filename (message), reply_part);

-- 
1.7.0



[notmuch] [PATCH] json_quote_str should handle non-ASCII characters

2010-03-04 Thread Gregor Hoffleit
* Sebastian Spaeth  [Do M?r 04 14:57:27 +0100 2010]
> On 2010-03-04, Sebastian Spaeth wrote:
> > The current code in json_quote_str() only accepts strict printable ASCII
> > code points (i.e. 32-127), all other code points are dropped from the
> > JSON output.
> 
> That would explain why my web interface does not display any umlaut
> symbols.

Well, I noticed noneatall umlauts. That's how I found this problem.

Regards,
Gregor


[notmuch] [PATCH] json_quote_str should handle non-ASCII characters

2010-03-04 Thread Sebastian Spaeth
On 2010-03-04, Sebastian Spaeth wrote:
> The current code in json_quote_str() only accepts strict printable ASCII
> code points (i.e. 32-127), all other code points are dropped from the
> JSON output.

That would explain why my web interface does not display any umlaut
symbols.

Nice finding,
Sebastian


[notmuch] [PATCH] format_part_json: part_content->data is not null terminated

2010-03-04 Thread Gregor Hoffleit
In format_part_json, part_content->data is not a null terminated string.
Instead, we have to use part_content->len.
---
 notmuch-show.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 1a1d601..4b755e9 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -309,10 +309,15 @@ format_part_json (GMimeObject *part, int *part_count)
 if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
 {
+   char *content_data;
+
show_part_content (part, stream_memory);
part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM 
(stream_memory));

-   printf (", \"content\": %s", json_quote_str (ctx, (char *) 
part_content->data));
+   content_data = talloc_size (ctx, part_content->len+1);
+   memcpy (content_data, (char *)part_content->data, part_content->len+1);
+   content_data[part_content->len] = 0;
+   printf (", \"content\": %s", json_quote_str (ctx, content_data));
 }

 fputs ("}", stdout);
-- 
1.7.0


[notmuch] [PATCH] json_quote_str should handle non-ASCII characters

2010-03-04 Thread Gregor Hoffleit
The current code in json_quote_str() only accepts strict printable ASCII
code points (i.e. 32-127), all other code points are dropped from the
JSON output.

This patch accepts code points 32-255.

json_quote_str() should handle non-ASCII characters.
---
 json.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/json.c b/json.c
index 9614143..6dc0345 100644
--- a/json.c
+++ b/json.c
@@ -59,7 +59,7 @@ json_quote_str(const void *ctx, const char *str)
return NULL;

 for (ptr = str; *ptr; len++, ptr++) {
-   if (*ptr < 32 || *ptr == '\"' || *ptr == '\\')
+   if ((unsigned char)(*ptr) < 32 || *ptr == '\"' || *ptr == '\\')
len++;
 }

@@ -70,7 +70,7 @@ json_quote_str(const void *ctx, const char *str)

 *ptr2++ = '\"';
 while (*ptr) {
-   if (*ptr > 31 && *ptr != '\"' && *ptr != '\\') {
+   if ((unsigned char)(*ptr) > 31 && *ptr != '\"' && *ptr != '\\') {
*ptr2++ = *ptr++;
} else {
*ptr2++ = '\\';
--
1.7.0


[notmuch] [PATCH 2/2] Build and link against notmuch shared library

2010-03-04 Thread Sebastian Spaeth
>  notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
> -notmuch: $(notmuch_client_modules) lib/notmuch.a
> - $(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
> +notmuch: $(notmuch_client_modules) lib/libnotmuch.so
> + $(call quiet,CC,$(LDFLAGS)) -lnotmuch $(filter-out 
> lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@

I just tried out this patch to compile notmuch as a shared library and
while producing lib/libnotmuch.so.1 it fails to find notmuch later:

CC  notmuch
/usr/bin/ld: cannot find -lnotmuch

Aso it creates libnotmuch.so.1 in lib but seems to try symlinking it in
the "compat" dir which fails and produces a dead symlink.

CXX lib/libnotmuch.so.1
ln -sf compat/libnotmuch.so.1 compat/libnotmuch.so

Is more needed than this patch? Also, *I* think it would be nice to
support --static or --shared as options to --configure. But that is a
minor thing, probably.

Sebastian


Re: [notmuch] [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line

2010-03-04 Thread Michal Sojka
Hi again,

On Tue, 02 Mar 2010, Sebastian Spaeth wrote:
> Previously, we would output:
> 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth  
> wrote:' now it is:
> 'On 2010-02-25, Sebastian Spaeth wrote:'
> 
> In case we don't find a '<' (as indicator for 'Realname '), we still 
> use the whole from address.
> 
> Signed-off-by: Sebastian Spaeth 
> ---
> This probably shows my lack of C skills quite nicely but it does the job for 
> me.
> 
>  notmuch-reply.c |   21 ++---
>  1 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 98f6442..929572f 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
> *config, notmuch_query_
>  GMimeMessage *reply;
>  notmuch_messages_t *messages;
>  notmuch_message_t *message;
> -const char *subject, *from_addr = NULL;
> +const char *subject, *from_addr = NULL, *short_from;
>  const char *in_reply_to, *orig_references, *references;
>  char *reply_headers;
> +time_t date;
> +struct tm *datetm;
> +char *datestr;
>  
>  for (messages = notmuch_query_search_messages (query);
>notmuch_messages_has_more (messages);
> @@ -346,10 +349,21 @@ notmuch_reply_format_default(void *ctx, 
> notmuch_config_t *config, notmuch_query_

I tried your patch. The first problem is that it doesn't apply. I had to
change the number 10 to 9 in the line above.

> + /* If from contains '<' (not as first char),
> +  * only use the preceding real name */
> + short_from = talloc_strdup(ctx, from_addr);
> + if (strstr(short_from, "<") > short_from) {
> +   *(strstr(short_from, "<")-1) = 0;
> + }
> +
>   printf ("On %s, %s wrote:\n",
> - notmuch_message_get_header (message, "date"),
> - notmuch_message_get_header (message, "from"));
> + datestr,
> + short_from);

The second problem is that the value of from_addr doesn't (always?)
contain sender's addres. When I wanded to reply to this email with you
patch applied, I got: "On 2010-03-02, Michal Sojka wrote:". So I fixed
that in your patch and added removal of "" around name.

>From 0555ba560fdaad3780c186b01b102670451585fb Mon Sep 17 00:00:00 2001
From: Sebastian Spaeth 
Date: Tue, 2 Mar 2010 13:37:42 +0100
Subject: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line

Previously, we would output:
'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth  
wrote:' now it is:
'On 2010-02-25, Sebastian Spaeth wrote:'

In case we don't find a '<' (as indicator for 'Realname '), we still use 
the whole from address.

Signed-off-by: Sebastian Spaeth 

Modified to use proper From header and strip "".
Signed-off-by: Michal Sojka 
---
 notmuch-reply.c |   28 +---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 98f6442..0ef4954 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
*config, notmuch_query_
 GMimeMessage *reply;
 notmuch_messages_t *messages;
 notmuch_message_t *message;
-const char *subject, *from_addr = NULL;
+const char *subject, *from_addr = NULL, *short_from;
 const char *in_reply_to, *orig_references, *references;
 char *reply_headers;
+time_t date;
+struct tm *datetm;
+char *datestr, *angle;
 
 for (messages = notmuch_query_search_messages (query);
 notmuch_messages_has_more (messages);
@@ -346,9 +349,28 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
*config, notmuch_query_
g_object_unref (G_OBJECT (reply));
reply = NULL;
 
+   date = notmuch_message_get_date(message);
+   datetm = gmtime( &date );
+   datestr = talloc_array(ctx, char, 11);
+   strftime(datestr, 11, "%Y-%m-%d", datetm);
+
+   /* If from contains '<' (not as first char), only use the
+* preceding real name without "" (if present). */
+   short_from = notmuch_message_get_header (message, "from");
+   if ((angle = strchr(short_from, '<')) > short_from) {
+   while (angle-1 >= short_from && *(angle-1) == ' ')
+   angle--;
+   *angle = '\0';
+   if (*short_from == '"' && *(angle-1) == '"' &&
+   angle-1 > short_from) {
+   short_from++;
+   *(angle-1) = '\0';
+   }
+   }
+
printf ("On %s, %s wrote:\n",
-   notmuch_message_get_header (message, "date"),
-   notmuch_message_get_header (message, "from"));
+   datestr,
+   short_from);
 
show_message_body (notmuch_message_get_filename (message), reply_part);
 
-- 
1.7.0

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


Re: [notmuch] [PATCH] json_quote_str should handle non-ASCII characters

2010-03-04 Thread Gregor Hoffleit
* Sebastian Spaeth  [Do Mär 04 14:57:27 +0100 2010]
> On 2010-03-04, Sebastian Spaeth wrote:
> > The current code in json_quote_str() only accepts strict printable ASCII
> > code points (i.e. 32-127), all other code points are dropped from the
> > JSON output.
> 
> That would explain why my web interface does not display any umlaut
> symbols.

Well, I noticed noneatall umlauts. That's how I found this problem.

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


Re: [notmuch] [PATCH] json_quote_str should handle non-ASCII characters

2010-03-04 Thread Sebastian Spaeth
On 2010-03-04, Sebastian Spaeth wrote:
> The current code in json_quote_str() only accepts strict printable ASCII
> code points (i.e. 32-127), all other code points are dropped from the
> JSON output.

That would explain why my web interface does not display any umlaut
symbols.

Nice finding,
Sebastian
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] format_part_json: part_content->data is not null terminated

2010-03-04 Thread Gregor Hoffleit
In format_part_json, part_content->data is not a null terminated string.
Instead, we have to use part_content->len.
---
 notmuch-show.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 1a1d601..4b755e9 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -309,10 +309,15 @@ format_part_json (GMimeObject *part, int *part_count)
 if (g_mime_content_type_is_type (content_type, "text", "*") &&
!g_mime_content_type_is_type (content_type, "text", "html"))
 {
+   char *content_data;
+
show_part_content (part, stream_memory);
part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM 
(stream_memory));
 
-   printf (", \"content\": %s", json_quote_str (ctx, (char *) 
part_content->data));
+   content_data = talloc_size (ctx, part_content->len+1);
+   memcpy (content_data, (char *)part_content->data, part_content->len+1);
+   content_data[part_content->len] = 0;
+   printf (", \"content\": %s", json_quote_str (ctx, content_data));
 }
 
 fputs ("}", stdout);
-- 
1.7.0
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] json_quote_str should handle non-ASCII characters

2010-03-04 Thread Gregor Hoffleit
The current code in json_quote_str() only accepts strict printable ASCII
code points (i.e. 32-127), all other code points are dropped from the
JSON output.

This patch accepts code points 32-255.

json_quote_str() should handle non-ASCII characters.
---
 json.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/json.c b/json.c
index 9614143..6dc0345 100644
--- a/json.c
+++ b/json.c
@@ -59,7 +59,7 @@ json_quote_str(const void *ctx, const char *str)
return NULL;
 
 for (ptr = str; *ptr; len++, ptr++) {
-   if (*ptr < 32 || *ptr == '\"' || *ptr == '\\')
+   if ((unsigned char)(*ptr) < 32 || *ptr == '\"' || *ptr == '\\')
len++;
 }
 
@@ -70,7 +70,7 @@ json_quote_str(const void *ctx, const char *str)
 
 *ptr2++ = '\"';
 while (*ptr) {
-   if (*ptr > 31 && *ptr != '\"' && *ptr != '\\') {
+   if ((unsigned char)(*ptr) > 31 && *ptr != '\"' && *ptr != '\\') {
*ptr2++ = *ptr++;
} else {
*ptr2++ = '\\';
--
1.7.0
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH 2/2] Build and link against notmuch shared library

2010-03-04 Thread Sebastian Spaeth
>  notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
> -notmuch: $(notmuch_client_modules) lib/notmuch.a
> - $(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
> +notmuch: $(notmuch_client_modules) lib/libnotmuch.so
> + $(call quiet,CC,$(LDFLAGS)) -lnotmuch $(filter-out 
> lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@

I just tried out this patch to compile notmuch as a shared library and
while producing lib/libnotmuch.so.1 it fails to find notmuch later:

CC  notmuch
/usr/bin/ld: cannot find -lnotmuch

Aso it creates libnotmuch.so.1 in lib but seems to try symlinking it in
the "compat" dir which fails and produces a dead symlink.

CXX lib/libnotmuch.so.1
ln -sf compat/libnotmuch.so.1 compat/libnotmuch.so

Is more needed than this patch? Also, *I* think it would be nice to
support --static or --shared as options to --configure. But that is a
minor thing, probably.

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