[PATCH 2/2] fix: initialize error var before using it

2012-10-25 Thread Taesoo Kim

Signed-off-by: Taesoo Kim 
---
 notmuch-config.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/notmuch-config.c b/notmuch-config.c
index c95f9dd..195ddb4 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -403,6 +403,7 @@ notmuch_config_open (void *ctx,
g_error_free (error);
 }
 
+error = NULL;
 config->maildir_add_as_tag_flags =
g_key_file_get_boolean (config->key_file,
"maildir", "add_as_tag_flags", &error);
-- 
1.8.0

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


[PATCH 1/2] Automatic tagging based on maildir

2012-10-25 Thread Taesoo Kim
Since gmail will provide labels as imap sub/folders, notmuch also can
take advantage of labels as tags, when maildir.add_as_tag_flags is
specified.

Signed-off-by: Taesoo Kim 
---
 notmuch-client.h |  7 +++
 notmuch-config.c | 42 ++
 notmuch-new.c| 32 
 3 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index ae9344b..ce05e52 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -265,6 +265,13 @@ void
 notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
  notmuch_bool_t synchronize_flags);
 
+notmuch_bool_t
+notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config);
+
+void
+notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config,
+notmuch_bool_t add_as_tag_flags);
+
 const char **
 notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t 
*length);
 
diff --git a/notmuch-config.c b/notmuch-config.c
index 3e37a2d..c95f9dd 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -88,7 +88,16 @@ static const char maildir_config_comment[] =
 "\n"
 "\tThe \"notmuch new\" command will notice flag changes in filenames\n"
 "\tand update tags, while the \"notmuch tag\" and \"notmuch restore\"\n"
-"\tcommands will notice tag changes and update flags in filenames\n";
+"\tcommands will notice tag changes and update flags in filenames\n"
+"\n"
+"\tadd_as_tag_flags   Valid values are true and false.\n"
+"\n"
+"\nIf ture, then add the lower-cased name of maildirs"
+"\n(also deliminated by .) as tags"
+"\n"
+"\n\te.g. Life  -> life"
+"\n\te.g. MIT.CSAIL -> mit, csail"
+"\n\te.g. Mailing.OSS.Linux -> mailing, oss, linux";
 
 static const char search_config_comment[] =
 " Search configuration\n"
@@ -114,6 +123,7 @@ struct _notmuch_config {
 const char **new_ignore;
 size_t new_ignore_length;
 notmuch_bool_t maildir_synchronize_flags;
+notmuch_bool_t maildir_add_as_tag_flags;
 const char **search_exclude_tags;
 size_t search_exclude_tags_length;
 };
@@ -251,7 +261,7 @@ notmuch_config_open (void *ctx,
fprintf (stderr, "Out of memory.\n");
return NULL;
 }
-
+
 talloc_set_destructor (config, notmuch_config_destructor);
 
 if (filename) {
@@ -393,6 +403,14 @@ notmuch_config_open (void *ctx,
g_error_free (error);
 }
 
+config->maildir_add_as_tag_flags =
+   g_key_file_get_boolean (config->key_file,
+   "maildir", "add_as_tag_flags", &error);
+if (error) {
+   notmuch_config_set_maildir_add_as_tag_flags (config, FALSE);
+   g_error_free (error);
+}
+
 /* Whenever we know of configuration sections that don't appear in
  * the configuration file, we add some comments to help the user
  * understand what can be done. */
@@ -438,7 +456,7 @@ notmuch_config_open (void *ctx,
 }
 
 /* Close the given notmuch_config_t object, freeing all resources.
- * 
+ *
  * Note: Any changes made to the configuration are *not* saved by this
  * function. To save changes, call notmuch_config_save before
  * notmuch_config_close.
@@ -720,7 +738,7 @@ notmuch_config_command_get (void *ctx, char *item)
 } else if (strcmp(item, "user.other_email") == 0) {
const char **other_email;
size_t i, length;
-   
+
other_email = notmuch_config_get_user_other_email (config, &length);
for (i = 0; i < length; i++)
printf ("%s\n", other_email[i]);
@@ -891,3 +909,19 @@ notmuch_config_set_maildir_synchronize_flags 
(notmuch_config_t *config,
"maildir", "synchronize_flags", synchronize_flags);
 config->maildir_synchronize_flags = synchronize_flags;
 }
+
+
+notmuch_bool_t
+notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config)
+{
+return config->maildir_add_as_tag_flags;
+}
+
+void
+notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config,
+notmuch_bool_t add_as_tag_flags)
+{
+g_key_file_set_boolean (config->key_file,
+   "maildir", "add_as_tag_flags", add_as_tag_flags);
+config->maildir_add_as_tag_flags = add_as_tag_flags;
+}
diff --git a/notmuch-new.c b/notmuch-new.c
index 56c4a6f..9ec983f 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -20,6 +20,7 @@
 
 #include "notmuch-client.h"
 
+#include 
 #include 
 
 typedef struct _filename_node {
@@ -53,6 +54,7 @@ typedef struct {
 _filename_list_t *directory_mtimes;
 
 notmuch_bool_t synchronize_flags;
+notmuch_bool_t add_as_tag_flags;
 } add_files_state_t;
 
 static volatile sig_atomic_t do_print_progress = 0;
@@ -240,6 +242,32 @@ _entry_in_ignore_list (const char *entry, 
add_files_state_t *state)
 return FALSE;
 }
 
+static void
+_

[PATCH 0/2] automatic tagging based on imap maildir

2012-10-25 Thread Taesoo Kim
Hi all,

To use gmail's label (imap maildir), parse maildir and add some tags as gmail's
labels.

Thanks,
Taesoo

Taesoo Kim (2):
  Automatic tagging based on maildir
  fix: initialize error var before using it

 notmuch-client.h |  7 +++
 notmuch-config.c | 43 +++
 notmuch-new.c| 32 
 3 files changed, 78 insertions(+), 4 deletions(-)

-- 
1.8.0

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


[PATCH 3/7] go: Allow notmuch objects to be garbage collected

2012-10-25 Thread Adrien Bustany
Le 19/10/2012 06:55, Ethan Glasser-Camp a ?crit :
> Adrien Bustany  writes:
>
>> This makes notmuch appropriately free the underlying notmuch C objects
>> when garbage collecting their Go wrappers. To make sure we don't break
>> the underlying links between objects (for example, a notmuch_messages_t
>> being GC'ed before a notmuch_message_t belonging to it), we add for each
>> wraper struct a pointer to the owner object (Go objects with a reference
>> pointing to them don't get garbage collected).
>
> Hi Adrien! This whole series is marked moreinfo, but I don't think
> that's just. It looks like there were some unresolved issues about
> reference tracking and garbage collection, and some suggestions to use
> the C values of enums instead of regenerating them with iota, but
> there's definitely valid code that I assume would be useful if anyone
> ever wanted to write in Go ;). Are you figuring to clean this series up?
>
> This comment should s/wraper/wrapper/.
>
> Ethan
>

Hello Ethan,

thanks for the heads up, I still have this on my table, and yes there is 
additional work to do for the patches to be really clean. I can't give 
an estimate for now, let's hope sooner than later :/

Cheers

Adrien


[PATCH v2 0/2] Add flush/reopen methods to notmuch_database_t

2012-10-25 Thread Adrien Bustany
Le 20/10/2012 18:49, Ethan Glasser-Camp a ?crit :
> Jani Nikula  writes:
>
>> On Wed, 17 Oct 2012, Adrien Bustany  wrote:
>>> The code of the patches in unchanged, but the formatting issues are now
>>> hopefully fixed.
>>
>> Hi Adrien, please check at what version flush and reopen have been
>> introduced to xapian. If they are new-ish (I don't know, didn't have the
>> time to check), please add appropriate #ifdefs. [1] lays the groundwork
>> for this. We'll also need to decide what is the minimum xapian version
>> required in general, i.e. features earlier than that don't need
>> conditional compilation.
>
> Hi! The new versions of these patches are still pretty trivial and they
> still look OK to me, but based on Jani's prompting I decided to look up
> the methods. Seems that flush() is a very old (pre-1.1.0, 2009-04) name
> for commit(), which is the preferred name these days. You should
> probably therefore rename the function notmuch_database_commit, and have
> it call the WritableDatabase::commit() method.
>
> reopen() is a very very old method, seems like it has been around since
> 2004.
>
> So I think Adrien is safe from having to do version checks, but we
> should probably use commit() instead of flush().
>
> Ethan
>

Thanks for checking that! Sorry for the late answer, I had a hard time 
keeping on top of things lately...


[PATCH 2/2] fix: initialize error var before using it

2012-10-25 Thread Taesoo Kim

Signed-off-by: Taesoo Kim 
---
 notmuch-config.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/notmuch-config.c b/notmuch-config.c
index c95f9dd..195ddb4 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -403,6 +403,7 @@ notmuch_config_open (void *ctx,
g_error_free (error);
 }

+error = NULL;
 config->maildir_add_as_tag_flags =
g_key_file_get_boolean (config->key_file,
"maildir", "add_as_tag_flags", &error);
-- 
1.8.0



[PATCH 1/2] Automatic tagging based on maildir

2012-10-25 Thread Taesoo Kim
Since gmail will provide labels as imap sub/folders, notmuch also can
take advantage of labels as tags, when maildir.add_as_tag_flags is
specified.

Signed-off-by: Taesoo Kim 
---
 notmuch-client.h |  7 +++
 notmuch-config.c | 42 ++
 notmuch-new.c| 32 
 3 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index ae9344b..ce05e52 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -265,6 +265,13 @@ void
 notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
  notmuch_bool_t synchronize_flags);

+notmuch_bool_t
+notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config);
+
+void
+notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config,
+notmuch_bool_t add_as_tag_flags);
+
 const char **
 notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t 
*length);

diff --git a/notmuch-config.c b/notmuch-config.c
index 3e37a2d..c95f9dd 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -88,7 +88,16 @@ static const char maildir_config_comment[] =
 "\n"
 "\tThe \"notmuch new\" command will notice flag changes in filenames\n"
 "\tand update tags, while the \"notmuch tag\" and \"notmuch restore\"\n"
-"\tcommands will notice tag changes and update flags in filenames\n";
+"\tcommands will notice tag changes and update flags in filenames\n"
+"\n"
+"\tadd_as_tag_flags   Valid values are true and false.\n"
+"\n"
+"\nIf ture, then add the lower-cased name of maildirs"
+"\n(also deliminated by .) as tags"
+"\n"
+"\n\te.g. Life  -> life"
+"\n\te.g. MIT.CSAIL -> mit, csail"
+"\n\te.g. Mailing.OSS.Linux -> mailing, oss, linux";

 static const char search_config_comment[] =
 " Search configuration\n"
@@ -114,6 +123,7 @@ struct _notmuch_config {
 const char **new_ignore;
 size_t new_ignore_length;
 notmuch_bool_t maildir_synchronize_flags;
+notmuch_bool_t maildir_add_as_tag_flags;
 const char **search_exclude_tags;
 size_t search_exclude_tags_length;
 };
@@ -251,7 +261,7 @@ notmuch_config_open (void *ctx,
fprintf (stderr, "Out of memory.\n");
return NULL;
 }
-
+
 talloc_set_destructor (config, notmuch_config_destructor);

 if (filename) {
@@ -393,6 +403,14 @@ notmuch_config_open (void *ctx,
g_error_free (error);
 }

+config->maildir_add_as_tag_flags =
+   g_key_file_get_boolean (config->key_file,
+   "maildir", "add_as_tag_flags", &error);
+if (error) {
+   notmuch_config_set_maildir_add_as_tag_flags (config, FALSE);
+   g_error_free (error);
+}
+
 /* Whenever we know of configuration sections that don't appear in
  * the configuration file, we add some comments to help the user
  * understand what can be done. */
@@ -438,7 +456,7 @@ notmuch_config_open (void *ctx,
 }

 /* Close the given notmuch_config_t object, freeing all resources.
- * 
+ *
  * Note: Any changes made to the configuration are *not* saved by this
  * function. To save changes, call notmuch_config_save before
  * notmuch_config_close.
@@ -720,7 +738,7 @@ notmuch_config_command_get (void *ctx, char *item)
 } else if (strcmp(item, "user.other_email") == 0) {
const char **other_email;
size_t i, length;
-   
+
other_email = notmuch_config_get_user_other_email (config, &length);
for (i = 0; i < length; i++)
printf ("%s\n", other_email[i]);
@@ -891,3 +909,19 @@ notmuch_config_set_maildir_synchronize_flags 
(notmuch_config_t *config,
"maildir", "synchronize_flags", synchronize_flags);
 config->maildir_synchronize_flags = synchronize_flags;
 }
+
+
+notmuch_bool_t
+notmuch_config_get_maildir_add_as_tag_flags (notmuch_config_t *config)
+{
+return config->maildir_add_as_tag_flags;
+}
+
+void
+notmuch_config_set_maildir_add_as_tag_flags (notmuch_config_t *config,
+notmuch_bool_t add_as_tag_flags)
+{
+g_key_file_set_boolean (config->key_file,
+   "maildir", "add_as_tag_flags", add_as_tag_flags);
+config->maildir_add_as_tag_flags = add_as_tag_flags;
+}
diff --git a/notmuch-new.c b/notmuch-new.c
index 56c4a6f..9ec983f 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -20,6 +20,7 @@

 #include "notmuch-client.h"

+#include 
 #include 

 typedef struct _filename_node {
@@ -53,6 +54,7 @@ typedef struct {
 _filename_list_t *directory_mtimes;

 notmuch_bool_t synchronize_flags;
+notmuch_bool_t add_as_tag_flags;
 } add_files_state_t;

 static volatile sig_atomic_t do_print_progress = 0;
@@ -240,6 +242,32 @@ _entry_in_ignore_list (const char *entry, 
add_files_state_t *state)
 return FALSE;
 }

+static void
+_add_maildir_

[PATCH 0/2] automatic tagging based on imap maildir

2012-10-25 Thread Taesoo Kim
Hi all,

To use gmail's label (imap maildir), parse maildir and add some tags as gmail's
labels.

Thanks,
Taesoo

Taesoo Kim (2):
  Automatic tagging based on maildir
  fix: initialize error var before using it

 notmuch-client.h |  7 +++
 notmuch-config.c | 43 +++
 notmuch-new.c| 32 
 3 files changed, 78 insertions(+), 4 deletions(-)

-- 
1.8.0



[PATCH v5 2/9] parse-time-string: add a date/time parser to notmuch

2012-10-25 Thread Austin Clements
Quoth myself on Oct 22 at  4:14 am:
> Overall this looks pretty good to me, and I must say, this parser is
> amazingly flexible and copes well with a remarkably hostile grammar.
> 
> A lot of little comments below (sorry if any of this ground has
> already been covered in the previous four versions).
> 
> I do have one broad comment.  While I'm all for ad hoc parsers for ad
> hoc grammars like dates, there is one piece of the literature I think
> this parser suffers for by ignoring: tokenizing.  I think it would
> simplify a lot of this code if it did a tokenizing pass before the
> parsing pass.  It doesn't have to be a serious tokenizer with
> streaming and keywords and token types and junk; just something that
> first splits the input into substrings, possibly just non-overlapping
> matches of [[:digit:]]+|[[:alpha:]]+|[-+:/.].  This would simplify the
> handling of postponed numbers because, with trivial lookahead in the
> token stream, you wouldn't have to postpone them.  Likewise, it would
> eliminate last_field.  It would simplify keyword matching because you
> wouldn't have to worry about matching substrings (I spent a long time
> staring at that code before I figured out what it would and wouldn't
> accept).  Most important, I think it would make the parser more
> predictable for users; for example, the parser currently accepts
> things like "saturtoday" because it's aggressively single-pass.

I should add that I am not at all opposed to this patch as it is
currently designed.  We need a date parser.  My comment about
separating tokenization is just a way that this code could probably be
simplified if someone were so inclined or if simplifying the code
would help it pass any hurdles.


[PATCH] Support OpenBSD

2012-10-25 Thread Ethan Glasser-Camp
Austin Clements  writes:

> OpenBSD's build flags are identical to FreeBSD, except that libraries
> need to be explicitly linked against libc.  No code changes are
> necessary.
>
> From: Cody Cutler 
> ---

OK, looks fine.

Ethan


Re: [PATCH v5 2/9] parse-time-string: add a date/time parser to notmuch

2012-10-25 Thread Austin Clements
Quoth myself on Oct 22 at  4:14 am:
> Overall this looks pretty good to me, and I must say, this parser is
> amazingly flexible and copes well with a remarkably hostile grammar.
> 
> A lot of little comments below (sorry if any of this ground has
> already been covered in the previous four versions).
> 
> I do have one broad comment.  While I'm all for ad hoc parsers for ad
> hoc grammars like dates, there is one piece of the literature I think
> this parser suffers for by ignoring: tokenizing.  I think it would
> simplify a lot of this code if it did a tokenizing pass before the
> parsing pass.  It doesn't have to be a serious tokenizer with
> streaming and keywords and token types and junk; just something that
> first splits the input into substrings, possibly just non-overlapping
> matches of [[:digit:]]+|[[:alpha:]]+|[-+:/.].  This would simplify the
> handling of postponed numbers because, with trivial lookahead in the
> token stream, you wouldn't have to postpone them.  Likewise, it would
> eliminate last_field.  It would simplify keyword matching because you
> wouldn't have to worry about matching substrings (I spent a long time
> staring at that code before I figured out what it would and wouldn't
> accept).  Most important, I think it would make the parser more
> predictable for users; for example, the parser currently accepts
> things like "saturtoday" because it's aggressively single-pass.

I should add that I am not at all opposed to this patch as it is
currently designed.  We need a date parser.  My comment about
separating tokenization is just a way that this code could probably be
simplified if someone were so inclined or if simplifying the code
would help it pass any hurdles.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Support OpenBSD

2012-10-25 Thread Ethan Glasser-Camp
Austin Clements  writes:

> OpenBSD's build flags are identical to FreeBSD, except that libraries
> need to be explicitly linked against libc.  No code changes are
> necessary.
>
> From: Cody Cutler 
> ---

OK, looks fine.

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


Re: [PATCH 3/7] go: Allow notmuch objects to be garbage collected

2012-10-25 Thread Adrien Bustany

Le 19/10/2012 06:55, Ethan Glasser-Camp a écrit :

Adrien Bustany  writes:


This makes notmuch appropriately free the underlying notmuch C objects
when garbage collecting their Go wrappers. To make sure we don't break
the underlying links between objects (for example, a notmuch_messages_t
being GC'ed before a notmuch_message_t belonging to it), we add for each
wraper struct a pointer to the owner object (Go objects with a reference
pointing to them don't get garbage collected).


Hi Adrien! This whole series is marked moreinfo, but I don't think
that's just. It looks like there were some unresolved issues about
reference tracking and garbage collection, and some suggestions to use
the C values of enums instead of regenerating them with iota, but
there's definitely valid code that I assume would be useful if anyone
ever wanted to write in Go ;). Are you figuring to clean this series up?

This comment should s/wraper/wrapper/.

Ethan



Hello Ethan,

thanks for the heads up, I still have this on my table, and yes there is 
additional work to do for the patches to be really clean. I can't give 
an estimate for now, let's hope sooner than later :/


Cheers

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


Re: [PATCH v2 0/2] Add flush/reopen methods to notmuch_database_t

2012-10-25 Thread Adrien Bustany

Le 20/10/2012 18:49, Ethan Glasser-Camp a écrit :

Jani Nikula  writes:


On Wed, 17 Oct 2012, Adrien Bustany  wrote:

The code of the patches in unchanged, but the formatting issues are now
hopefully fixed.


Hi Adrien, please check at what version flush and reopen have been
introduced to xapian. If they are new-ish (I don't know, didn't have the
time to check), please add appropriate #ifdefs. [1] lays the groundwork
for this. We'll also need to decide what is the minimum xapian version
required in general, i.e. features earlier than that don't need
conditional compilation.


Hi! The new versions of these patches are still pretty trivial and they
still look OK to me, but based on Jani's prompting I decided to look up
the methods. Seems that flush() is a very old (pre-1.1.0, 2009-04) name
for commit(), which is the preferred name these days. You should
probably therefore rename the function notmuch_database_commit, and have
it call the WritableDatabase::commit() method.

reopen() is a very very old method, seems like it has been around since
2004.

So I think Adrien is safe from having to do version checks, but we
should probably use commit() instead of flush().

Ethan



Thanks for checking that! Sorry for the late answer, I had a hard time 
keeping on top of things lately...

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


[PATCH] test: Fix HTML rendering test

2012-10-25 Thread Tomi Ollila
On Thu, Oct 25 2012, Austin Clements  wrote:

>
> Emacs seems to have as many ways to convert HTML to text as there are
> people trying to run this test.  What's the value of
> mm-text-html-renderer for you in Emacs 24?

On Fedora 17:

 PASS   notmuch-hello-refresh hook is called
 PASS   notmuch-hello-refresh hook is called on updates
 FAIL   Rendering HTML mail with images
 --- emacs.56.OUTPUT   2012-10-25 07:59:22.831311067 +
 +++ emacs.56.EXPECTED 2012-10-25 07:59:22.833311095 +
 @@ -5,5 +5,4 @@

   [ multipart/related ]
[ text/html ]
-*
-smiley 
+* smiley
nil

emacs-large-search-buffer: Testing Emacs with large search results bu

--

emacs -q -nw

emacs-version is a variable defined in `C source code'.
Its value is "24.1.1"

M-x load-library message

mm-text-html-renderer's value is shr

(mm-text-html-renderer-alist not defined at this time)

M-x load-library mm-view

mm-text-html-renderer-alist's value is ((shr . mm-shr)
...


Tomi


[PATCH] test: Fix HTML rendering test

2012-10-25 Thread Ethan Glasser-Camp
Austin Clements  writes:

> Quoth Ethan Glasser-Camp on Oct 24 at  9:59 pm:
>> Austin Clements  writes:
>
> Emacs seems to have as many ways to convert HTML to text as there are
> people trying to run this test.  What's the value of
> mm-text-html-renderer for you in Emacs 24?

I get html2text.

I wanted to write more about what the test should and should not do, but
really I don't know and don't have the time to write about it!

Ethan


[PATCH (draft) 2/2] emacs: show: make "view part" show hidden parts

2012-10-25 Thread Mark Walters
This change means that hidden parts in the show buffer are inserted
into the buffer when the "view command" is called on that part (by
default v on the button).
---
 emacs/notmuch-show.el |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9157669..293456d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -836,7 +836,8 @@ has overridden the default for this part"
 (when (memq nth user-parts)
   (setq not-shown (not not-shown)))
 (if not-shown
-   (notmuch-show-insert-part-header nth content-type content-type nil " 
(not shown)")
+   (button-put (notmuch-show-insert-part-header nth content-type 
content-type nil " (not shown)")
+   :part-not-shown 't)
   (notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type)))
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
@@ -1912,7 +1913,10 @@ the user (see 
`notmuch-show-stash-mlarchive-link-alist')."

 (defun notmuch-show-part-button-view (&optional button)
   (interactive)
-  (notmuch-show-part-button-internal button #'notmuch-show-view-part))
+  (let ((button (or button (button-at (point)
+(if (and button (button-get button :part-not-shown))
+   (notmuch-show-part-button-internal button 
#'notmuch-show-internally-show-part)
+  (notmuch-show-part-button-internal button #'notmuch-show-view-part

 (defun notmuch-show-part-button-interactively-view (&optional button)
   (interactive)
-- 
1.7.9.1



[PATCH (draft) 1/2] emacs: allow the user to toggle the visibility of multipart/alternative parts

2012-10-25 Thread Mark Walters
This patch adds a keybinding to the buttons in the notmuch-show emacs
buffer to allow the user to toggle the visibility of each part of a
message in the show buffer.  This is particularly useful for
multipart/alternative parts where the parts are not really
alternatives but contain different information.
---
 emacs/notmuch-show.el |   47 +++
 1 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 0f54259..9157669 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -155,6 +155,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-indent-content)
 (put 'notmuch-show-indent-content 'permanent-local t)

+(defvar notmuch-show-message-multipart/alternative-display-parts nil)
+(make-variable-buffer-local 
'notmuch-show-message-multipart/alternative-display-parts)
+(put 'notmuch-show-message-multipart/alternative-display-parts 
'permanent-local t)
+
 (defcustom notmuch-show-stash-mlarchive-link-alist
   '(("Gmane" . "http://mid.gmane.org/";)
 ("MARC" . "http://marc.info/?i=";)
@@ -455,6 +459,7 @@ message at DEPTH in the current thread."
 (define-key map "v" 'notmuch-show-part-button-view)
 (define-key map "o" 'notmuch-show-part-button-interactively-view)
 (define-key map "|" 'notmuch-show-part-button-pipe)
+(define-key map "t" 'notmuch-show-part-button-internally-show)
 map)
   "Submap for button commands")
 (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
@@ -531,6 +536,16 @@ message at DEPTH in the current thread."
 (let ((handle (mm-make-handle (current-buffer) (list content-type
   (mm-pipe-part handle

+(defun notmuch-show-internally-show-part (message-id nth &optional filename 
content-type)
+  "Set a part to be displayed internally"
+  (let ((current-parts (lax-plist-get 
notmuch-show-message-multipart/alternative-display-parts message-id)))
+(setq notmuch-show-message-multipart/alternative-display-parts
+ (lax-plist-put 
notmuch-show-message-multipart/alternative-display-parts message-id
+(if (memq nth current-parts)
+(delq nth current-parts)
+  (cons nth current-parts)
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-multipart/*-to-list (part)
   (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
  (plist-get part :content)))
@@ -543,12 +558,15 @@ message at DEPTH in the current thread."
 ;; This inserts all parts of the chosen type rather than just one,
 ;; but it's not clear that this is the wrong thing to do - which
 ;; should be chosen if there are more than one that match?
+
+;; The variable user-parts says which parts should override the
+;; default so we use xor (handcoded since lisp does not have it).
+
 (mapc (lambda (inner-part)
(let ((inner-type (plist-get inner-part :content-type)))
- (if (or notmuch-show-all-multipart/alternative-parts
- (string= chosen-type inner-type))
- (notmuch-show-insert-bodypart msg inner-part depth)
-   (notmuch-show-insert-part-header (plist-get inner-part :id) 
inner-type inner-type nil " (not shown)"
+ (notmuch-show-insert-bodypart msg inner-part depth
+   (not (or 
notmuch-show-all-multipart/alternative-parts
+(string= chosen-type 
inner-type))
  inner-parts)

 (when notmuch-show-indent-multipart
@@ -806,11 +824,20 @@ message at DEPTH in the current thread."
   (setq handlers (cdr handlers
   t)

-(defun notmuch-show-insert-bodypart (msg part depth)
-  "Insert the body part PART at depth DEPTH in the current thread."
-  (let ((content-type (downcase (plist-get part :content-type)))
+(defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)
+  "Insert the body part PART at depth DEPTH in the current thread.
+
+If not-shown is TRUE then do not show the part unless the user
+has overridden the default for this part"
+  (let ((user-parts (lax-plist-get 
notmuch-show-message-multipart/alternative-display-parts
+  (notmuch-id-to-query (plist-get msg :id
+   (content-type (downcase (plist-get part :content-type)))
(nth (plist-get part :id)))
-(notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type))
+(when (memq nth user-parts)
+  (setq not-shown (not not-shown)))
+(if not-shown
+   (notmuch-show-insert-part-header nth content-type content-type nil " 
(not shown)")
+  (notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type)))
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -1895,6 +1922,10 @@ the us

[PATCH (draft) 0/2] Allow emacs to toggle display of all parts including multipart

2012-10-25 Thread Mark Walters
This patch series adds a function to toggle the display of any emacs
part in the show buffer. This is particularly useful for
multipart/alternative where the parts have different information.

The first patch binds this toggle to 't' on the part button. This
patch works by itself.

The second patch makes it that "viewing" (ie v on the part-button) a
"not shown" part displays the part in the buffer. Note this is not a
toggle since having displayed the part in the buffer the user may wish
to view the part externally (eg if it is a text/html part).

Caveats: 
 the patches work by reloading the whole buffer: this may mean
 extra messages appear in the thread. This is not ideal but is
 the same as toggling indentation etc.

 the reload saves state as normal but this means the view
 returns to the top of the current message. Since we know
 exactly where the user was (ie on the button) this should be
 restored.

 for technical reasons the "view" part functionality in the
 second patch only works for view called explicitly: not if
 the user has customised the default action to be view and
 calls that. This is easy to fix but the most natural way
 would break existing customisation of this action.

 reloading the buffer without keeping state does not currently
 reset the toggled parts. Again this is easy to fix but lets
 see if people like the general approach first.

Best wishes

Mark


Mark Walters (2):
  emacs: allow the user to toggle the visibility of
multipart/alternative parts
  emacs: show: make "view part" show hidden parts

 emacs/notmuch-show.el |   53 
 1 files changed, 44 insertions(+), 9 deletions(-)

-- 
1.7.9.1



Re: [ANN] notmuch-labeler: Improves notmuch way of displaying labels

2012-10-25 Thread James Vasile
+1 for merging this upstream.

Thanks.


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


Re: [PATCH] test: Fix HTML rendering test

2012-10-25 Thread Ethan Glasser-Camp
Austin Clements  writes:

> Quoth Ethan Glasser-Camp on Oct 24 at  9:59 pm:
>> Austin Clements  writes:
>
> Emacs seems to have as many ways to convert HTML to text as there are
> people trying to run this test.  What's the value of
> mm-text-html-renderer for you in Emacs 24?

I get html2text.

I wanted to write more about what the test should and should not do, but
really I don't know and don't have the time to write about it!

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


[PATCH (draft) 2/2] emacs: show: make "view part" show hidden parts

2012-10-25 Thread Mark Walters
This change means that hidden parts in the show buffer are inserted
into the buffer when the "view command" is called on that part (by
default v on the button).
---
 emacs/notmuch-show.el |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9157669..293456d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -836,7 +836,8 @@ has overridden the default for this part"
 (when (memq nth user-parts)
   (setq not-shown (not not-shown)))
 (if not-shown
-   (notmuch-show-insert-part-header nth content-type content-type nil " 
(not shown)")
+   (button-put (notmuch-show-insert-part-header nth content-type 
content-type nil " (not shown)")
+   :part-not-shown 't)
   (notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type)))
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
@@ -1912,7 +1913,10 @@ the user (see 
`notmuch-show-stash-mlarchive-link-alist')."
 
 (defun notmuch-show-part-button-view (&optional button)
   (interactive)
-  (notmuch-show-part-button-internal button #'notmuch-show-view-part))
+  (let ((button (or button (button-at (point)
+(if (and button (button-get button :part-not-shown))
+   (notmuch-show-part-button-internal button 
#'notmuch-show-internally-show-part)
+  (notmuch-show-part-button-internal button #'notmuch-show-view-part
 
 (defun notmuch-show-part-button-interactively-view (&optional button)
   (interactive)
-- 
1.7.9.1

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


[PATCH (draft) 1/2] emacs: allow the user to toggle the visibility of multipart/alternative parts

2012-10-25 Thread Mark Walters
This patch adds a keybinding to the buttons in the notmuch-show emacs
buffer to allow the user to toggle the visibility of each part of a
message in the show buffer.  This is particularly useful for
multipart/alternative parts where the parts are not really
alternatives but contain different information.
---
 emacs/notmuch-show.el |   47 +++
 1 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 0f54259..9157669 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -155,6 +155,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-indent-content)
 (put 'notmuch-show-indent-content 'permanent-local t)
 
+(defvar notmuch-show-message-multipart/alternative-display-parts nil)
+(make-variable-buffer-local 
'notmuch-show-message-multipart/alternative-display-parts)
+(put 'notmuch-show-message-multipart/alternative-display-parts 
'permanent-local t)
+
 (defcustom notmuch-show-stash-mlarchive-link-alist
   '(("Gmane" . "http://mid.gmane.org/";)
 ("MARC" . "http://marc.info/?i=";)
@@ -455,6 +459,7 @@ message at DEPTH in the current thread."
 (define-key map "v" 'notmuch-show-part-button-view)
 (define-key map "o" 'notmuch-show-part-button-interactively-view)
 (define-key map "|" 'notmuch-show-part-button-pipe)
+(define-key map "t" 'notmuch-show-part-button-internally-show)
 map)
   "Submap for button commands")
 (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
@@ -531,6 +536,16 @@ message at DEPTH in the current thread."
 (let ((handle (mm-make-handle (current-buffer) (list content-type
   (mm-pipe-part handle
 
+(defun notmuch-show-internally-show-part (message-id nth &optional filename 
content-type)
+  "Set a part to be displayed internally"
+  (let ((current-parts (lax-plist-get 
notmuch-show-message-multipart/alternative-display-parts message-id)))
+(setq notmuch-show-message-multipart/alternative-display-parts
+ (lax-plist-put 
notmuch-show-message-multipart/alternative-display-parts message-id
+(if (memq nth current-parts)
+(delq nth current-parts)
+  (cons nth current-parts)
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-multipart/*-to-list (part)
   (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
  (plist-get part :content)))
@@ -543,12 +558,15 @@ message at DEPTH in the current thread."
 ;; This inserts all parts of the chosen type rather than just one,
 ;; but it's not clear that this is the wrong thing to do - which
 ;; should be chosen if there are more than one that match?
+
+;; The variable user-parts says which parts should override the
+;; default so we use xor (handcoded since lisp does not have it).
+
 (mapc (lambda (inner-part)
(let ((inner-type (plist-get inner-part :content-type)))
- (if (or notmuch-show-all-multipart/alternative-parts
- (string= chosen-type inner-type))
- (notmuch-show-insert-bodypart msg inner-part depth)
-   (notmuch-show-insert-part-header (plist-get inner-part :id) 
inner-type inner-type nil " (not shown)"
+ (notmuch-show-insert-bodypart msg inner-part depth
+   (not (or 
notmuch-show-all-multipart/alternative-parts
+(string= chosen-type 
inner-type))
  inner-parts)
 
 (when notmuch-show-indent-multipart
@@ -806,11 +824,20 @@ message at DEPTH in the current thread."
   (setq handlers (cdr handlers
   t)
 
-(defun notmuch-show-insert-bodypart (msg part depth)
-  "Insert the body part PART at depth DEPTH in the current thread."
-  (let ((content-type (downcase (plist-get part :content-type)))
+(defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)
+  "Insert the body part PART at depth DEPTH in the current thread.
+
+If not-shown is TRUE then do not show the part unless the user
+has overridden the default for this part"
+  (let ((user-parts (lax-plist-get 
notmuch-show-message-multipart/alternative-display-parts
+  (notmuch-id-to-query (plist-get msg :id
+   (content-type (downcase (plist-get part :content-type)))
(nth (plist-get part :id)))
-(notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type))
+(when (memq nth user-parts)
+  (setq not-shown (not not-shown)))
+(if not-shown
+   (notmuch-show-insert-part-header nth content-type content-type nil " 
(not shown)")
+  (notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type)))
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -1895,6 +1922,10 @@ th

[PATCH (draft) 0/2] Allow emacs to toggle display of all parts including multipart

2012-10-25 Thread Mark Walters
This patch series adds a function to toggle the display of any emacs
part in the show buffer. This is particularly useful for
multipart/alternative where the parts have different information.

The first patch binds this toggle to 't' on the part button. This
patch works by itself.

The second patch makes it that "viewing" (ie v on the part-button) a
"not shown" part displays the part in the buffer. Note this is not a
toggle since having displayed the part in the buffer the user may wish
to view the part externally (eg if it is a text/html part).

Caveats: 
 the patches work by reloading the whole buffer: this may mean
 extra messages appear in the thread. This is not ideal but is
 the same as toggling indentation etc.

 the reload saves state as normal but this means the view
 returns to the top of the current message. Since we know
 exactly where the user was (ie on the button) this should be
 restored.

 for technical reasons the "view" part functionality in the
 second patch only works for view called explicitly: not if
 the user has customised the default action to be view and
 calls that. This is easy to fix but the most natural way
 would break existing customisation of this action.

 reloading the buffer without keeping state does not currently
 reset the toggled parts. Again this is easy to fix but lets
 see if people like the general approach first.

Best wishes

Mark


Mark Walters (2):
  emacs: allow the user to toggle the visibility of
multipart/alternative parts
  emacs: show: make "view part" show hidden parts

 emacs/notmuch-show.el |   53 
 1 files changed, 44 insertions(+), 9 deletions(-)

-- 
1.7.9.1

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


Re: [PATCH] test: Fix HTML rendering test

2012-10-25 Thread Tomi Ollila
On Thu, Oct 25 2012, Austin Clements  wrote:

>
> Emacs seems to have as many ways to convert HTML to text as there are
> people trying to run this test.  What's the value of
> mm-text-html-renderer for you in Emacs 24?

On Fedora 17:

 PASS   notmuch-hello-refresh hook is called
 PASS   notmuch-hello-refresh hook is called on updates
 FAIL   Rendering HTML mail with images
 --- emacs.56.OUTPUT   2012-10-25 07:59:22.831311067 +
 +++ emacs.56.EXPECTED 2012-10-25 07:59:22.833311095 +
 @@ -5,5 +5,4 @@
  
   [ multipart/related ]
[ text/html ]
-*
-smiley 
+* smiley
nil

emacs-large-search-buffer: Testing Emacs with large search results bu

--

emacs -q -nw

emacs-version is a variable defined in `C source code'.
Its value is "24.1.1"

M-x load-library message

mm-text-html-renderer's value is shr

(mm-text-html-renderer-alist not defined at this time)

M-x load-library mm-view

mm-text-html-renderer-alist's value is ((shr . mm-shr)
...


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