folder and path completely broken in HEAD?

2014-05-02 Thread dm-list-email-notm...@scs.stanford.edu
Jani Nikula  writes:

> On Fri, 02 May 2014, dm-list-email-notmuch at scs.stanford.edu wrote:
>>
>> I'm using a pretty standard maildir++ layout.  For example, underneath
>> my database.path I have a bunch of mail in directories such as:
>>
>> .INBOX.Main/{new,cur}
>> .mail.class/{new,cur}
>> .mail.voicemail/{new,cur}
>> ...
> Here's additional commentary on the specific queries.
>
>> linux7$ ./notmuch count folder:mail
>> 0
>> linux8$ ./notmuch count folder:.mail
>> 0

Oh, man.  That's a serious bummer.

Is there any mechanism left that would let me hierarchically group
messages?  I've got a ton of mail.* folders, and create new ones
dynamically.  I really want a mechanism to group them hierarchically, so
I can have a search that matches all current and future mail
directories.  I organized my whole mail setup around folders because a)
tags do not provide this kind of hierarchical control, and b) there
doesn't seem to be a convenient way to apply tags 100% reliably on
message delivery, whereas I *can* control the folder 100% reliably.

Worse, because of my poor performance, I was hoping to segregate
messages by year.  So it would be:

  2013/.mail.class
  2013/.mail.voicemail
  2014/.mail.class
  2014/.mail.voicemail

All the way back.  Now you are saying there will be no convenient way to
match just the "mail.class" part without the year?  How very
distressing.  Ugh.

David


[PATCH] NEWS: make it explicit that wildcard matching is no longer supported

2014-05-02 Thread Jani Nikula
Wildcard matching was a feature of the probabilistic prefix, and we no
longer have it for the boolean prefix. Also note that top-level folder
can now be searched.
---
 NEWS | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 75dba6f963b0..f10c280be328 100644
--- a/NEWS
+++ b/NEWS
@@ -21,12 +21,13 @@ General
 The `folder:` search prefix now requires an exact match

   The `folder:` prefix has been changed to search for email messages
-  by the exact, case sensitive maildir or MH folder name. The new
-  behaviour allows for more accurate mail folder based searches, and
-  should lead to less surprising results than the old behaviour. Users
-  are advised to see the `notmuch-search-terms` manual page for
-  details, and review how the change affects their existing `folder:`
-  searches.
+  by the exact, case sensitive maildir or MH folder name. Wildcard
+  matching (`folder:foo*`) is no longer supported. The new behaviour
+  allows for more accurate mail folder based searches, makes it
+  possible to search for messages in the top-level folder, and should
+  lead to less surprising results than the old behaviour. Users are
+  advised to see the `notmuch-search-terms` manual page for details,
+  and review how the change affects their existing `folder:` searches.

 There is a new `path:` search prefix.

-- 
1.9.2



folder and path completely broken in HEAD?

2014-05-02 Thread Mark Walters

Hi

Before checking other things: have you run notmuch new? That's needed to
update the database. It is an irreversible update so notmuch-0.17 will
not work with the updated database.

The update should save a dump of the tags before updating but you might
want to do that manually too (and maybe even keep a complete copy of the
database). The update might take quite a long time (but it can be
interrupted and restarted)

Best wishes

Mark


On Fri, 02 May 2014, dm-list-email-notmuch at scs.stanford.edu wrote:
> Hey, I'm playing around with the head of the git repository
> (bc64cdce289d84be2550c4fccb1f008d15eaeb0e) to try to figure out how the
> new folder: prefixes work, as folders are a critical part of how I
> organize my mail.  (Since tags are not hierarchical, folders are the
> best way for me to group mail to a bunch of related addresses, while
> retaining the ability to separate out any mailboxes that become high
> traffic.)
>
> I'm using a pretty standard maildir++ layout.  For example, underneath
> my database.path I have a bunch of mail in directories such as:
>
> .INBOX.Main/{new,cur}
> .mail.class/{new,cur}
> .mail.voicemail/{new,cur}
>
> It used to be the case that if I wanted to read all of my "mail" mail, I
> could search for folder:mail, while to look at just voicemail, I could
> say folder:mail.voicemail, etc.  Now, I can't get anything to match a
> folder predicate period.  For example, using notmuch as notmuch-0.17 and
> ./notmuch as notmuch-0.18-rc2+2~gbc64cdc, here's what I get:
>
> linux2$ notmuch count folder:mail
> 16257
> linux3$ notmuch count folder:mail.class
> 1896
> linux4$ notmuch count folder:mail.voicemail
> 34
> linux5$ notmuch count folder:mail.voicemail/cur
> 34
> linux6$ notmuch count folder:.mail.voicemail/cur
> 34
> linux7$ ./notmuch count folder:mail
> 0
> linux8$ ./notmuch count folder:.mail
> 0
> linux9$ ./notmuch count folder:.mail.voicemail
> 0
> linux10$ ./notmuch count folder:.mail.voicemail/cur
> 0
> linux 11$ ./notmuch count path:.mail.voicemail
> 0
> linux 12$ ./notmuch count path:.mail.voicemail/'**'
> 0
> linux 13$ ./notmuch count path:.mail.voicemail/cur 
> 0
> linux 14$ ./notmuch count folder:mail.voicemail
> 0
>
> What gives?  Are the path and folder predicates completely broken, or is
> something very important missing from the new notmuch-search-terms
> manual page?  How can I make this work?
>
> Thanks,
> David
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] doc: add *.pyc to doc/.gitignore

2014-05-02 Thread Jani Nikula
---
 doc/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/.gitignore b/doc/.gitignore
index a60fb31e9419..f0cbb9c27b24 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,2 +1,3 @@
+*.pyc
 docdeps.mk
 _build
-- 
1.9.2



[PATCH 1/2] test: add have-man and have-compact in test/.gitignore

2014-05-02 Thread Jani Nikula
Sort the file while at it.
---
 test/.gitignore | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/test/.gitignore b/test/.gitignore
index 97e024878728..4081cee6da18 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,9 +1,11 @@
-test-results
-corpus.mail
-smtp-dummy
-symbol-test
 arg-test
+corpus.mail
+have-compact
+have-man
 hex-xcode
-random-corpus
 parse-time
+random-corpus
+smtp-dummy
+symbol-test
+test-results
 tmp.*
-- 
1.9.2



[PATCH] NEWS: make it explicit that wildcard matching is no longer supported

2014-05-02 Thread David Edmondson
Good for me, thank you.
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 310 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140502/ccfe5e73/attachment.pgp>


Add support for specifying tags during "notmuch new"

2014-05-02 Thread David Edmondson
On Fri, May 02 2014, Austin Clements wrote:
>> 2) A periodic mail processing script wants to add new messages to
>>the database, then process those newly added messages to add
>>convenience tags, etc. without worrying about the user or other
>>instances of the script manipulating tags at the same time. Use
>>this approach:
>>  KEY=$RANDOM
>>   notmuch new +$KEY
>>   notmuch tag +notmuch tag:$KEY and to:notmuch at notmuchmail.org
>>   notmuch tag +gnus tag:$KEY and to:ding at gnus.org
>>   ...
>>   notmuch tag -$KEY tag:$KEY
>
> What happens when this script dies in the middle (say, your computer
> loses power or notmuch tag conflicts with something else on the write
> lock)?

It's a problem. I think that I would actually add both 'new' and
'new-$seconds' tags (given that I can't search on wildcarded tags) and
have 'notmuch tag' use only 'new-$seconds'.

The 'new' tag would help recover from failures such as you describe.

> One advantage of the standard "new" tag approach is that it's easy to
> write a stateless post-new tagging script that can be killed at any
> point and restarted.  (You're right that post-new has a concurrency
> issue, but we should fix that in its own right.)
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 310 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140502/3ebea34c/attachment.pgp>


[PATCH] NEWS: folder:, path:, and database upgrade

2014-05-02 Thread David Edmondson
On Fri, May 02 2014, Mark Walters wrote:
> I don't like the wildcard bit as an important part of the change was the
> removal of stemming. Perhaps keep exact in the headline and in the body
> say explicitly what the changes are no stemming, no wildcards (except
> globbing), etc (maybe case sensitivity is different?)

I'm not too upset about exactly what it says.

I wonder how many users care about "the removal of stemming" as opposed
to "wildcards no longer work", though :-)

> On Thu, 01 May 2014, David Edmondson  wrote:
>> On Sun, Apr 27 2014, Jani Nikula wrote:
>>> +The `folder:` search prefix now requires an exact match
>>
>> I think that it would be clearer to say:
>>
>>   The `folder:` search prefix no longer supports wildcard matching
>>
>> (Or something like that.)
>> ___
>> notmuch mailing list
>> notmuch at notmuchmail.org
>> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 310 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140502/5c7656b6/attachment-0001.pgp>


[PATCH v2] emacs: allow functions in notmuch-show-stash-mlarchive-link-alist

2014-05-02 Thread Mark Walters

This version LGTM +1.

Best wishes

Mark

On Thu, 01 May 2014, Jani Nikula  wrote:
> Some archives may use a more complicated scheme for referring to
> messages than just concatenated url and message-id. In particular,
> patchwork requires a query to translate message-id to a patchwork
> patch id. Allow functions in notmuch-show-stash-mlarchive-link-alist
> to facilitate this.
>
> For example, one could use something like this for patchwork.
>
> (lambda (message-id)
>   (concat
>"http://patchwork.example.com/patch/;
>(nth 0
>   (split-string
>(car (last (process-lines "pwclient" "search" "-n" "1"
>  "-m" (concat "<" message-id ">"
> ---
>  emacs/notmuch-show.el | 40 +++-
>  1 file changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index df10d4bad93b..10fc872141dc 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -180,10 +180,21 @@ each attachment handler is logged in buffers with names 
> beginning
>  )
>"List of Mailing List Archives to use when stashing links.
>  
> -These URIs are concatenated with the current message's
> -Message-Id in `notmuch-show-stash-mlarchive-link'."
> +This list is used for generating a Mailing List Archive reference
> +URI with the current message's Message-Id in
> +`notmuch-show-stash-mlarchive-link'.
> +
> +If the cdr of the alist element is not a function, the cdr is
> +expected to contain a URI that is concatenated with the current
> +message's Message-Id to create a ML archive reference URI.
> +
> +If the cdr is a function, the function is called with the
> +Message-Id as the argument, and the function is expected to
> +return the ML archive reference URI."
>:type '(alist :key-type (string :tag "Name")
> - :value-type (string :tag "URL"))
> + :value-type (choice
> +  (string :tag "URL")
> +  (function :tag "Function returning the URL")))
>:group 'notmuch-show)
>  
>  (defcustom notmuch-show-stash-mlarchive-link-default "Gmane"
> @@ -2055,16 +2066,19 @@ This presumes that the message is available at the 
> selected Mailing List Archive
>  If optional argument MLA is non-nil, use the provided key instead of 
> prompting
>  the user (see `notmuch-show-stash-mlarchive-link-alist')."
>(interactive)
> -  (notmuch-common-do-stash
> -   (concat (cdr (assoc
> -  (or mla
> -  (let ((completion-ignore-case t))
> -(completing-read
> - "Mailing List Archive: "
> - notmuch-show-stash-mlarchive-link-alist
> - nil t nil nil 
> notmuch-show-stash-mlarchive-link-default)))
> -  notmuch-show-stash-mlarchive-link-alist))
> -(notmuch-show-get-message-id t
> +  (let ((url (cdr (assoc
> +(or mla
> +(let ((completion-ignore-case t))
> +  (completing-read
> +   "Mailing List Archive: "
> +   notmuch-show-stash-mlarchive-link-alist
> +   nil t nil nil
> +   notmuch-show-stash-mlarchive-link-default)))
> +notmuch-show-stash-mlarchive-link-alist
> +(notmuch-common-do-stash
> + (if (functionp url)
> +  (funcall url (notmuch-show-get-message-id t))
> +   (concat url (notmuch-show-get-message-id t))
>  
>  (defun notmuch-show-stash-mlarchive-link-and-go ( mla)
>"Copy an ML Archive URI for the current message to the kill-ring and visit 
> it.
> -- 
> 1.9.2


[PATCH] NEWS: folder:, path:, and database upgrade

2014-05-02 Thread Mark Walters

I don't like the wildcard bit as an important part of the change was the
removal of stemming. Perhaps keep exact in the headline and in the body
say explicitly what the changes are no stemming, no wildcards (except
globbing), etc (maybe case sensitivity is different?)

Best wishes

Mark



On Thu, 01 May 2014, David Edmondson  wrote:
> On Sun, Apr 27 2014, Jani Nikula wrote:
>> +The `folder:` search prefix now requires an exact match
>
> I think that it would be clearer to say:
>
>   The `folder:` search prefix no longer supports wildcard matching
>
> (Or something like that.)
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 0/5] Add support for specifying tags during "notmuch new"

2014-05-02 Thread Mark Walters

Version 2 passes all tests and LGTM. +1

Best wishes

Mark

On Fri, 02 May 2014, David Edmondson  wrote:
> v1:
>
> This patch set allows a user to specify a list of tags to be
> added/removed to messages discovered during "notmuch new".
>
> Two use-cases are envisaged:
> 1) A chunk of messages was just dumped into the configured
>directory by hand, and the user doesn't want the 'inbox' tag
>applied to them. Run 'notmuch new -inbox'.
> 2) A periodic mail processing script wants to add new messages to
>the database, then process those newly added messages to add
>convenience tags, etc. without worrying about the user or other
>instances of the script manipulating tags at the same time. Use
>this approach:
>  KEY=$RANDOM
>notmuch new +$KEY
>notmuch tag +notmuch tag:$KEY and to:notmuch at notmuchmail.org
>notmuch tag +gnus tag:$KEY and to:ding at gnus.org
>...
>notmuch tag -$KEY tag:$KEY
>
> v2: The first version synced tags to flags rather than the other way
> around. Thanks to Mark for complaining at me.
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


folder and path completely broken in HEAD?

2014-05-02 Thread David Mazieres expires 2014-07-31 PDT
Mark Walters  writes:

> Hi
>
> Before checking other things: have you run notmuch new? That's needed to
> update the database. It is an irreversible update so notmuch-0.17 will
> not work with the updated database.

No, I haven't.  Okay, so that must be it.  Sorry for bothering people.
The discussion of the NEWS was a bit confusing, so I wanted to check it
out.  I knew something had to be very wrong.

Weill the new primitives still allow me to group my mail hierarchically
in searches?  The new man page is not totally clear on what is being
matched.

Thanks,
David


[PATCH 5/5] Test: Add tests for "notmuch new" command line tags

2014-05-02 Thread David Edmondson
Add a simple set of tests for adding, removing and both adding and
removing tags when running "notmuch new".
---
 test/T540-new-tags.sh | 28 
 1 file changed, 28 insertions(+)
 create mode 100755 test/T540-new-tags.sh

diff --git a/test/T540-new-tags.sh b/test/T540-new-tags.sh
new file mode 100755
index 000..58e6c18
--- /dev/null
+++ b/test/T540-new-tags.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+test_description="'notmuch new' with tags"
+. ./test-lib.sh
+
+which notmuch
+
+test_begin_subtest "Add tags during new"
+generate_message
+notmuch new +happyfunball +flyfishing
+output=$(notmuch search "id:${gen_msg_id}")
+expected='thread:0001   2001-01-05 [1/1] Notmuch Test Suite; Add 
tags during new (flyfishing happyfunball inbox unread)'
+test_expect_equal "$output" "$expected"
+
+test_begin_subtest "Remove tags during new"
+generate_message
+notmuch new -inbox
+output=$(notmuch search "id:${gen_msg_id}")
+expected='thread:0002   2001-01-05 [1/1] Notmuch Test Suite; 
Remove tags during new (unread)'
+test_expect_equal "$output" "$expected"
+
+test_begin_subtest "Add and remove tags during new"
+generate_message
+notmuch new +happyfunball -inbox
+output=$(notmuch search "id:${gen_msg_id}")
+expected='thread:0003   2001-01-05 [1/1] Notmuch Test Suite; Add 
and remove tags during new (happyfunball unread)'
+test_expect_equal "$output" "$expected"
+
+test_done
-- 
1.9.2



[PATCH 4/5] NEWS: Add information about "notmuch new" command line tags.

2014-05-02 Thread David Edmondson
---
 NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index bcd311d..13ae593 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,12 @@ Command-Line Interface

   This option suppresses the progress and summary reports.

+`notmuch new` allows tag addition/removal to be specified
+
+  An additional set of tags to be added or removed to messages
+  discovered by `notmuch new` can be specified. These are in addition
+  to the existing configured tags.
+
 Emacs Interface
 ---

-- 
1.9.2



[PATCH 3/5] notmuch-new: Manual: Add command line tags.

2014-05-02 Thread David Edmondson
Describe the addition of command line tags for "notmuch new".
---
 doc/man1/notmuch-new.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst
index 787ed78..84203de 100644
--- a/doc/man1/notmuch-new.rst
+++ b/doc/man1/notmuch-new.rst
@@ -5,7 +5,7 @@ notmuch-new
 SYNOPSIS
 

-**notmuch** **new** [options]
+**notmuch** **new** [options] [+<*tag*>|-<*tag*> ...]

 DESCRIPTION
 ===
@@ -15,7 +15,7 @@ Find and import any new messages to the database.
 The **new** command scans all sub-directories of the database,
 performing full-text indexing on new messages that are found. Each new
 message will automatically be tagged with both the **inbox** and
-**unread** tags.
+**unread** tags, as well as any tags specified on the command line.

 You should run **notmuch new** once after first running **notmuch
 setup** to create the initial database. The first run may take a long
-- 
1.9.2



[PATCH 2/5] notmuch-new: Allow the tags of new messages to be manipulated.

2014-05-02 Thread David Edmondson
Add support for specifying a set of tags to be added/removed from
messages added to the database by 'notmuch new'. These tags are
addition to those specified in .notmuch-config. They can be used to
override the pre-configured tags (e.g. -inbox).
---
 notmuch-new.c |  5 +
 tag-util.c| 20 +++-
 tag-util.h| 15 +++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 2c3d680..b49e5b2 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -951,6 +951,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);

+/* Add the configured tags to the list applied. */
 for (i = 0; i < new_tags_length; i++) {
const char *error_msg;

@@ -963,6 +964,10 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
return EXIT_FAILURE;
 }

+/* Add any command line tags to the list applied. */
+if (process_tag_command_line (argc - opt_index, [opt_index], 
add_files_state.tag_ops) < 0)
+   return EXIT_FAILURE;
+
 if (!no_hooks) {
ret = notmuch_run_hook (db_path, "pre-new");
if (ret)
diff --git a/tag-util.c b/tag-util.c
index 1dee2f3..94061f3 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -151,11 +151,9 @@ parse_tag_line (void *ctx, char *line,
 return ret;
 }

-tag_parse_status_t
-parse_tag_command_line (void *ctx, int argc, char **argv,
-   char **query_str, tag_op_list_t *tag_ops)
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *tag_ops)
 {
-
 int i;

 for (i = 0; i < argc; i++) {
@@ -173,12 +171,24 @@ parse_tag_command_line (void *ctx, int argc, char **argv,
msg = illegal_tag (argv[i] + 1, is_remove);
if (msg) {
fprintf (stderr, "Error: %s\n", msg);
-   return TAG_PARSE_INVALID;
+   return -1;
}

tag_op_list_append (tag_ops, argv[i] + 1, is_remove);
 }

+return i;
+}
+
+tag_parse_status_t
+parse_tag_command_line (void *ctx, int argc, char **argv,
+   char **query_str, tag_op_list_t *tag_ops)
+{
+int i = process_tag_command_line (argc, argv, tag_ops);
+
+if (i < 0)
+   return TAG_PARSE_INVALID;
+
 *query_str = query_string_from_args (ctx, argc - i, [i]);

 if (*query_str == NULL) {
diff --git a/tag-util.h b/tag-util.h
index 512cfac..f757e6b 100644
--- a/tag-util.h
+++ b/tag-util.h
@@ -78,6 +78,21 @@ parse_tag_line (void *ctx, char *line,



+/* Process a command line of the following format:
+ *
+ * +|- [...] [--]
+ *
+ * Return the number of tags operations, or -1 for failure to parse.
+ *
+ * Output Parameters:
+ * ops contains a list of tag operations
+ *
+ * The ops argument is not cleared.
+ */
+
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *ops);
+
 /* Parse a command line of the following format:
  *
  * +|- [...] [--] 
-- 
1.9.2



[PATCH 1/5] notmuch-new: Use tag_op_list_apply() rather than hand-coding the same.

2014-05-02 Thread David Edmondson
Rather than hand-coding the application of tags to new messages, use
the existing tag_op_list_apply().
fixup.
---
 notmuch-new.c | 31 ---
 tag-util.c|  8 
 tag-util.h| 10 +++---
 3 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index d269c7c..2c3d680 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -45,10 +45,9 @@ typedef struct {
 int output_is_a_tty;
 enum verbosity verbosity;
 notmuch_bool_t debug;
-const char **new_tags;
-size_t new_tags_length;
 const char **new_ignore;
 size_t new_ignore_length;
+tag_op_list_t *tag_ops;

 int total_files;
 int processed_files;
@@ -253,7 +252,6 @@ add_file (notmuch_database_t *notmuch, const char *filename,
  add_files_state_t *state)
 {
 notmuch_message_t *message = NULL;
-const char **tag;
 notmuch_status_t status;

 status = notmuch_database_begin_atomic (notmuch);
@@ -263,14 +261,13 @@ add_file (notmuch_database_t *notmuch, const char 
*filename,
 status = notmuch_database_add_message (notmuch, filename, );
 switch (status) {
 /* Success. */
-case NOTMUCH_STATUS_SUCCESS:
-   state->added_messages++;
-   notmuch_message_freeze (message);
-   for (tag = state->new_tags; *tag != NULL; tag++)
-   notmuch_message_add_tag (message, *tag);
+case NOTMUCH_STATUS_SUCCESS:;
+   tag_op_flag_t flags = 0;
+
if (state->synchronize_flags)
-   notmuch_message_maildir_flags_to_tags (message);
-   notmuch_message_thaw (message);
+   flags |= TAG_FLAG_TAG_SYNC;
+   state->added_messages++;
+   (void) tag_op_list_apply (message, state->tag_ops, flags);
break;
 /* Non-fatal issues (go on to next file). */
 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
@@ -923,6 +920,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 notmuch_bool_t timer_is_active = FALSE;
 notmuch_bool_t no_hooks = FALSE;
 notmuch_bool_t quiet = FALSE, verbose = FALSE;
+const char **new_tags;
+size_t new_tags_length;

 add_files_state.verbosity = VERBOSITY_NORMAL;
 add_files_state.debug = FALSE;
@@ -946,20 +945,22 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 else if (verbose)
add_files_state.verbosity = VERBOSITY_VERBOSE;

-add_files_state.new_tags = notmuch_config_get_new_tags (config, 
_files_state.new_tags_length);
+new_tags = notmuch_config_get_new_tags (config, _tags_length);
 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, 
_files_state.new_ignore_length);
 add_files_state.synchronize_flags = 
notmuch_config_get_maildir_synchronize_flags (config);
+add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);

-for (i = 0; i < add_files_state.new_tags_length; i++) {
+for (i = 0; i < new_tags_length; i++) {
const char *error_msg;

-   error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
+   error_msg = illegal_tag (new_tags[i], FALSE);
if (error_msg) {
-   fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
-add_files_state.new_tags[i], error_msg);
+   fprintf (stderr, "Error: tag '%s' in new.tags: %s\n", new_tags[i], 
error_msg);
return EXIT_FAILURE;
}
+   if (tag_op_list_append (add_files_state.tag_ops, new_tags[i], FALSE) != 
0)
+   return EXIT_FAILURE;
 }

 if (!no_hooks) {
diff --git a/tag-util.c b/tag-util.c
index 343c161..1dee2f3 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -327,6 +327,14 @@ tag_op_list_apply (notmuch_message_t *message,
}
 }

+if (flags & TAG_FLAG_TAG_SYNC) {
+   status = notmuch_message_maildir_flags_to_tags (message);
+   if (status) {
+   message_error (message, status, "synching maildir to tags");
+   return status;
+   }
+}
+
 return NOTMUCH_STATUS_SUCCESS;

 }
diff --git a/tag-util.h b/tag-util.h
index 8a4074c..512cfac 100644
--- a/tag-util.h
+++ b/tag-util.h
@@ -14,19 +14,23 @@ typedef enum {
  */
 TAG_FLAG_MAILDIR_SYNC = (1 << 0),

+/* Operations are synced from maildir, if possible.
+ */
+TAG_FLAG_TAG_SYNC = (1 << 1),
+
 /* Remove all tags from message before applying list.
  */
-TAG_FLAG_REMOVE_ALL = (1 << 1),
+TAG_FLAG_REMOVE_ALL = (1 << 2),

 /* Don't try to avoid database operations. Useful when we
  * know that message passed needs these operations.
  */
-TAG_FLAG_PRE_OPTIMIZED = (1 << 2),
+TAG_FLAG_PRE_OPTIMIZED = (1 << 3),

 /* Accept strange tags that might be user error;
  * intended for use by notmuch-restore.
  */
-TAG_FLAG_BE_GENEROUS = (1 << 3)
+TAG_FLAG_BE_GENEROUS = (1 << 4)

 } tag_op_flag_t;

-- 
1.9.2



[PATCH v2 0/5] Add support for specifying tags during "notmuch new"

2014-05-02 Thread David Edmondson
v1:

This patch set allows a user to specify a list of tags to be
added/removed to messages discovered during "notmuch new".

Two use-cases are envisaged:
1) A chunk of messages was just dumped into the configured
   directory by hand, and the user doesn't want the 'inbox' tag
   applied to them. Run 'notmuch new -inbox'.
2) A periodic mail processing script wants to add new messages to
   the database, then process those newly added messages to add
   convenience tags, etc. without worrying about the user or other
   instances of the script manipulating tags at the same time. Use
   this approach:
 KEY=$RANDOM
 notmuch new +$KEY
 notmuch tag +notmuch tag:$KEY and to:notmuch at notmuchmail.org
 notmuch tag +gnus tag:$KEY and to:ding at gnus.org
 ...
 notmuch tag -$KEY tag:$KEY

v2: The first version synced tags to flags rather than the other way
around. Thanks to Mark for complaining at me.
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 310 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140502/0cd7d669/attachment.pgp>


precedence in `notmuch-search-line-faces'

2014-05-02 Thread David Edmondson
The documentation for `notmuch-search-line-faces' says:

> The attributes defined for matching tags are merged, with later
> attributes overriding earlier.

A comment in `notmuch-search-color-line', which implements this, says:

> ;; Reverse the list so earlier entries take precedence

Clearly these two are at odds. The implementation of
`notmuch-search-color-line' follows the comment. That is, earlier
entries in the list take precedence.

The original implementation of `notmuch-search-color-line' followed the
documentation of the user-visible variable, but this was changed by
commit 60ebc849 in July 2012.

I'm inclined to go with the documentation and change the implementation,
but this could obviously ruin things for some users until they reorder
their settings.

Thoughts?
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 310 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20140502/a9efa182/attachment.pgp>


Final call for news for 0.18

2014-05-02 Thread Tomi Ollila
On Fri, May 02 2014, Felipe Contreras  wrote:

> Tomi Ollila wrote:
>
>> PS: does vim frontend lack id:message-id feature --
>
> What feature?

In Emacs MUA, when one presses ENTER (or clicks mouse) on top of
text containing id: the client opens that particular message.

> -- 
> Felipe Contreras


Tomi


Final call for news for 0.18

2014-05-02 Thread Tomi Ollila
On Fri, May 02 2014, David Bremner  wrote:

> Felipe Contreras  writes:
>
>>
>>> Also NEWS for these changes are missing.
>>
>> Shouldn't the NEWS be written by the maintainers? In fact, aren't they
>> the ones that decide if something is worth mentioning in the NEWS or
>> not?
>>
>
> Hi Felipe;
>
> I guess for the Vim/ruby stuff you're best positioned to judge what is
> important.  We run a kind of pyramid scheme: people generally submit
> short summaries of their own user visible changes; this is the first
> release that I've written a short summary of that.

That said (by David) I'm happy w/ your revised patch set, provided you
also add a NEWS patch, on top of 'release' branch.


For writing NEWS patch: NEWS patches should be written by the one authoring
the corresponding change. And everyone else judges whether the NEWS are
good enough, and the iteration goes on. Finally unless NEWS are
satisfactionary, the patches in question are reverted from the repository >;D
I.e. ease the work of maintainers by providing relevant NEWS by the time of
release :D

>
> d

Tomi


Final call for news for 0.18

2014-05-02 Thread David Bremner
Felipe Contreras  writes:

>
>> Also NEWS for these changes are missing.
>
> Shouldn't the NEWS be written by the maintainers? In fact, aren't they
> the ones that decide if something is worth mentioning in the NEWS or
> not?
>

Hi Felipe;

I guess for the Vim/ruby stuff you're best positioned to judge what is
important.  We run a kind of pyramid scheme: people generally submit
short summaries of their own user visible changes; this is the first
release that I've written a short summary of that.

d


Add support for specifying tags during "notmuch new"

2014-05-02 Thread Austin Clements
Quoth David Edmondson on May 02 at  9:15 am:
> This patch set allows a user to specify a list of tags to be
> added/removed to messages discovered during "notmuch new".
> 
> Two use-cases are envisaged:
> 1) A chunk of messages was just dumped into the configured
>directory by hand, and the user doesn't want the 'inbox' tag
>applied to them. Run 'notmuch new -inbox'.
> 2) A periodic mail processing script wants to add new messages to
>the database, then process those newly added messages to add
>convenience tags, etc. without worrying about the user or other
>instances of the script manipulating tags at the same time. Use
>this approach:
>  KEY=$RANDOM
>notmuch new +$KEY
>notmuch tag +notmuch tag:$KEY and to:notmuch at notmuchmail.org
>notmuch tag +gnus tag:$KEY and to:ding at gnus.org
>...
>notmuch tag -$KEY tag:$KEY

What happens when this script dies in the middle (say, your computer
loses power or notmuch tag conflicts with something else on the write
lock)?  One advantage of the standard "new" tag approach is that it's
easy to write a stateless post-new tagging script that can be killed
at any point and restarted.  (You're right that post-new has a
concurrency issue, but we should fix that in its own right.)


folder and path completely broken in HEAD?

2014-05-02 Thread dm-list-email-notm...@scs.stanford.edu
Hey, I'm playing around with the head of the git repository
(bc64cdce289d84be2550c4fccb1f008d15eaeb0e) to try to figure out how the
new folder: prefixes work, as folders are a critical part of how I
organize my mail.  (Since tags are not hierarchical, folders are the
best way for me to group mail to a bunch of related addresses, while
retaining the ability to separate out any mailboxes that become high
traffic.)

I'm using a pretty standard maildir++ layout.  For example, underneath
my database.path I have a bunch of mail in directories such as:

.INBOX.Main/{new,cur}
.mail.class/{new,cur}
.mail.voicemail/{new,cur}

It used to be the case that if I wanted to read all of my "mail" mail, I
could search for folder:mail, while to look at just voicemail, I could
say folder:mail.voicemail, etc.  Now, I can't get anything to match a
folder predicate period.  For example, using notmuch as notmuch-0.17 and
./notmuch as notmuch-0.18-rc2+2~gbc64cdc, here's what I get:

linux2$ notmuch count folder:mail
16257
linux3$ notmuch count folder:mail.class
1896
linux4$ notmuch count folder:mail.voicemail
34
linux5$ notmuch count folder:mail.voicemail/cur
34
linux6$ notmuch count folder:.mail.voicemail/cur
34
linux7$ ./notmuch count folder:mail
0
linux8$ ./notmuch count folder:.mail
0
linux9$ ./notmuch count folder:.mail.voicemail
0
linux10$ ./notmuch count folder:.mail.voicemail/cur
0
linux 11$ ./notmuch count path:.mail.voicemail
0
linux 12$ ./notmuch count path:.mail.voicemail/'**'
0
linux 13$ ./notmuch count path:.mail.voicemail/cur 
0
linux 14$ ./notmuch count folder:mail.voicemail
0

What gives?  Are the path and folder predicates completely broken, or is
something very important missing from the new notmuch-search-terms
manual page?  How can I make this work?

Thanks,
David


[PATCH 4/5] NEWS: Add information about "notmuch new" command line tags.

2014-05-02 Thread David Edmondson
---
 NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index bcd311d..13ae593 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,12 @@ Command-Line Interface

   This option suppresses the progress and summary reports.

+`notmuch new` allows tag addition/removal to be specified
+
+  An additional set of tags to be added or removed to messages
+  discovered by `notmuch new` can be specified. These are in addition
+  to the existing configured tags.
+
 Emacs Interface
 ---

-- 
1.9.2



[PATCH 3/5] notmuch-new: Manual: Add command line tags.

2014-05-02 Thread David Edmondson
Describe the addition of command line tags for "notmuch new".
---
 doc/man1/notmuch-new.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst
index 787ed78..84203de 100644
--- a/doc/man1/notmuch-new.rst
+++ b/doc/man1/notmuch-new.rst
@@ -5,7 +5,7 @@ notmuch-new
 SYNOPSIS
 

-**notmuch** **new** [options]
+**notmuch** **new** [options] [+<*tag*>|-<*tag*> ...]

 DESCRIPTION
 ===
@@ -15,7 +15,7 @@ Find and import any new messages to the database.
 The **new** command scans all sub-directories of the database,
 performing full-text indexing on new messages that are found. Each new
 message will automatically be tagged with both the **inbox** and
-**unread** tags.
+**unread** tags, as well as any tags specified on the command line.

 You should run **notmuch new** once after first running **notmuch
 setup** to create the initial database. The first run may take a long
-- 
1.9.2



[PATCH 2/5] notmuch-new: Allow the tags of new messages to be manipulated.

2014-05-02 Thread David Edmondson
Add support for specifying a set of tags to be added/removed from
messages added to the database by 'notmuch new'. These tags are
addition to those specified in .notmuch-config. They can be used to
override the pre-configured tags (e.g. -inbox).
---
 notmuch-new.c |  5 +
 tag-util.c| 20 +++-
 tag-util.h| 15 +++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index b53401a..855e1e2 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -951,6 +951,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);

+/* Add the configured tags to the list applied. */
 for (i = 0; i < new_tags_length; i++) {
const char *error_msg;

@@ -963,6 +964,10 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
return EXIT_FAILURE;
 }

+/* Add any command line tags to the list applied. */
+if (process_tag_command_line (argc - opt_index, [opt_index], 
add_files_state.tag_ops) < 0)
+   return EXIT_FAILURE;
+
 if (!no_hooks) {
ret = notmuch_run_hook (db_path, "pre-new");
if (ret)
diff --git a/tag-util.c b/tag-util.c
index 343c161..5ad78aa 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -151,11 +151,9 @@ parse_tag_line (void *ctx, char *line,
 return ret;
 }

-tag_parse_status_t
-parse_tag_command_line (void *ctx, int argc, char **argv,
-   char **query_str, tag_op_list_t *tag_ops)
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *tag_ops)
 {
-
 int i;

 for (i = 0; i < argc; i++) {
@@ -173,12 +171,24 @@ parse_tag_command_line (void *ctx, int argc, char **argv,
msg = illegal_tag (argv[i] + 1, is_remove);
if (msg) {
fprintf (stderr, "Error: %s\n", msg);
-   return TAG_PARSE_INVALID;
+   return -1;
}

tag_op_list_append (tag_ops, argv[i] + 1, is_remove);
 }

+return i;
+}
+
+tag_parse_status_t
+parse_tag_command_line (void *ctx, int argc, char **argv,
+   char **query_str, tag_op_list_t *tag_ops)
+{
+int i = process_tag_command_line (argc, argv, tag_ops);
+
+if (i < 0)
+   return TAG_PARSE_INVALID;
+
 *query_str = query_string_from_args (ctx, argc - i, [i]);

 if (*query_str == NULL) {
diff --git a/tag-util.h b/tag-util.h
index 8a4074c..9f2c18c 100644
--- a/tag-util.h
+++ b/tag-util.h
@@ -74,6 +74,21 @@ parse_tag_line (void *ctx, char *line,



+/* Process a command line of the following format:
+ *
+ * +|- [...] [--]
+ *
+ * Return the number of tags operations, or -1 for failure to parse.
+ *
+ * Output Parameters:
+ * ops contains a list of tag operations
+ *
+ * The ops argument is not cleared.
+ */
+
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *ops);
+
 /* Parse a command line of the following format:
  *
  * +|- [...] [--] 
-- 
1.9.2



[PATCH 1/5] notmuch-new: Use tag_op_list_apply() rather than hand-coding the same.

2014-05-02 Thread David Edmondson
Rather than hand-coding the application of tags to new messages, use
the existing tag_op_list_apply().
---
 notmuch-new.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index d269c7c..b53401a 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -45,10 +45,9 @@ typedef struct {
 int output_is_a_tty;
 enum verbosity verbosity;
 notmuch_bool_t debug;
-const char **new_tags;
-size_t new_tags_length;
 const char **new_ignore;
 size_t new_ignore_length;
+tag_op_list_t *tag_ops;

 int total_files;
 int processed_files;
@@ -253,7 +252,6 @@ add_file (notmuch_database_t *notmuch, const char *filename,
  add_files_state_t *state)
 {
 notmuch_message_t *message = NULL;
-const char **tag;
 notmuch_status_t status;

 status = notmuch_database_begin_atomic (notmuch);
@@ -263,14 +261,13 @@ add_file (notmuch_database_t *notmuch, const char 
*filename,
 status = notmuch_database_add_message (notmuch, filename, );
 switch (status) {
 /* Success. */
-case NOTMUCH_STATUS_SUCCESS:
-   state->added_messages++;
-   notmuch_message_freeze (message);
-   for (tag = state->new_tags; *tag != NULL; tag++)
-   notmuch_message_add_tag (message, *tag);
+case NOTMUCH_STATUS_SUCCESS:;
+   tag_op_flag_t flags = 0;
+
if (state->synchronize_flags)
-   notmuch_message_maildir_flags_to_tags (message);
-   notmuch_message_thaw (message);
+   flags |= TAG_FLAG_MAILDIR_SYNC;
+   state->added_messages++;
+   (void) tag_op_list_apply (message, state->tag_ops, flags);
break;
 /* Non-fatal issues (go on to next file). */
 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
@@ -923,6 +920,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 notmuch_bool_t timer_is_active = FALSE;
 notmuch_bool_t no_hooks = FALSE;
 notmuch_bool_t quiet = FALSE, verbose = FALSE;
+const char **new_tags;
+size_t new_tags_length;

 add_files_state.verbosity = VERBOSITY_NORMAL;
 add_files_state.debug = FALSE;
@@ -946,20 +945,22 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 else if (verbose)
add_files_state.verbosity = VERBOSITY_VERBOSE;

-add_files_state.new_tags = notmuch_config_get_new_tags (config, 
_files_state.new_tags_length);
+new_tags = notmuch_config_get_new_tags (config, _tags_length);
 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, 
_files_state.new_ignore_length);
 add_files_state.synchronize_flags = 
notmuch_config_get_maildir_synchronize_flags (config);
+add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);

-for (i = 0; i < add_files_state.new_tags_length; i++) {
+for (i = 0; i < new_tags_length; i++) {
const char *error_msg;

-   error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
+   error_msg = illegal_tag (new_tags[i], FALSE);
if (error_msg) {
-   fprintf (stderr, "Error: tag '%s' in new.tags: %s\n",
-add_files_state.new_tags[i], error_msg);
+   fprintf (stderr, "Error: tag '%s' in new.tags: %s\n", new_tags[i], 
error_msg);
return EXIT_FAILURE;
}
+   if (tag_op_list_append (add_files_state.tag_ops, new_tags[i], FALSE) != 
0)
+   return EXIT_FAILURE;
 }

 if (!no_hooks) {
-- 
1.9.2



Add support for specifying tags during "notmuch new"

2014-05-02 Thread David Edmondson
This patch set allows a user to specify a list of tags to be
added/removed to messages discovered during "notmuch new".

Two use-cases are envisaged:
1) A chunk of messages was just dumped into the configured
   directory by hand, and the user doesn't want the 'inbox' tag
   applied to them. Run 'notmuch new -inbox'.
2) A periodic mail processing script wants to add new messages to
   the database, then process those newly added messages to add
   convenience tags, etc. without worrying about the user or other
   instances of the script manipulating tags at the same time. Use
   this approach:
 KEY=$RANDOM
 notmuch new +$KEY
 notmuch tag +notmuch tag:$KEY and to:notmuch at notmuchmail.org
 notmuch tag +gnus tag:$KEY and to:ding at gnus.org
 ...
 notmuch tag -$KEY tag:$KEY



[PATCH 5/5] NEWS: insert and new refuse invalid tags

2014-05-02 Thread David Bremner
Jani Nikula  writes:

> ---
>  NEWS | 7 +++
>  1 file changed, 7 insertions(+)

pushed jani's 5 patches, and an amended version of mine


[PATCH 2/5] notmuch-new: Allow the tags of new messages to be manipulated.

2014-05-02 Thread David Edmondson
Add support for specifying a set of tags to be added/removed from
messages added to the database by 'notmuch new'. These tags are
addition to those specified in .notmuch-config. They can be used to
override the pre-configured tags (e.g. -inbox).
---
 notmuch-new.c |  5 +
 tag-util.c| 20 +++-
 tag-util.h| 15 +++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index b53401a..855e1e2 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -951,6 +951,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);
 
+/* Add the configured tags to the list applied. */
 for (i = 0; i  new_tags_length; i++) {
const char *error_msg;
 
@@ -963,6 +964,10 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
return EXIT_FAILURE;
 }
 
+/* Add any command line tags to the list applied. */
+if (process_tag_command_line (argc - opt_index, argv[opt_index], 
add_files_state.tag_ops)  0)
+   return EXIT_FAILURE;
+
 if (!no_hooks) {
ret = notmuch_run_hook (db_path, pre-new);
if (ret)
diff --git a/tag-util.c b/tag-util.c
index 343c161..5ad78aa 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -151,11 +151,9 @@ parse_tag_line (void *ctx, char *line,
 return ret;
 }
 
-tag_parse_status_t
-parse_tag_command_line (void *ctx, int argc, char **argv,
-   char **query_str, tag_op_list_t *tag_ops)
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *tag_ops)
 {
-
 int i;
 
 for (i = 0; i  argc; i++) {
@@ -173,12 +171,24 @@ parse_tag_command_line (void *ctx, int argc, char **argv,
msg = illegal_tag (argv[i] + 1, is_remove);
if (msg) {
fprintf (stderr, Error: %s\n, msg);
-   return TAG_PARSE_INVALID;
+   return -1;
}
 
tag_op_list_append (tag_ops, argv[i] + 1, is_remove);
 }
 
+return i;
+}
+
+tag_parse_status_t
+parse_tag_command_line (void *ctx, int argc, char **argv,
+   char **query_str, tag_op_list_t *tag_ops)
+{
+int i = process_tag_command_line (argc, argv, tag_ops);
+
+if (i  0)
+   return TAG_PARSE_INVALID;
+
 *query_str = query_string_from_args (ctx, argc - i, argv[i]);
 
 if (*query_str == NULL) {
diff --git a/tag-util.h b/tag-util.h
index 8a4074c..9f2c18c 100644
--- a/tag-util.h
+++ b/tag-util.h
@@ -74,6 +74,21 @@ parse_tag_line (void *ctx, char *line,
 
 
 
+/* Process a command line of the following format:
+ *
+ * +tag|-tag [...] [--]
+ *
+ * Return the number of tags operations, or -1 for failure to parse.
+ *
+ * Output Parameters:
+ * ops contains a list of tag operations
+ *
+ * The ops argument is not cleared.
+ */
+
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *ops);
+
 /* Parse a command line of the following format:
  *
  * +tag|-tag [...] [--] search-terms
-- 
1.9.2

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


Add support for specifying tags during notmuch new

2014-05-02 Thread David Edmondson
This patch set allows a user to specify a list of tags to be
added/removed to messages discovered during notmuch new.

Two use-cases are envisaged:
1) A chunk of messages was just dumped into the configured
   directory by hand, and the user doesn't want the 'inbox' tag
   applied to them. Run 'notmuch new -inbox'.
2) A periodic mail processing script wants to add new messages to
   the database, then process those newly added messages to add
   convenience tags, etc. without worrying about the user or other
   instances of the script manipulating tags at the same time. Use
   this approach:
 KEY=$RANDOM
 notmuch new +$KEY
 notmuch tag +notmuch tag:$KEY and to:notmuch@notmuchmail.org
 notmuch tag +gnus tag:$KEY and to:d...@gnus.org
 ...
 notmuch tag -$KEY tag:$KEY

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


[PATCH 5/5] Test: Add tests for notmuch new command line tags

2014-05-02 Thread David Edmondson
Add a simple set of tests for adding, removing and both adding and
removing tags when running notmuch new.
---
 test/T540-new-tags.sh | 28 
 1 file changed, 28 insertions(+)
 create mode 100755 test/T540-new-tags.sh

diff --git a/test/T540-new-tags.sh b/test/T540-new-tags.sh
new file mode 100755
index 000..58e6c18
--- /dev/null
+++ b/test/T540-new-tags.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+test_description='notmuch new' with tags
+. ./test-lib.sh
+
+which notmuch
+
+test_begin_subtest Add tags during new
+generate_message
+notmuch new +happyfunball +flyfishing
+output=$(notmuch search id:${gen_msg_id})
+expected='thread:0001   2001-01-05 [1/1] Notmuch Test Suite; Add 
tags during new (flyfishing happyfunball inbox unread)'
+test_expect_equal $output $expected
+
+test_begin_subtest Remove tags during new
+generate_message
+notmuch new -inbox
+output=$(notmuch search id:${gen_msg_id})
+expected='thread:0002   2001-01-05 [1/1] Notmuch Test Suite; 
Remove tags during new (unread)'
+test_expect_equal $output $expected
+
+test_begin_subtest Add and remove tags during new
+generate_message
+notmuch new +happyfunball -inbox
+output=$(notmuch search id:${gen_msg_id})
+expected='thread:0003   2001-01-05 [1/1] Notmuch Test Suite; Add 
and remove tags during new (happyfunball unread)'
+test_expect_equal $output $expected
+
+test_done
-- 
1.9.2

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


[PATCH 1/5] notmuch-new: Use tag_op_list_apply() rather than hand-coding the same.

2014-05-02 Thread David Edmondson
Rather than hand-coding the application of tags to new messages, use
the existing tag_op_list_apply().
---
 notmuch-new.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index d269c7c..b53401a 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -45,10 +45,9 @@ typedef struct {
 int output_is_a_tty;
 enum verbosity verbosity;
 notmuch_bool_t debug;
-const char **new_tags;
-size_t new_tags_length;
 const char **new_ignore;
 size_t new_ignore_length;
+tag_op_list_t *tag_ops;
 
 int total_files;
 int processed_files;
@@ -253,7 +252,6 @@ add_file (notmuch_database_t *notmuch, const char *filename,
  add_files_state_t *state)
 {
 notmuch_message_t *message = NULL;
-const char **tag;
 notmuch_status_t status;
 
 status = notmuch_database_begin_atomic (notmuch);
@@ -263,14 +261,13 @@ add_file (notmuch_database_t *notmuch, const char 
*filename,
 status = notmuch_database_add_message (notmuch, filename, message);
 switch (status) {
 /* Success. */
-case NOTMUCH_STATUS_SUCCESS:
-   state-added_messages++;
-   notmuch_message_freeze (message);
-   for (tag = state-new_tags; *tag != NULL; tag++)
-   notmuch_message_add_tag (message, *tag);
+case NOTMUCH_STATUS_SUCCESS:;
+   tag_op_flag_t flags = 0;
+
if (state-synchronize_flags)
-   notmuch_message_maildir_flags_to_tags (message);
-   notmuch_message_thaw (message);
+   flags |= TAG_FLAG_MAILDIR_SYNC;
+   state-added_messages++;
+   (void) tag_op_list_apply (message, state-tag_ops, flags);
break;
 /* Non-fatal issues (go on to next file). */
 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
@@ -923,6 +920,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 notmuch_bool_t timer_is_active = FALSE;
 notmuch_bool_t no_hooks = FALSE;
 notmuch_bool_t quiet = FALSE, verbose = FALSE;
+const char **new_tags;
+size_t new_tags_length;
 
 add_files_state.verbosity = VERBOSITY_NORMAL;
 add_files_state.debug = FALSE;
@@ -946,20 +945,22 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 else if (verbose)
add_files_state.verbosity = VERBOSITY_VERBOSE;
 
-add_files_state.new_tags = notmuch_config_get_new_tags (config, 
add_files_state.new_tags_length);
+new_tags = notmuch_config_get_new_tags (config, new_tags_length);
 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, 
add_files_state.new_ignore_length);
 add_files_state.synchronize_flags = 
notmuch_config_get_maildir_synchronize_flags (config);
+add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);
 
-for (i = 0; i  add_files_state.new_tags_length; i++) {
+for (i = 0; i  new_tags_length; i++) {
const char *error_msg;
 
-   error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
+   error_msg = illegal_tag (new_tags[i], FALSE);
if (error_msg) {
-   fprintf (stderr, Error: tag '%s' in new.tags: %s\n,
-add_files_state.new_tags[i], error_msg);
+   fprintf (stderr, Error: tag '%s' in new.tags: %s\n, new_tags[i], 
error_msg);
return EXIT_FAILURE;
}
+   if (tag_op_list_append (add_files_state.tag_ops, new_tags[i], FALSE) != 
0)
+   return EXIT_FAILURE;
 }
 
 if (!no_hooks) {
-- 
1.9.2

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


[PATCH 3/5] notmuch-new: Manual: Add command line tags.

2014-05-02 Thread David Edmondson
Describe the addition of command line tags for notmuch new.
---
 doc/man1/notmuch-new.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst
index 787ed78..84203de 100644
--- a/doc/man1/notmuch-new.rst
+++ b/doc/man1/notmuch-new.rst
@@ -5,7 +5,7 @@ notmuch-new
 SYNOPSIS
 
 
-**notmuch** **new** [options]
+**notmuch** **new** [options] [+*tag*|-*tag* ...]
 
 DESCRIPTION
 ===
@@ -15,7 +15,7 @@ Find and import any new messages to the database.
 The **new** command scans all sub-directories of the database,
 performing full-text indexing on new messages that are found. Each new
 message will automatically be tagged with both the **inbox** and
-**unread** tags.
+**unread** tags, as well as any tags specified on the command line.
 
 You should run **notmuch new** once after first running **notmuch
 setup** to create the initial database. The first run may take a long
-- 
1.9.2

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


[PATCH 4/5] NEWS: Add information about notmuch new command line tags.

2014-05-02 Thread David Edmondson
---
 NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index bcd311d..13ae593 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,12 @@ Command-Line Interface
 
   This option suppresses the progress and summary reports.
 
+`notmuch new` allows tag addition/removal to be specified
+
+  An additional set of tags to be added or removed to messages
+  discovered by `notmuch new` can be specified. These are in addition
+  to the existing configured tags.
+
 Emacs Interface
 ---
 
-- 
1.9.2

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


RE: Final call for news for 0.18

2014-05-02 Thread Tomi Ollila
On Fri, May 02 2014, Felipe Contreras felipe.contre...@gmail.com wrote:

 Tomi Ollila wrote:

 PS: does vim frontend lack id:message-id feature --

 What feature?

In Emacs MUA, when one presses ENTER (or clicks mouse) on top of
text containing id:message-id the client opens that particular message.

 -- 
 Felipe Contreras


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


precedence in `notmuch-search-line-faces'

2014-05-02 Thread David Edmondson
The documentation for `notmuch-search-line-faces' says:

 The attributes defined for matching tags are merged, with later
 attributes overriding earlier.

A comment in `notmuch-search-color-line', which implements this, says:

 ;; Reverse the list so earlier entries take precedence

Clearly these two are at odds. The implementation of
`notmuch-search-color-line' follows the comment. That is, earlier
entries in the list take precedence.

The original implementation of `notmuch-search-color-line' followed the
documentation of the user-visible variable, but this was changed by
commit 60ebc849 in July 2012.

I'm inclined to go with the documentation and change the implementation,
but this could obviously ruin things for some users until they reorder
their settings.

Thoughts?


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


[PATCH v2 0/5] Add support for specifying tags during notmuch new

2014-05-02 Thread David Edmondson
v1:

This patch set allows a user to specify a list of tags to be
added/removed to messages discovered during notmuch new.

Two use-cases are envisaged:
1) A chunk of messages was just dumped into the configured
   directory by hand, and the user doesn't want the 'inbox' tag
   applied to them. Run 'notmuch new -inbox'.
2) A periodic mail processing script wants to add new messages to
   the database, then process those newly added messages to add
   convenience tags, etc. without worrying about the user or other
   instances of the script manipulating tags at the same time. Use
   this approach:
 KEY=$RANDOM
 notmuch new +$KEY
 notmuch tag +notmuch tag:$KEY and to:notmuch@notmuchmail.org
 notmuch tag +gnus tag:$KEY and to:d...@gnus.org
 ...
 notmuch tag -$KEY tag:$KEY

v2: The first version synced tags to flags rather than the other way
around. Thanks to Mark for complaining at me.


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


[PATCH 3/5] notmuch-new: Manual: Add command line tags.

2014-05-02 Thread David Edmondson
Describe the addition of command line tags for notmuch new.
---
 doc/man1/notmuch-new.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/man1/notmuch-new.rst b/doc/man1/notmuch-new.rst
index 787ed78..84203de 100644
--- a/doc/man1/notmuch-new.rst
+++ b/doc/man1/notmuch-new.rst
@@ -5,7 +5,7 @@ notmuch-new
 SYNOPSIS
 
 
-**notmuch** **new** [options]
+**notmuch** **new** [options] [+*tag*|-*tag* ...]
 
 DESCRIPTION
 ===
@@ -15,7 +15,7 @@ Find and import any new messages to the database.
 The **new** command scans all sub-directories of the database,
 performing full-text indexing on new messages that are found. Each new
 message will automatically be tagged with both the **inbox** and
-**unread** tags.
+**unread** tags, as well as any tags specified on the command line.
 
 You should run **notmuch new** once after first running **notmuch
 setup** to create the initial database. The first run may take a long
-- 
1.9.2

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


[PATCH 1/5] notmuch-new: Use tag_op_list_apply() rather than hand-coding the same.

2014-05-02 Thread David Edmondson
Rather than hand-coding the application of tags to new messages, use
the existing tag_op_list_apply().
fixup.
---
 notmuch-new.c | 31 ---
 tag-util.c|  8 
 tag-util.h| 10 +++---
 3 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index d269c7c..2c3d680 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -45,10 +45,9 @@ typedef struct {
 int output_is_a_tty;
 enum verbosity verbosity;
 notmuch_bool_t debug;
-const char **new_tags;
-size_t new_tags_length;
 const char **new_ignore;
 size_t new_ignore_length;
+tag_op_list_t *tag_ops;
 
 int total_files;
 int processed_files;
@@ -253,7 +252,6 @@ add_file (notmuch_database_t *notmuch, const char *filename,
  add_files_state_t *state)
 {
 notmuch_message_t *message = NULL;
-const char **tag;
 notmuch_status_t status;
 
 status = notmuch_database_begin_atomic (notmuch);
@@ -263,14 +261,13 @@ add_file (notmuch_database_t *notmuch, const char 
*filename,
 status = notmuch_database_add_message (notmuch, filename, message);
 switch (status) {
 /* Success. */
-case NOTMUCH_STATUS_SUCCESS:
-   state-added_messages++;
-   notmuch_message_freeze (message);
-   for (tag = state-new_tags; *tag != NULL; tag++)
-   notmuch_message_add_tag (message, *tag);
+case NOTMUCH_STATUS_SUCCESS:;
+   tag_op_flag_t flags = 0;
+
if (state-synchronize_flags)
-   notmuch_message_maildir_flags_to_tags (message);
-   notmuch_message_thaw (message);
+   flags |= TAG_FLAG_TAG_SYNC;
+   state-added_messages++;
+   (void) tag_op_list_apply (message, state-tag_ops, flags);
break;
 /* Non-fatal issues (go on to next file). */
 case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
@@ -923,6 +920,8 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 notmuch_bool_t timer_is_active = FALSE;
 notmuch_bool_t no_hooks = FALSE;
 notmuch_bool_t quiet = FALSE, verbose = FALSE;
+const char **new_tags;
+size_t new_tags_length;
 
 add_files_state.verbosity = VERBOSITY_NORMAL;
 add_files_state.debug = FALSE;
@@ -946,20 +945,22 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 else if (verbose)
add_files_state.verbosity = VERBOSITY_VERBOSE;
 
-add_files_state.new_tags = notmuch_config_get_new_tags (config, 
add_files_state.new_tags_length);
+new_tags = notmuch_config_get_new_tags (config, new_tags_length);
 add_files_state.new_ignore = notmuch_config_get_new_ignore (config, 
add_files_state.new_ignore_length);
 add_files_state.synchronize_flags = 
notmuch_config_get_maildir_synchronize_flags (config);
+add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);
 
-for (i = 0; i  add_files_state.new_tags_length; i++) {
+for (i = 0; i  new_tags_length; i++) {
const char *error_msg;
 
-   error_msg = illegal_tag (add_files_state.new_tags[i], FALSE);
+   error_msg = illegal_tag (new_tags[i], FALSE);
if (error_msg) {
-   fprintf (stderr, Error: tag '%s' in new.tags: %s\n,
-add_files_state.new_tags[i], error_msg);
+   fprintf (stderr, Error: tag '%s' in new.tags: %s\n, new_tags[i], 
error_msg);
return EXIT_FAILURE;
}
+   if (tag_op_list_append (add_files_state.tag_ops, new_tags[i], FALSE) != 
0)
+   return EXIT_FAILURE;
 }
 
 if (!no_hooks) {
diff --git a/tag-util.c b/tag-util.c
index 343c161..1dee2f3 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -327,6 +327,14 @@ tag_op_list_apply (notmuch_message_t *message,
}
 }
 
+if (flags  TAG_FLAG_TAG_SYNC) {
+   status = notmuch_message_maildir_flags_to_tags (message);
+   if (status) {
+   message_error (message, status, synching maildir to tags);
+   return status;
+   }
+}
+
 return NOTMUCH_STATUS_SUCCESS;
 
 }
diff --git a/tag-util.h b/tag-util.h
index 8a4074c..512cfac 100644
--- a/tag-util.h
+++ b/tag-util.h
@@ -14,19 +14,23 @@ typedef enum {
  */
 TAG_FLAG_MAILDIR_SYNC = (1  0),
 
+/* Operations are synced from maildir, if possible.
+ */
+TAG_FLAG_TAG_SYNC = (1  1),
+
 /* Remove all tags from message before applying list.
  */
-TAG_FLAG_REMOVE_ALL = (1  1),
+TAG_FLAG_REMOVE_ALL = (1  2),
 
 /* Don't try to avoid database operations. Useful when we
  * know that message passed needs these operations.
  */
-TAG_FLAG_PRE_OPTIMIZED = (1  2),
+TAG_FLAG_PRE_OPTIMIZED = (1  3),
 
 /* Accept strange tags that might be user error;
  * intended for use by notmuch-restore.
  */
-TAG_FLAG_BE_GENEROUS = (1  3)
+TAG_FLAG_BE_GENEROUS = (1  4)
 
 } tag_op_flag_t;
 
-- 
1.9.2

___
notmuch mailing list

[PATCH 2/5] notmuch-new: Allow the tags of new messages to be manipulated.

2014-05-02 Thread David Edmondson
Add support for specifying a set of tags to be added/removed from
messages added to the database by 'notmuch new'. These tags are
addition to those specified in .notmuch-config. They can be used to
override the pre-configured tags (e.g. -inbox).
---
 notmuch-new.c |  5 +
 tag-util.c| 20 +++-
 tag-util.h| 15 +++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 2c3d680..b49e5b2 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -951,6 +951,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
 add_files_state.tag_ops = tag_op_list_create (config);
 db_path = notmuch_config_get_database_path (config);
 
+/* Add the configured tags to the list applied. */
 for (i = 0; i  new_tags_length; i++) {
const char *error_msg;
 
@@ -963,6 +964,10 @@ notmuch_new_command (notmuch_config_t *config, int argc, 
char *argv[])
return EXIT_FAILURE;
 }
 
+/* Add any command line tags to the list applied. */
+if (process_tag_command_line (argc - opt_index, argv[opt_index], 
add_files_state.tag_ops)  0)
+   return EXIT_FAILURE;
+
 if (!no_hooks) {
ret = notmuch_run_hook (db_path, pre-new);
if (ret)
diff --git a/tag-util.c b/tag-util.c
index 1dee2f3..94061f3 100644
--- a/tag-util.c
+++ b/tag-util.c
@@ -151,11 +151,9 @@ parse_tag_line (void *ctx, char *line,
 return ret;
 }
 
-tag_parse_status_t
-parse_tag_command_line (void *ctx, int argc, char **argv,
-   char **query_str, tag_op_list_t *tag_ops)
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *tag_ops)
 {
-
 int i;
 
 for (i = 0; i  argc; i++) {
@@ -173,12 +171,24 @@ parse_tag_command_line (void *ctx, int argc, char **argv,
msg = illegal_tag (argv[i] + 1, is_remove);
if (msg) {
fprintf (stderr, Error: %s\n, msg);
-   return TAG_PARSE_INVALID;
+   return -1;
}
 
tag_op_list_append (tag_ops, argv[i] + 1, is_remove);
 }
 
+return i;
+}
+
+tag_parse_status_t
+parse_tag_command_line (void *ctx, int argc, char **argv,
+   char **query_str, tag_op_list_t *tag_ops)
+{
+int i = process_tag_command_line (argc, argv, tag_ops);
+
+if (i  0)
+   return TAG_PARSE_INVALID;
+
 *query_str = query_string_from_args (ctx, argc - i, argv[i]);
 
 if (*query_str == NULL) {
diff --git a/tag-util.h b/tag-util.h
index 512cfac..f757e6b 100644
--- a/tag-util.h
+++ b/tag-util.h
@@ -78,6 +78,21 @@ parse_tag_line (void *ctx, char *line,
 
 
 
+/* Process a command line of the following format:
+ *
+ * +tag|-tag [...] [--]
+ *
+ * Return the number of tags operations, or -1 for failure to parse.
+ *
+ * Output Parameters:
+ * ops contains a list of tag operations
+ *
+ * The ops argument is not cleared.
+ */
+
+int
+process_tag_command_line (int argc, char **argv, tag_op_list_t *ops);
+
 /* Parse a command line of the following format:
  *
  * +tag|-tag [...] [--] search-terms
-- 
1.9.2

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


[PATCH 5/5] Test: Add tests for notmuch new command line tags

2014-05-02 Thread David Edmondson
Add a simple set of tests for adding, removing and both adding and
removing tags when running notmuch new.
---
 test/T540-new-tags.sh | 28 
 1 file changed, 28 insertions(+)
 create mode 100755 test/T540-new-tags.sh

diff --git a/test/T540-new-tags.sh b/test/T540-new-tags.sh
new file mode 100755
index 000..58e6c18
--- /dev/null
+++ b/test/T540-new-tags.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+test_description='notmuch new' with tags
+. ./test-lib.sh
+
+which notmuch
+
+test_begin_subtest Add tags during new
+generate_message
+notmuch new +happyfunball +flyfishing
+output=$(notmuch search id:${gen_msg_id})
+expected='thread:0001   2001-01-05 [1/1] Notmuch Test Suite; Add 
tags during new (flyfishing happyfunball inbox unread)'
+test_expect_equal $output $expected
+
+test_begin_subtest Remove tags during new
+generate_message
+notmuch new -inbox
+output=$(notmuch search id:${gen_msg_id})
+expected='thread:0002   2001-01-05 [1/1] Notmuch Test Suite; 
Remove tags during new (unread)'
+test_expect_equal $output $expected
+
+test_begin_subtest Add and remove tags during new
+generate_message
+notmuch new +happyfunball -inbox
+output=$(notmuch search id:${gen_msg_id})
+expected='thread:0003   2001-01-05 [1/1] Notmuch Test Suite; Add 
and remove tags during new (happyfunball unread)'
+test_expect_equal $output $expected
+
+test_done
-- 
1.9.2

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


[PATCH 4/5] NEWS: Add information about notmuch new command line tags.

2014-05-02 Thread David Edmondson
---
 NEWS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index bcd311d..13ae593 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,12 @@ Command-Line Interface
 
   This option suppresses the progress and summary reports.
 
+`notmuch new` allows tag addition/removal to be specified
+
+  An additional set of tags to be added or removed to messages
+  discovered by `notmuch new` can be specified. These are in addition
+  to the existing configured tags.
+
 Emacs Interface
 ---
 
-- 
1.9.2

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


Re: [PATCH v2 0/5] Add support for specifying tags during notmuch new

2014-05-02 Thread Mark Walters

Version 2 passes all tests and LGTM. +1

Best wishes

Mark

On Fri, 02 May 2014, David Edmondson d...@dme.org wrote:
 v1:

 This patch set allows a user to specify a list of tags to be
 added/removed to messages discovered during notmuch new.

 Two use-cases are envisaged:
 1) A chunk of messages was just dumped into the configured
directory by hand, and the user doesn't want the 'inbox' tag
applied to them. Run 'notmuch new -inbox'.
 2) A periodic mail processing script wants to add new messages to
the database, then process those newly added messages to add
convenience tags, etc. without worrying about the user or other
instances of the script manipulating tags at the same time. Use
this approach:
  KEY=$RANDOM
notmuch new +$KEY
notmuch tag +notmuch tag:$KEY and to:notmuch@notmuchmail.org
notmuch tag +gnus tag:$KEY and to:d...@gnus.org
...
notmuch tag -$KEY tag:$KEY

 v2: The first version synced tags to flags rather than the other way
 around. Thanks to Mark for complaining at me.
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] NEWS: folder:, path:, and database upgrade

2014-05-02 Thread Mark Walters

I don't like the wildcard bit as an important part of the change was the
removal of stemming. Perhaps keep exact in the headline and in the body
say explicitly what the changes are no stemming, no wildcards (except
globbing), etc (maybe case sensitivity is different?)

Best wishes

Mark



On Thu, 01 May 2014, David Edmondson d...@dme.org wrote:
 On Sun, Apr 27 2014, Jani Nikula wrote:
 +The `folder:` search prefix now requires an exact match

 I think that it would be clearer to say:

   The `folder:` search prefix no longer supports wildcard matching

 (Or something like that.)
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] emacs: allow functions in notmuch-show-stash-mlarchive-link-alist

2014-05-02 Thread Mark Walters

This version LGTM +1.

Best wishes

Mark

On Thu, 01 May 2014, Jani Nikula j...@nikula.org wrote:
 Some archives may use a more complicated scheme for referring to
 messages than just concatenated url and message-id. In particular,
 patchwork requires a query to translate message-id to a patchwork
 patch id. Allow functions in notmuch-show-stash-mlarchive-link-alist
 to facilitate this.

 For example, one could use something like this for patchwork.

 (lambda (message-id)
   (concat
http://patchwork.example.com/patch/;
(nth 0
   (split-string
(car (last (process-lines pwclient search -n 1
  -m (concat  message-id 
 ---
  emacs/notmuch-show.el | 40 +++-
  1 file changed, 27 insertions(+), 13 deletions(-)

 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index df10d4bad93b..10fc872141dc 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -180,10 +180,21 @@ each attachment handler is logged in buffers with names 
 beginning
  )
List of Mailing List Archives to use when stashing links.
  
 -These URIs are concatenated with the current message's
 -Message-Id in `notmuch-show-stash-mlarchive-link'.
 +This list is used for generating a Mailing List Archive reference
 +URI with the current message's Message-Id in
 +`notmuch-show-stash-mlarchive-link'.
 +
 +If the cdr of the alist element is not a function, the cdr is
 +expected to contain a URI that is concatenated with the current
 +message's Message-Id to create a ML archive reference URI.
 +
 +If the cdr is a function, the function is called with the
 +Message-Id as the argument, and the function is expected to
 +return the ML archive reference URI.
:type '(alist :key-type (string :tag Name)
 - :value-type (string :tag URL))
 + :value-type (choice
 +  (string :tag URL)
 +  (function :tag Function returning the URL)))
:group 'notmuch-show)
  
  (defcustom notmuch-show-stash-mlarchive-link-default Gmane
 @@ -2055,16 +2066,19 @@ This presumes that the message is available at the 
 selected Mailing List Archive
  If optional argument MLA is non-nil, use the provided key instead of 
 prompting
  the user (see `notmuch-show-stash-mlarchive-link-alist').
(interactive)
 -  (notmuch-common-do-stash
 -   (concat (cdr (assoc
 -  (or mla
 -  (let ((completion-ignore-case t))
 -(completing-read
 - Mailing List Archive: 
 - notmuch-show-stash-mlarchive-link-alist
 - nil t nil nil 
 notmuch-show-stash-mlarchive-link-default)))
 -  notmuch-show-stash-mlarchive-link-alist))
 -(notmuch-show-get-message-id t
 +  (let ((url (cdr (assoc
 +(or mla
 +(let ((completion-ignore-case t))
 +  (completing-read
 +   Mailing List Archive: 
 +   notmuch-show-stash-mlarchive-link-alist
 +   nil t nil nil
 +   notmuch-show-stash-mlarchive-link-default)))
 +notmuch-show-stash-mlarchive-link-alist
 +(notmuch-common-do-stash
 + (if (functionp url)
 +  (funcall url (notmuch-show-get-message-id t))
 +   (concat url (notmuch-show-get-message-id t))
  
  (defun notmuch-show-stash-mlarchive-link-and-go (optional mla)
Copy an ML Archive URI for the current message to the kill-ring and visit 
 it.
 -- 
 1.9.2
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] doc: add *.pyc to doc/.gitignore

2014-05-02 Thread Jani Nikula
---
 doc/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/.gitignore b/doc/.gitignore
index a60fb31e9419..f0cbb9c27b24 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1,2 +1,3 @@
+*.pyc
 docdeps.mk
 _build
-- 
1.9.2

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


[PATCH 1/2] test: add have-man and have-compact in test/.gitignore

2014-05-02 Thread Jani Nikula
Sort the file while at it.
---
 test/.gitignore | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/test/.gitignore b/test/.gitignore
index 97e024878728..4081cee6da18 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,9 +1,11 @@
-test-results
-corpus.mail
-smtp-dummy
-symbol-test
 arg-test
+corpus.mail
+have-compact
+have-man
 hex-xcode
-random-corpus
 parse-time
+random-corpus
+smtp-dummy
+symbol-test
+test-results
 tmp.*
-- 
1.9.2

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


Re: Add support for specifying tags during notmuch new

2014-05-02 Thread Austin Clements
Quoth David Edmondson on May 02 at  9:15 am:
 This patch set allows a user to specify a list of tags to be
 added/removed to messages discovered during notmuch new.
 
 Two use-cases are envisaged:
 1) A chunk of messages was just dumped into the configured
directory by hand, and the user doesn't want the 'inbox' tag
applied to them. Run 'notmuch new -inbox'.
 2) A periodic mail processing script wants to add new messages to
the database, then process those newly added messages to add
convenience tags, etc. without worrying about the user or other
instances of the script manipulating tags at the same time. Use
this approach:
  KEY=$RANDOM
notmuch new +$KEY
notmuch tag +notmuch tag:$KEY and to:notmuch@notmuchmail.org
notmuch tag +gnus tag:$KEY and to:d...@gnus.org
...
notmuch tag -$KEY tag:$KEY

What happens when this script dies in the middle (say, your computer
loses power or notmuch tag conflicts with something else on the write
lock)?  One advantage of the standard new tag approach is that it's
easy to write a stateless post-new tagging script that can be killed
at any point and restarted.  (You're right that post-new has a
concurrency issue, but we should fix that in its own right.)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] NEWS: make it explicit that wildcard matching is no longer supported

2014-05-02 Thread Jani Nikula
Wildcard matching was a feature of the probabilistic prefix, and we no
longer have it for the boolean prefix. Also note that top-level folder
can now be searched.
---
 NEWS | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index 75dba6f963b0..f10c280be328 100644
--- a/NEWS
+++ b/NEWS
@@ -21,12 +21,13 @@ General
 The `folder:` search prefix now requires an exact match
 
   The `folder:` prefix has been changed to search for email messages
-  by the exact, case sensitive maildir or MH folder name. The new
-  behaviour allows for more accurate mail folder based searches, and
-  should lead to less surprising results than the old behaviour. Users
-  are advised to see the `notmuch-search-terms` manual page for
-  details, and review how the change affects their existing `folder:`
-  searches.
+  by the exact, case sensitive maildir or MH folder name. Wildcard
+  matching (`folder:foo*`) is no longer supported. The new behaviour
+  allows for more accurate mail folder based searches, makes it
+  possible to search for messages in the top-level folder, and should
+  lead to less surprising results than the old behaviour. Users are
+  advised to see the `notmuch-search-terms` manual page for details,
+  and review how the change affects their existing `folder:` searches.
 
 There is a new `path:` search prefix.
 
-- 
1.9.2

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


Re: [PATCH] NEWS: make it explicit that wildcard matching is no longer supported

2014-05-02 Thread David Edmondson
Good for me, thank you.


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


folder and path completely broken in HEAD?

2014-05-02 Thread dm-list-email-notmuch
Hey, I'm playing around with the head of the git repository
(bc64cdce289d84be2550c4fccb1f008d15eaeb0e) to try to figure out how the
new folder: prefixes work, as folders are a critical part of how I
organize my mail.  (Since tags are not hierarchical, folders are the
best way for me to group mail to a bunch of related addresses, while
retaining the ability to separate out any mailboxes that become high
traffic.)

I'm using a pretty standard maildir++ layout.  For example, underneath
my database.path I have a bunch of mail in directories such as:

.INBOX.Main/{new,cur}
.mail.class/{new,cur}
.mail.voicemail/{new,cur}

It used to be the case that if I wanted to read all of my mail mail, I
could search for folder:mail, while to look at just voicemail, I could
say folder:mail.voicemail, etc.  Now, I can't get anything to match a
folder predicate period.  For example, using notmuch as notmuch-0.17 and
./notmuch as notmuch-0.18-rc2+2~gbc64cdc, here's what I get:

linux2$ notmuch count folder:mail
16257
linux3$ notmuch count folder:mail.class
1896
linux4$ notmuch count folder:mail.voicemail
34
linux5$ notmuch count folder:mail.voicemail/cur
34
linux6$ notmuch count folder:.mail.voicemail/cur
34
linux7$ ./notmuch count folder:mail
0
linux8$ ./notmuch count folder:.mail
0
linux9$ ./notmuch count folder:.mail.voicemail
0
linux10$ ./notmuch count folder:.mail.voicemail/cur
0
linux 11$ ./notmuch count path:.mail.voicemail
0
linux 12$ ./notmuch count path:.mail.voicemail/'**'
0
linux 13$ ./notmuch count path:.mail.voicemail/cur 
0
linux 14$ ./notmuch count folder:mail.voicemail
0

What gives?  Are the path and folder predicates completely broken, or is
something very important missing from the new notmuch-search-terms
manual page?  How can I make this work?

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


Re: [PATCH 1/2] test: add have-man and have-compact in test/.gitignore

2014-05-02 Thread David Bremner
Jani Nikula j...@nikula.org writes:

 Sort the file while at it.

pushed to master.

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


Re: folder and path completely broken in HEAD?

2014-05-02 Thread Jani Nikula
On Fri, 02 May 2014, dm-list-email-notm...@scs.stanford.edu wrote:
 Hey, I'm playing around with the head of the git repository
 (bc64cdce289d84be2550c4fccb1f008d15eaeb0e) to try to figure out how the
 new folder: prefixes work, as folders are a critical part of how I
 organize my mail.  (Since tags are not hierarchical, folders are the
 best way for me to group mail to a bunch of related addresses, while
 retaining the ability to separate out any mailboxes that become high
 traffic.)

 I'm using a pretty standard maildir++ layout.  For example, underneath
 my database.path I have a bunch of mail in directories such as:

 .INBOX.Main/{new,cur}
 .mail.class/{new,cur}
 .mail.voicemail/{new,cur}

 It used to be the case that if I wanted to read all of my mail mail, I
 could search for folder:mail, while to look at just voicemail, I could
 say folder:mail.voicemail, etc.  Now, I can't get anything to match a
 folder predicate period.  For example, using notmuch as notmuch-0.17 and
 ./notmuch as notmuch-0.18-rc2+2~gbc64cdc, here's what I get:

First, read Mark's reply about database upgrade, and heed the notice
about upgrade being automatic but downgrade requiring a reindex of all
your mails.

Here's additional commentary on the specific queries.

 linux7$ ./notmuch count folder:mail
 0
 linux8$ ./notmuch count folder:.mail
 0

These two will not match anything.

 linux9$ ./notmuch count folder:.mail.voicemail
 0

After the upgrade, this should work for .mail.voicemail/{new,cur}.

 linux10$ ./notmuch count folder:.mail.voicemail/cur
 0

This won't match anything. To specifically search for messages in cur,
you can use the new path prefix, path:.mail.voicemail/cur

 linux 11$ ./notmuch count path:.mail.voicemail
 0

This will match messages in .mail.voicemail only, and nothing in the cur
or new subdirectories.

 linux 12$ ./notmuch count path:.mail.voicemail/'**'
 0

I'm not sure your quoting will work, but if you don't have any other
subfolders than cur and new, this should be equal to
folder:.mail.voicemail

 linux 13$ ./notmuch count path:.mail.voicemail/cur 
 0

This should match messages in the cur subdirectory.

 linux 14$ ./notmuch count folder:mail.voicemail
 0

This won't match anything.


BR,
Jani.

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


Re: folder and path completely broken in HEAD?

2014-05-02 Thread David Mazieres expires 2014-07-31 PDT
Mark Walters markwalters1...@gmail.com writes:

 Hi

 Before checking other things: have you run notmuch new? That's needed to
 update the database. It is an irreversible update so notmuch-0.17 will
 not work with the updated database.

No, I haven't.  Okay, so that must be it.  Sorry for bothering people.
The discussion of the NEWS was a bit confusing, so I wanted to check it
out.  I knew something had to be very wrong.

Weill the new primitives still allow me to group my mail hierarchically
in searches?  The new man page is not totally clear on what is being
matched.

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


Re: folder and path completely broken in HEAD?

2014-05-02 Thread dm-list-email-notmuch
Jani Nikula j...@nikula.org writes:

 On Fri, 02 May 2014, dm-list-email-notm...@scs.stanford.edu wrote:

 I'm using a pretty standard maildir++ layout.  For example, underneath
 my database.path I have a bunch of mail in directories such as:

 .INBOX.Main/{new,cur}
 .mail.class/{new,cur}
 .mail.voicemail/{new,cur}
 ...
 Here's additional commentary on the specific queries.

 linux7$ ./notmuch count folder:mail
 0
 linux8$ ./notmuch count folder:.mail
 0

Oh, man.  That's a serious bummer.

Is there any mechanism left that would let me hierarchically group
messages?  I've got a ton of mail.* folders, and create new ones
dynamically.  I really want a mechanism to group them hierarchically, so
I can have a search that matches all current and future mail
directories.  I organized my whole mail setup around folders because a)
tags do not provide this kind of hierarchical control, and b) there
doesn't seem to be a convenient way to apply tags 100% reliably on
message delivery, whereas I *can* control the folder 100% reliably.

Worse, because of my poor performance, I was hoping to segregate
messages by year.  So it would be:

  2013/.mail.class
  2013/.mail.voicemail
  2014/.mail.class
  2014/.mail.voicemail

All the way back.  Now you are saying there will be no convenient way to
match just the mail.class part without the year?  How very
distressing.  Ugh.

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


Re: folder and path completely broken in HEAD?

2014-05-02 Thread Suvayu Ali
Hello David,

On Fri, May 02, 2014 at 02:16:07PM -0700, David Mazieres expires 2014-07-31 PDT 
wrote:
 Mark Walters markwalters1...@gmail.com writes:
 
  Before checking other things: have you run notmuch new? That's needed to
  update the database. It is an irreversible update so notmuch-0.17 will
  not work with the updated database.
 
 No, I haven't.  Okay, so that must be it.  Sorry for bothering people.
 The discussion of the NEWS was a bit confusing, so I wanted to check it
 out.  I knew something had to be very wrong.
 
 Weill the new primitives still allow me to group my mail hierarchically
 in searches?  The new man page is not totally clear on what is being
 matched.

Here are some examples:

  $ notmuch config get database.path
  /home/user/Mail
  $ notmuch count -- folder:Gmail/Tux
  5113
  $ notmuch count -- 'path:Gmail/**'
  87807

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: folder and path completely broken in HEAD?

2014-05-02 Thread Suvayu Ali
On Fri, May 02, 2014 at 09:57:49PM -0700, 
dm-list-email-notm...@scs.stanford.edu wrote:
 
 Worse, because of my poor performance, I was hoping to segregate
 messages by year.  So it would be:
 
   2013/.mail.class
   2013/.mail.voicemail
   2014/.mail.class
   2014/.mail.voicemail
 
 All the way back.  Now you are saying there will be no convenient way to
 match just the mail.class part without the year?  How very
 distressing.  Ugh.

If you are using shell commands, you can always use:

  $ notmuch count -- folder:201{3,4}/.mail.class

Not sure how to achieve the same from the Emacs UI (or other UIs).

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch