[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-07 Thread Jameson Graef Rollins
The new customization variable, notmuch-search-exclude-deleted, when
set to t, will exclude any messages with the "deleted" tag from
searches.

Additionally, specifying "tag:deleted" in the search directly will
override the exclusion and will included deleted messages in the
search results.
---
 emacs/notmuch.el   |8 
 test/emacs |   42 
 .../notmuch-search-tag-inbox-deleted-excluded  |   24 +++
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 
test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..c519687 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -905,6 +905,11 @@ PROMPT is the string to prompt with."
   (read-from-minibuffer prompt nil keymap nil
'notmuch-query-history nil nil
 
+(defcustom notmuch-search-exclude-deleted nil
+  "Exclude deleted messages (with \"deleted\" tag) from search results."
+  :group 'notmuch
+  :type 'boolean)
+
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line 
continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -927,6 +932,9 @@ The optional parameters are used as follows:
 (set 'notmuch-search-target-thread target-thread)
 (set 'notmuch-search-target-line target-line)
 (set 'notmuch-search-continuation continuation)
+(when (and notmuch-search-exclude-deleted
+  (not (string-match "tag:deleted[ )]*" query)))
+  (setq query (concat query " and not tag:deleted")))
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
diff --git a/test/emacs b/test/emacs
index a06c223..1d78fbe 100755
--- a/test/emacs
+++ b/test/emacs
@@ -35,6 +35,48 @@ test_emacs '(notmuch-search "tag:inbox")
(test-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
 
+test_begin_subtest "Exclude \"deleted\" messages from search"
+notmuch tag +deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+# we "delete" a second message that's part of a multi-message thread
+# to make sure the rest of the thread is still returned
+notmuch tag +deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search "tag:inbox")
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+notmuch tag -deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-search-tag-inbox-deleted-excluded
+
+test_begin_subtest "Exclude \"deleted\" messages from search, manual override"
+notmuch tag +deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+notmuch tag +deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+cat 

[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-07 Thread Jameson Graef Rollins
The new customization variable, notmuch-search-exclude-deleted, when
set to t, will exclude any messages with the "deleted" tag from
searches.

Additionally, specifying "tag:deleted" in the search directly will
override the exclusion and will included deleted messages in the
search results.
---
 emacs/notmuch.el   |8 
 test/emacs |   42 
 .../notmuch-search-tag-inbox-deleted-excluded  |   24 +++
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 
test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..c519687 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -905,6 +905,11 @@ PROMPT is the string to prompt with."
   (read-from-minibuffer prompt nil keymap nil
'notmuch-query-history nil nil

+(defcustom notmuch-search-exclude-deleted nil
+  "Exclude deleted messages (with \"deleted\" tag) from search results."
+  :group 'notmuch
+  :type 'boolean)
+
 ;;;###autoload
 (defun notmuch-search (query &optional oldest-first target-thread target-line 
continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -927,6 +932,9 @@ The optional parameters are used as follows:
 (set 'notmuch-search-target-thread target-thread)
 (set 'notmuch-search-target-line target-line)
 (set 'notmuch-search-continuation continuation)
+(when (and notmuch-search-exclude-deleted
+  (not (string-match "tag:deleted[ )]*" query)))
+  (setq query (concat query " and not tag:deleted")))
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
diff --git a/test/emacs b/test/emacs
index a06c223..1d78fbe 100755
--- a/test/emacs
+++ b/test/emacs
@@ -35,6 +35,48 @@ test_emacs '(notmuch-search "tag:inbox")
(test-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox

+test_begin_subtest "Exclude \"deleted\" messages from search"
+notmuch tag +deleted id:1258506353-20352-1-git-send-email-stewart at 
flamingspork.com
+# we "delete" a second message that's part of a multi-message thread
+# to make sure the rest of the thread is still returned
+notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag at 
dottedmag.net
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search "tag:inbox")
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted id:1258506353-20352-1-git-send-email-stewart at 
flamingspork.com
+notmuch tag -deleted id:1258471718-6781-1-git-send-email-dottedmag at 
dottedmag.net
+test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-search-tag-inbox-deleted-excluded
+
+test_begin_subtest "Exclude \"deleted\" messages from search, manual override"
+notmuch tag +deleted id:1258506353-20352-1-git-send-email-stewart at 
flamingspork.com
+notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag at 
dottedmag.net
+cat 

[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Aaron Ecay
Jameson,

One comment

On Sat,  7 Jan 2012 14:28:11 -0800, Jameson Graef Rollins  wrote:
> The new customization variable, notmuch-search-exclude-deleted, when
> set to t, will exclude any messages with the "deleted" tag from
> searches.
> 
> Additionally, specifying "tag:deleted" in the search directly will
> override the exclusion and will included deleted messages in the
> search results.
> ---
>  emacs/notmuch.el   |8 
>  test/emacs |   42 
> 
>  .../notmuch-search-tag-inbox-deleted-excluded  |   24 +++
>  3 files changed, 74 insertions(+), 0 deletions(-)
>  create mode 100644 
> test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index fde2377..c519687 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -905,6 +905,11 @@ PROMPT is the string to prompt with."
>(read-from-minibuffer prompt nil keymap nil
>   'notmuch-query-history nil nil
>  
> +(defcustom notmuch-search-exclude-deleted nil
> +  "Exclude deleted messages (with \"deleted\" tag) from search results."
> +  :group 'notmuch
> +  :type 'boolean)
> +
>  ;;;###autoload
>  (defun notmuch-search (query &optional oldest-first target-thread 
> target-line continuation)
>"Run \"notmuch search\" with the given query string and display results.
> @@ -927,6 +932,9 @@ The optional parameters are used as follows:
>  (set 'notmuch-search-target-thread target-thread)
>  (set 'notmuch-search-target-line target-line)
>  (set 'notmuch-search-continuation continuation)
> +(when (and notmuch-search-exclude-deleted
> +(not (string-match "tag:deleted[ )]*" query)))

?is:? is a synonym for ?tag:? in searches ? so this section of the code
should look for it too.

-- 
Aaron Ecay


[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Austin Clements
> > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> >  (set 'notmuch-search-target-thread target-thread)
> >  (set 'notmuch-search-target-line target-line)
> >  (set 'notmuch-search-continuation continuation)
> > +(when (and notmuch-search-exclude-deleted
> > +  (not (string-match "tag:deleted[ )]*" query)))
> 
> ?is:? is a synonym for ?tag:? in searches ? so this section of the code
> should look for it too.

There are several other things that could also trip up this regexp.
xtag:deletedx would be falsely matched, as would a quoted phrase
containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
incorrectly not be matched.  Getting this right is hard, though I'd be
happy with

  "\\<\\(tag\\|is\\):deleted\\>"

or maybe

  "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"

Implicit exclusions like this were actually one of my target features
for the custom query parser, but I think hacking around that by
inspecting the query string is a fine interim solution.  (One of these
months I'll dust off the query parser, really!)


[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Jameson Graef Rollins
On Sun, 8 Jan 2012 20:49:38 -0500, Austin Clements  wrote:
> > > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> > >  (set 'notmuch-search-target-thread target-thread)
> > >  (set 'notmuch-search-target-line target-line)
> > >  (set 'notmuch-search-continuation continuation)
> > > +(when (and notmuch-search-exclude-deleted
> > > +(not (string-match "tag:deleted[ )]*" query)))
> > 
> > ?is:? is a synonym for ?tag:? in searches ? so this section of the code
> > should look for it too.
> 
> There are several other things that could also trip up this regexp.
> xtag:deletedx would be falsely matched, as would a quoted phrase
> containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
> incorrectly not be matched.

Thanks so much for the review, guys.  I should have mentioned in this
patch that the my regex skills are very weak, and that it was surely
incomplete.  I always forget about the is: prefix as well.

> Getting this right is hard, though I'd be happy with
> 
>   "\\<\\(tag\\|is\\):deleted\\>"

Every time I think I start to understand regex I am reminded that it's
black magic and I really know nothing.  For instance, I am not familiar
with "<" or ">", although they appear to be a "word" boundaries
(although I'm not sure how "word" is defined).  Also, why is all the \\
(double?)  escaping needed?  I'll certainly take your word for it,
though.

> or maybe
> 
>   "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"

After staring at this for 10 minutes I think I'm getting the extra bits
here.  It matches an initial \", and then a second at the end if the
first matched.  That's clever.  Why 

  \\>\\2

instead of

 \\2\\>

?

I'm definitely confused by why so much apparent escaping is needed,
though.

> Implicit exclusions like this were actually one of my target features
> for the custom query parser, but I think hacking around that by
> inspecting the query string is a fine interim solution.  (One of these
> months I'll dust off the query parser, really!)

Very much looking forward to it!

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Austin Clements
Quoth Jameson Graef Rollins on Jan 08 at  6:34 pm:
> On Sun, 8 Jan 2012 20:49:38 -0500, Austin Clements  
> wrote:
> > > > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> > > >  (set 'notmuch-search-target-thread target-thread)
> > > >  (set 'notmuch-search-target-line target-line)
> > > >  (set 'notmuch-search-continuation continuation)
> > > > +(when (and notmuch-search-exclude-deleted
> > > > +  (not (string-match "tag:deleted[ )]*" query)))
> > > 
> > > ?is:? is a synonym for ?tag:? in searches ? so this section of the code
> > > should look for it too.
> > 
> > There are several other things that could also trip up this regexp.
> > xtag:deletedx would be falsely matched, as would a quoted phrase
> > containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
> > incorrectly not be matched.
> 
> Thanks so much for the review, guys.  I should have mentioned in this
> patch that the my regex skills are very weak, and that it was surely
> incomplete.  I always forget about the is: prefix as well.
> 
> > Getting this right is hard, though I'd be happy with
> > 
> >   "\\<\\(tag\\|is\\):deleted\\>"
> 
> Every time I think I start to understand regex I am reminded that it's
> black magic and I really know nothing.  For instance, I am not familiar
> with "<" or ">", although they appear to be a "word" boundaries
> (although I'm not sure how "word" is defined).  Also, why is all the \\
> (double?)  escaping needed?  I'll certainly take your word for it,
> though.

I'm not positive, but I think \> matches on the transition from a
"word-constituent" character to a non-word-constituent character, as
defined by Emacs' active syntax table.

The slashes are all doubled because I was writing it as an Emacs
string for easy pasting (sorry, I should have been explicit about
that).  The regexp itself is

  \<\(tag\|is\):deleted\>

> > or maybe
> > 
> >   "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"
> 
> After staring at this for 10 minutes I think I'm getting the extra bits
> here.  It matches an initial \", and then a second at the end if the
> first matched.  That's clever.  Why 

Exactly.

>   \\>\\2
> 
> instead of
> 
>  \\2\\>
> 
> ?

Okay, that can qualify as black magic.  The problem is that a " will
mess up the word-boundary matching because " isn't a word constituent
character.  So, if it is looking for a quote at the end, the \2 in
\2\> would match and consume the ", but then the \> wouldn't match.


[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Austin Clements
Quoth myself on Jan 08 at  8:49 pm:
> > > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> > >  (set 'notmuch-search-target-thread target-thread)
> > >  (set 'notmuch-search-target-line target-line)
> > >  (set 'notmuch-search-continuation continuation)
> > > +(when (and notmuch-search-exclude-deleted
> > > +(not (string-match "tag:deleted[ )]*" query)))
> > 
> > ?is:? is a synonym for ?tag:? in searches ? so this section of the code
> > should look for it too.
> 
> There are several other things that could also trip up this regexp.
> xtag:deletedx would be falsely matched, as would a quoted phrase
> containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
> incorrectly not be matched.  Getting this right is hard, though I'd be
> happy with
> 
>   "\\<\\(tag\\|is\\):deleted\\>"
> 
> or maybe
> 
>   "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"

For the record, here's a More Correct (TM) version

  "\\(^\\|[-+ ()]\\)\\(tag\\|is\\):\\(\"?\\)deleted\\3\\($\\|[ ()]\\)"

However, as we discussed on IRC, it's probably better to fix this in
the CLI/library by adding a config option for auto-excluded tags, an
API to register these with the library (probably part of the query
API), and to iterate over the terms in the parsed query to determine
which tag exclusions should be automatically added.


Re: [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Aaron Ecay
Jameson,

One comment

On Sat,  7 Jan 2012 14:28:11 -0800, Jameson Graef Rollins 
 wrote:
> The new customization variable, notmuch-search-exclude-deleted, when
> set to t, will exclude any messages with the "deleted" tag from
> searches.
> 
> Additionally, specifying "tag:deleted" in the search directly will
> override the exclusion and will included deleted messages in the
> search results.
> ---
>  emacs/notmuch.el   |8 
>  test/emacs |   42 
> 
>  .../notmuch-search-tag-inbox-deleted-excluded  |   24 +++
>  3 files changed, 74 insertions(+), 0 deletions(-)
>  create mode 100644 
> test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index fde2377..c519687 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -905,6 +905,11 @@ PROMPT is the string to prompt with."
>(read-from-minibuffer prompt nil keymap nil
>   'notmuch-query-history nil nil
>  
> +(defcustom notmuch-search-exclude-deleted nil
> +  "Exclude deleted messages (with \"deleted\" tag) from search results."
> +  :group 'notmuch
> +  :type 'boolean)
> +
>  ;;;###autoload
>  (defun notmuch-search (query &optional oldest-first target-thread 
> target-line continuation)
>"Run \"notmuch search\" with the given query string and display results.
> @@ -927,6 +932,9 @@ The optional parameters are used as follows:
>  (set 'notmuch-search-target-thread target-thread)
>  (set 'notmuch-search-target-line target-line)
>  (set 'notmuch-search-continuation continuation)
> +(when (and notmuch-search-exclude-deleted
> +(not (string-match "tag:deleted[ )]*" query)))

“is:” is a synonym for “tag:” in searches – so this section of the code
should look for it too.

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


Re: [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Austin Clements
> > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> >  (set 'notmuch-search-target-thread target-thread)
> >  (set 'notmuch-search-target-line target-line)
> >  (set 'notmuch-search-continuation continuation)
> > +(when (and notmuch-search-exclude-deleted
> > +  (not (string-match "tag:deleted[ )]*" query)))
> 
> “is:” is a synonym for “tag:” in searches – so this section of the code
> should look for it too.

There are several other things that could also trip up this regexp.
xtag:deletedx would be falsely matched, as would a quoted phrase
containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
incorrectly not be matched.  Getting this right is hard, though I'd be
happy with

  "\\<\\(tag\\|is\\):deleted\\>"

or maybe

  "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"

Implicit exclusions like this were actually one of my target features
for the custom query parser, but I think hacking around that by
inspecting the query string is a fine interim solution.  (One of these
months I'll dust off the query parser, really!)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Jameson Graef Rollins
On Sun, 8 Jan 2012 20:49:38 -0500, Austin Clements  wrote:
> > > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> > >  (set 'notmuch-search-target-thread target-thread)
> > >  (set 'notmuch-search-target-line target-line)
> > >  (set 'notmuch-search-continuation continuation)
> > > +(when (and notmuch-search-exclude-deleted
> > > +(not (string-match "tag:deleted[ )]*" query)))
> > 
> > “is:” is a synonym for “tag:” in searches – so this section of the code
> > should look for it too.
> 
> There are several other things that could also trip up this regexp.
> xtag:deletedx would be falsely matched, as would a quoted phrase
> containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
> incorrectly not be matched.

Thanks so much for the review, guys.  I should have mentioned in this
patch that the my regex skills are very weak, and that it was surely
incomplete.  I always forget about the is: prefix as well.

> Getting this right is hard, though I'd be happy with
> 
>   "\\<\\(tag\\|is\\):deleted\\>"

Every time I think I start to understand regex I am reminded that it's
black magic and I really know nothing.  For instance, I am not familiar
with "<" or ">", although they appear to be a "word" boundaries
(although I'm not sure how "word" is defined).  Also, why is all the \\
(double?)  escaping needed?  I'll certainly take your word for it,
though.

> or maybe
> 
>   "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"

After staring at this for 10 minutes I think I'm getting the extra bits
here.  It matches an initial \", and then a second at the end if the
first matched.  That's clever.  Why 

  \\>\\2

instead of

 \\2\\>

?

I'm definitely confused by why so much apparent escaping is needed,
though.

> Implicit exclusions like this were actually one of my target features
> for the custom query parser, but I think hacking around that by
> inspecting the query string is a fine interim solution.  (One of these
> months I'll dust off the query parser, really!)

Very much looking forward to it!

jamie.


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


Re: [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Austin Clements
Quoth Jameson Graef Rollins on Jan 08 at  6:34 pm:
> On Sun, 8 Jan 2012 20:49:38 -0500, Austin Clements  wrote:
> > > > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> > > >  (set 'notmuch-search-target-thread target-thread)
> > > >  (set 'notmuch-search-target-line target-line)
> > > >  (set 'notmuch-search-continuation continuation)
> > > > +(when (and notmuch-search-exclude-deleted
> > > > +  (not (string-match "tag:deleted[ )]*" query)))
> > > 
> > > “is:” is a synonym for “tag:” in searches – so this section of the code
> > > should look for it too.
> > 
> > There are several other things that could also trip up this regexp.
> > xtag:deletedx would be falsely matched, as would a quoted phrase
> > containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
> > incorrectly not be matched.
> 
> Thanks so much for the review, guys.  I should have mentioned in this
> patch that the my regex skills are very weak, and that it was surely
> incomplete.  I always forget about the is: prefix as well.
> 
> > Getting this right is hard, though I'd be happy with
> > 
> >   "\\<\\(tag\\|is\\):deleted\\>"
> 
> Every time I think I start to understand regex I am reminded that it's
> black magic and I really know nothing.  For instance, I am not familiar
> with "<" or ">", although they appear to be a "word" boundaries
> (although I'm not sure how "word" is defined).  Also, why is all the \\
> (double?)  escaping needed?  I'll certainly take your word for it,
> though.

I'm not positive, but I think \> matches on the transition from a
"word-constituent" character to a non-word-constituent character, as
defined by Emacs' active syntax table.

The slashes are all doubled because I was writing it as an Emacs
string for easy pasting (sorry, I should have been explicit about
that).  The regexp itself is

  \<\(tag\|is\):deleted\>

> > or maybe
> > 
> >   "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"
> 
> After staring at this for 10 minutes I think I'm getting the extra bits
> here.  It matches an initial \", and then a second at the end if the
> first matched.  That's clever.  Why 

Exactly.

>   \\>\\2
> 
> instead of
> 
>  \\2\\>
> 
> ?

Okay, that can qualify as black magic.  The problem is that a " will
mess up the word-boundary matching because " isn't a word constituent
character.  So, if it is looking for a quote at the end, the \2 in
\2\> would match and consume the ", but then the \> wouldn't match.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-08 Thread Austin Clements
Quoth myself on Jan 08 at  8:49 pm:
> > > @@ -927,6 +932,9 @@ The optional parameters are used as follows:
> > >  (set 'notmuch-search-target-thread target-thread)
> > >  (set 'notmuch-search-target-line target-line)
> > >  (set 'notmuch-search-continuation continuation)
> > > +(when (and notmuch-search-exclude-deleted
> > > +(not (string-match "tag:deleted[ )]*" query)))
> > 
> > “is:” is a synonym for “tag:” in searches – so this section of the code
> > should look for it too.
> 
> There are several other things that could also trip up this regexp.
> xtag:deletedx would be falsely matched, as would a quoted phrase
> containing "tag:deleted", while tag:"deleted" and tag:(deleted) would
> incorrectly not be matched.  Getting this right is hard, though I'd be
> happy with
> 
>   "\\<\\(tag\\|is\\):deleted\\>"
> 
> or maybe
> 
>   "\\<\\(tag\\|is\\):\\(\"?\\)deleted\\>\\2"

For the record, here's a More Correct (TM) version

  "\\(^\\|[-+ ()]\\)\\(tag\\|is\\):\\(\"?\\)deleted\\3\\($\\|[ ()]\\)"

However, as we discussed on IRC, it's probably better to fix this in
the CLI/library by adding a config option for auto-excluded tags, an
API to register these with the library (probably part of the query
API), and to iterate over the terms in the parsed query to determine
which tag exclusions should be automatically added.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch