"search --duplicate=2 --output=messages" is deranged

2014-11-25 Thread David Bremner
David Edmondson  writes:

> Consider:
>
> : disaster-area; notmuch search --output=files id:87hbph5yww.fsf at 
> aw.hh.sledj.net
> /home/dme/Maildir/mail/list/notmuch/xx01550
> : disaster-area; notmuch search --duplicate=2 --output=files 
> id:87hbph5yww.fsf at aw.hh.sledj.net
> : disaster-area; notmuch search --duplicate=2 --output=messages 
> id:87hbph5yww.fsf at aw.hh.sledj.net
> id:87hbph5yww.fsf at aw.hh.sledj.net
> : disaster-area; 
>
> There's only one file, but the last search which asks for results where
> there are more than one reports the message id.

For the record, this was fixed in commit 4366b9b88c63242

d 


tag:deleted messages immediately deleted ?

2014-11-25 Thread David Bremner
Olivier Berger  writes:

>
> In any case, there has been a change in the way this worked.

That's strange, but since it is currently working as we expect, the main
question is whether we should change how excludes work.

>
> For the moment, I'm using the following saved search :
> (tag:deleted or tag:spam) and tag:deleted
> which will display the deleted mails.

Right. For me it would be less confusing to write

   (tag:deleted and tag:spam) or tag:deleted

I agree that the interaction of excludes makes (either version of ) this
search look a bit strange.



[RFC][PATCH v2] emacs: Replace `notmuch-search-result-format' evaluation.

2014-11-25 Thread David Edmondson
Alternative implementation of code that interprets
`notmuch-search-result-format' to insert the results of a search.
---

Added some more documentation, as per bremner.

 emacs/notmuch.el | 300 +--
 1 file changed, 178 insertions(+), 122 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 218486a..eb79a29 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -66,23 +66,103 @@
 "Placeholder variable when notmuch-version.el[c] is not available."))

 (defcustom notmuch-search-result-format
-  `(("date" . "%12s ")
-("count" . "%-7s ")
-("authors" . "%-20s ")
-("subject" . "%s ")
-("tags" . "(%s)"))
-  "Search result formatting. Supported fields are:
-   date, count, authors, subject, tags
-For example:
-   (setq notmuch-search-result-format \(\(\"authors\" . \"%-40s\"\)
-\(\"subject\" . \"%s\"\)\)\)
-Line breaks are permitted in format strings (though this is
-currently experimental).  Note that a line break at the end of an
-\"authors\" field will get elided if the authors list is long;
-place it instead at the beginning of the following field.  To
-enter a line break when setting this variable with setq, use \\n.
-To enter a line break in customize, press \\[quoted-insert] C-j."
-  :type '(alist :key-type (string) :value-type (string))
+  '((:width -12 :date_relative) " "
+(:width -7 (:concat "[" :matched "/" :total "]")) " "
+;; This splitting will not be necessary once
+;; id:1414172643-28270-1-git-send-email-dme at dme.org is integrated.
+(:width 40 (:eval (let* ((split-authors (split-string
+(plist-get notmuch-thread :authors)
+"|" t 
split-string-default-separators))
+;; There will always be matched authors.
+(matched-authors (car split-authors))
+;; There may not be non-matched authors.
+(non-matched-authors (mapconcat #'identity (cdr 
split-authors) " ")))
+   (notmuch-search-format-authors matched-authors 
non-matched-authors " "
+:subject " "
+"(" (:eval (notmuch-tag-format-tags (plist-get notmuch-thread :tags)
+   (plist-get notmuch-thread :orig-tags)))
+")" "\n")
+
+  "Template for displaying search results.
+
+The value is a list of items to insert in the search
+results. Individual items should be in one of the following
+forms:
+
+A string that is inserted directly (e.g. \" \").
+
+A number that is inserted directly (e.g. 5).
+
+A list that is recursively evaluated (e.g. `(:concat FORM1
+ FORM2)').
+
+A function that is evaluated with a single argument, the current
+ thread.
+
+A symbol corresponding to an attribute of the
+ thread. Currently available attributes include:
+
+ :date_relative -- a user-readable rendering of the Date: header
+ of the first matching message in the thread, as a string.
+
+ :timestamp -- the number of seconds since the Epoch, 1970-01-01
+ 00:00:00 + (UTC), corresponding to the Date: header of the
+ first matching message in the thread.
+
+ :subject -- the subject of the first matching message in the
+ thread as a string.
+
+ :authors -- a comma separated string containing a list of the
+ authors of messages in the thread. If there are non-matching
+ authors (i.e. the thread contains messages which did not match
+ the search terms and those messages have authors who are not
+ also authors of messages that did match the search terms) then
+ the matching and non-matching authors are separated by a `|'
+ symbol in the results in place of a comma.
+
+ :matched -- the number of messages that matched search terms in
+ the thread (a number).
+
+ :total -- the total number of messages in the thread (i.e. the
+ count of both matching and non-matching messages).
+
+ :tags -- a list of tags associated with messages in the
+ thread. Each tag is included as a distinct string.
+
+ :orig-tags -- a list of tags that were associated with messages
+ in the thread when the search originally took place.
+
+ :query -- a list with two elements. The first element is a query
+ string that will return all of the matching messages in the
+ current thread. The second element is a query string that will
+ return all of the non-matching messages in the current thread.
+
+ :thread -- the thread id of the matching thread, as a string.
+
+ For a full list of the attributes available, see the source code
+ for notmuch itself.
+
+A directive that describes how to evaluate the remainder of the
+ list. The following directives are available:
+
+ `:concat FORM...' -- evaluate each element of FORM and return
+ the concatenated results.
+
+ `:width WIDTH FORM' -- evaluate FORM and return the result
+ truncated to WIDTH characters. The result will be padded with
+ spaces to WIDTH 

[RFC][PATCH v1] emacs: Replace `notmuch-search-result-format' evaluation.

2014-11-25 Thread David Edmondson
On Tue, Nov 25 2014, David Bremner wrote:
>> +A symbol corresponding to an attribute of the
>> + thread (e.g. `:date_relative' or `:subject').
>
> It'd be nice for the user to have a pointer here to figure out what
> the possible attributes are.

I don't believe that we currently document these anywhere. I'll add a
list in the form "this will include such attributes as ...".

Something that I didn't mention is that this implementation behaves
differently from the current one in two ways:

- The invisible authors are not available to isearch. That is, the
  current implementation hides the authors that couldn't be shown in the
  available space using invisible text that can be exposed during an
  isearch in the buffer. This isn't done with the new implementation.

- The truncation of author names is hard - they are just chopped at the
  defined width (minus space for the ellipsis). The current code tries
  to find a nice break point (between authors). That was done to better
  support the the above feature (as isearch won't match text across a
  visible/invisible boundary).

The first of these is complex to fix. The current implementation relies
on overlays, which in turn require direct access to the buffer where the
text will be rendered. The buffer isn't available to the formatting
function in the new implementation.

The second could be fixed relatively straightforwardly, but without a
fix for the invisible text, I'm not clear that it's useful (and in fact
may be harmful).


[RFC][PATCH v1] emacs: Replace `notmuch-search-result-format' evaluation.

2014-11-25 Thread David Bremner
David Edmondson  writes:

> Alternative implementation of code that interprets
> `notmuch-search-result-format' to insert the results of a search.
> ---
>
> First pass at this. Thoughts?

The general direction looks very nice.

> +A symbol corresponding to an attribute of the
> + thread (e.g. `:date_relative' or `:subject').

It'd be nice for the user to have a pointer here to figure out what the
possible attributes are.


Re: [RFC][PATCH v1] emacs: Replace `notmuch-search-result-format' evaluation.

2014-11-25 Thread David Edmondson
On Tue, Nov 25 2014, David Bremner wrote:
 +A symbol corresponding to an attribute of the
 + thread (e.g. `:date_relative' or `:subject').

 It'd be nice for the user to have a pointer here to figure out what
 the possible attributes are.

I don't believe that we currently document these anywhere. I'll add a
list in the form this will include such attributes as 

Something that I didn't mention is that this implementation behaves
differently from the current one in two ways:

- The invisible authors are not available to isearch. That is, the
  current implementation hides the authors that couldn't be shown in the
  available space using invisible text that can be exposed during an
  isearch in the buffer. This isn't done with the new implementation.

- The truncation of author names is hard - they are just chopped at the
  defined width (minus space for the ellipsis). The current code tries
  to find a nice break point (between authors). That was done to better
  support the the above feature (as isearch won't match text across a
  visible/invisible boundary).

The first of these is complex to fix. The current implementation relies
on overlays, which in turn require direct access to the buffer where the
text will be rendered. The buffer isn't available to the formatting
function in the new implementation.

The second could be fixed relatively straightforwardly, but without a
fix for the invisible text, I'm not clear that it's useful (and in fact
may be harmful).
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[RFC][PATCH v2] emacs: Replace `notmuch-search-result-format' evaluation.

2014-11-25 Thread David Edmondson
Alternative implementation of code that interprets
`notmuch-search-result-format' to insert the results of a search.
---

Added some more documentation, as per bremner.

 emacs/notmuch.el | 300 +--
 1 file changed, 178 insertions(+), 122 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 218486a..eb79a29 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -66,23 +66,103 @@
 Placeholder variable when notmuch-version.el[c] is not available.))
 
 (defcustom notmuch-search-result-format
-  `((date . %12s )
-(count . %-7s )
-(authors . %-20s )
-(subject . %s )
-(tags . (%s)))
-  Search result formatting. Supported fields are:
-   date, count, authors, subject, tags
-For example:
-   (setq notmuch-search-result-format \(\(\authors\ . \%-40s\\)
-\(\subject\ . \%s\\)\)\)
-Line breaks are permitted in format strings (though this is
-currently experimental).  Note that a line break at the end of an
-\authors\ field will get elided if the authors list is long;
-place it instead at the beginning of the following field.  To
-enter a line break when setting this variable with setq, use \\n.
-To enter a line break in customize, press \\[quoted-insert] C-j.
-  :type '(alist :key-type (string) :value-type (string))
+  '((:width -12 :date_relative)  
+(:width -7 (:concat [ :matched / :total ]))  
+;; This splitting will not be necessary once
+;; id:1414172643-28270-1-git-send-email-...@dme.org is integrated.
+(:width 40 (:eval (let* ((split-authors (split-string
+(plist-get notmuch-thread :authors)
+| t 
split-string-default-separators))
+;; There will always be matched authors.
+(matched-authors (car split-authors))
+;; There may not be non-matched authors.
+(non-matched-authors (mapconcat #'identity (cdr 
split-authors)  )))
+   (notmuch-search-format-authors matched-authors 
non-matched-authors  
+:subject  
+( (:eval (notmuch-tag-format-tags (plist-get notmuch-thread :tags)
+   (plist-get notmuch-thread :orig-tags)))
+) \n)
+
+  Template for displaying search results.
+
+The value is a list of items to insert in the search
+results. Individual items should be in one of the following
+forms:
+
+A string that is inserted directly (e.g. \ \).
+
+A number that is inserted directly (e.g. 5).
+
+A list that is recursively evaluated (e.g. `(:concat FORM1
+ FORM2)').
+
+A function that is evaluated with a single argument, the current
+ thread.
+
+A symbol corresponding to an attribute of the
+ thread. Currently available attributes include:
+
+ :date_relative -- a user-readable rendering of the Date: header
+ of the first matching message in the thread, as a string.
+
+ :timestamp -- the number of seconds since the Epoch, 1970-01-01
+ 00:00:00 + (UTC), corresponding to the Date: header of the
+ first matching message in the thread.
+
+ :subject -- the subject of the first matching message in the
+ thread as a string.
+
+ :authors -- a comma separated string containing a list of the
+ authors of messages in the thread. If there are non-matching
+ authors (i.e. the thread contains messages which did not match
+ the search terms and those messages have authors who are not
+ also authors of messages that did match the search terms) then
+ the matching and non-matching authors are separated by a `|'
+ symbol in the results in place of a comma.
+
+ :matched -- the number of messages that matched search terms in
+ the thread (a number).
+
+ :total -- the total number of messages in the thread (i.e. the
+ count of both matching and non-matching messages).
+
+ :tags -- a list of tags associated with messages in the
+ thread. Each tag is included as a distinct string.
+
+ :orig-tags -- a list of tags that were associated with messages
+ in the thread when the search originally took place.
+
+ :query -- a list with two elements. The first element is a query
+ string that will return all of the matching messages in the
+ current thread. The second element is a query string that will
+ return all of the non-matching messages in the current thread.
+
+ :thread -- the thread id of the matching thread, as a string.
+
+ For a full list of the attributes available, see the source code
+ for notmuch itself.
+
+A directive that describes how to evaluate the remainder of the
+ list. The following directives are available:
+
+ `:concat FORM...' -- evaluate each element of FORM and return
+ the concatenated results.
+
+ `:width WIDTH FORM' -- evaluate FORM and return the result
+ truncated to WIDTH characters. The result will be padded with
+ spaces to WIDTH characters, with padding at on the left if the
+ WIDTH is 

Re: tag:deleted messages immediately deleted ?

2014-11-25 Thread David Bremner
Olivier Berger olivier.ber...@telecom-sudparis.eu writes:


 In any case, there has been a change in the way this worked.

That's strange, but since it is currently working as we expect, the main
question is whether we should change how excludes work.


 For the moment, I'm using the following saved search :
 (tag:deleted or tag:spam) and tag:deleted
 which will display the deleted mails.

Right. For me it would be less confusing to write

   (tag:deleted and tag:spam) or tag:deleted

I agree that the interaction of excludes makes (either version of ) this
search look a bit strange.

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


Re: search --duplicate=2 --output=messages is deranged

2014-11-25 Thread David Bremner
David Edmondson d...@dme.org writes:

 Consider:

 : disaster-area; notmuch search --output=files 
 id:87hbph5yww@aw.hh.sledj.net
 /home/dme/Maildir/mail/list/notmuch/xx01550
 : disaster-area; notmuch search --duplicate=2 --output=files 
 id:87hbph5yww@aw.hh.sledj.net
 : disaster-area; notmuch search --duplicate=2 --output=messages 
 id:87hbph5yww@aw.hh.sledj.net
 id:87hbph5yww@aw.hh.sledj.net
 : disaster-area; 

 There's only one file, but the last search which asks for results where
 there are more than one reports the message id.

For the record, this was fixed in commit 4366b9b88c63242

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