[PATCH] don't show x-foo tags in search view

2012-11-07 Thread Austin Clements
The code looks good to me (two minor comments below), but, as David
pointed out, this needs a commit message.

Quoth James Vasile on Oct 30 at 10:57 am:
> Austin,
> 
> Thanks for the helpful comments.  I redid the patch to take a list of
> regexps.  That way users can banish different kinds of tags or simply
> list the tags themselves.  I've responded to your comments in text below
> the patch.
> 
> ---
>  emacs/notmuch.el |   26 +-
>  1 file changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index f9454d8..05aa114 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -775,6 +775,21 @@ non-authors is found, assume that all of the authors 
> match."
> (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
>(insert padding
>  
> +  

Extra blank link inserted.

> +(defcustom notmuch-search-hide-tag-regexps '()
> +  "List of regular expressionss specifying tags to hide in search view.
> +
> +Notmuch will hide any tags in search view that match the regexps
> +specified in the list `notmuch-search-hide-tag-regexp`.  The
> +match is case-insensitive.
> +
> +If you are not comfortable with regular expressions, a list of
> +tag words will work, assuming those tags use only alphanumeric
> +characters.  An empty list will disable hiding of tags in search
> +view.  The list can be set via setq or the customize interface."

The last sentence isn't necessary.  This is true of virtually every
customize variable by design.

> +  :type '(repeat  regexp)
> +  :group 'notmuch-search)
> +
>  (defun notmuch-search-insert-field (field format-string result)
>(cond
> ((string-equal field "date")
> @@ -793,7 +808,16 @@ non-authors is found, assume that all of the authors 
> match."
>  (notmuch-search-insert-authors format-string (plist-get result 
> :authors)))
>  
> ((string-equal field "tags")
> -(let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
> +(let ((tags-str
> +(mapconcat 'identity
> +   (let ((case-fold-search t))
> + (remove-if
> +  (lambda (tag)
> +(find tag notmuch-search-hide-tag-regexps
> +  :test (lambda (tag regexp)
> +  (string-match regexp tag
> +  (plist-get result :tags)))
> +   " ")))
>(insert (propertize (format format-string tags-str)
> 'face 'notmuch-tag-face))
>  




[PATCH] don't show x-foo tags in search view

2012-11-07 Thread James Vasile
David Bremner  writes:
> James Vasile  writes:
>
>> Austin,
>>
>> Thanks for the helpful comments.  I redid the patch to take a list of
>> regexps.  That way users can banish different kinds of tags or simply
>> list the tags themselves.  I've responded to your comments in text below
>> the patch.
>>
>
> I think the patch is probably OK now contentwise, but the commit message
> is what I quoted above, which is not ideal.  

New commit message:

This patch hides any tags in search view that match the regexps
specified in the list `notmuch-search-hide-tag-regexps`. The match is
case-insensitive.  An empty list (which is the default) will disable
hiding of tags in search view.  The list can be set via setq or the
customize interface.  To hide all tags that begin with "x-" or "X-", set
`notmuch-search-hide-tag-regexps` to "^X-".


>
> As far as being obsoleted by Damien's labeller patches, let's cross that
> bridge when we come to it.  Unless somebody objects, I'd be willing to
> push some version of this now.

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



[PATCH] don't show x-foo tags in search view

2012-11-07 Thread David Bremner
James Vasile  writes:

> Austin,
>
> Thanks for the helpful comments.  I redid the patch to take a list of
> regexps.  That way users can banish different kinds of tags or simply
> list the tags themselves.  I've responded to your comments in text below
> the patch.
>

I think the patch is probably OK now contentwise, but the commit message
is what I quoted above, which is not ideal.  

As far as being obsoleted by Damien's labeller patches, let's cross that
bridge when we come to it.  Unless somebody objects, I'd be willing to
push some version of this now.

d


Re: [PATCH] don't show x-foo tags in search view

2012-11-07 Thread David Bremner
James Vasile ja...@hackervisions.org writes:

 Austin,

 Thanks for the helpful comments.  I redid the patch to take a list of
 regexps.  That way users can banish different kinds of tags or simply
 list the tags themselves.  I've responded to your comments in text below
 the patch.


I think the patch is probably OK now contentwise, but the commit message
is what I quoted above, which is not ideal.  

As far as being obsoleted by Damien's labeller patches, let's cross that
bridge when we come to it.  Unless somebody objects, I'd be willing to
push some version of this now.

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


Re: [PATCH] don't show x-foo tags in search view

2012-11-07 Thread James Vasile
David Bremner da...@tethera.net writes:
 James Vasile ja...@hackervisions.org writes:

 Austin,

 Thanks for the helpful comments.  I redid the patch to take a list of
 regexps.  That way users can banish different kinds of tags or simply
 list the tags themselves.  I've responded to your comments in text below
 the patch.


 I think the patch is probably OK now contentwise, but the commit message
 is what I quoted above, which is not ideal.  

New commit message:

This patch hides any tags in search view that match the regexps
specified in the list `notmuch-search-hide-tag-regexps`. The match is
case-insensitive.  An empty list (which is the default) will disable
hiding of tags in search view.  The list can be set via setq or the
customize interface.  To hide all tags that begin with x- or X-, set
`notmuch-search-hide-tag-regexps` to ^X-.



 As far as being obsoleted by Damien's labeller patches, let's cross that
 bridge when we come to it.  Unless somebody objects, I'd be willing to
 push some version of this now.

Thanks.


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


Re: [PATCH] don't show x-foo tags in search view

2012-11-07 Thread Austin Clements
The code looks good to me (two minor comments below), but, as David
pointed out, this needs a commit message.

Quoth James Vasile on Oct 30 at 10:57 am:
 Austin,
 
 Thanks for the helpful comments.  I redid the patch to take a list of
 regexps.  That way users can banish different kinds of tags or simply
 list the tags themselves.  I've responded to your comments in text below
 the patch.
 
 ---
  emacs/notmuch.el |   26 +-
  1 file changed, 25 insertions(+), 1 deletion(-)
 
 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
 index f9454d8..05aa114 100644
 --- a/emacs/notmuch.el
 +++ b/emacs/notmuch.el
 @@ -775,6 +775,21 @@ non-authors is found, assume that all of the authors 
 match.
 (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
(insert padding
  
 +  

Extra blank link inserted.

 +(defcustom notmuch-search-hide-tag-regexps '()
 +  List of regular expressionss specifying tags to hide in search view.
 +
 +Notmuch will hide any tags in search view that match the regexps
 +specified in the list `notmuch-search-hide-tag-regexp`.  The
 +match is case-insensitive.
 +
 +If you are not comfortable with regular expressions, a list of
 +tag words will work, assuming those tags use only alphanumeric
 +characters.  An empty list will disable hiding of tags in search
 +view.  The list can be set via setq or the customize interface.

The last sentence isn't necessary.  This is true of virtually every
customize variable by design.

 +  :type '(repeat  regexp)
 +  :group 'notmuch-search)
 +
  (defun notmuch-search-insert-field (field format-string result)
(cond
 ((string-equal field date)
 @@ -793,7 +808,16 @@ non-authors is found, assume that all of the authors 
 match.
  (notmuch-search-insert-authors format-string (plist-get result 
 :authors)))
  
 ((string-equal field tags)
 -(let ((tags-str (mapconcat 'identity (plist-get result :tags)  )))
 +(let ((tags-str
 +(mapconcat 'identity
 +   (let ((case-fold-search t))
 + (remove-if
 +  (lambda (tag)
 +(find tag notmuch-search-hide-tag-regexps
 +  :test (lambda (tag regexp)
 +  (string-match regexp tag
 +  (plist-get result :tags)))
 +)))
(insert (propertize (format format-string tags-str)
 'face 'notmuch-tag-face))
  


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


[PATCH] don't show x-foo tags in search view

2012-10-30 Thread James Vasile
Damien Cassou  writes:
> On Mon, Oct 29, 2012 at 7:57 PM, James Vasile  
> wrote:
>> My filters create tags like x-bogotrained-spam that are for internal
>> bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
>> want them cluttering my 'search' view.  This patch omits x-foo and X-foo
>> tags from the 'search' view.
>
> what about using notmuch-labeler that let you hide whatever you want
> (or replace it by pictures)?
> https://github.com/DamienCassou/notmuch-labeler
>
> I'm working on integrating it inside notmuch
>

I wasn't aware of labeler.  It looks like it has some nice
functionality.  When it gets integrated into the trunk, I'll use it,
assuming it can match regexps and not just literal strings.

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



[PATCH] don't show x-foo tags in search view

2012-10-30 Thread James Vasile
Austin,

Thanks for the helpful comments.  I redid the patch to take a list of
regexps.  That way users can banish different kinds of tags or simply
list the tags themselves.  I've responded to your comments in text below
the patch.

---
 emacs/notmuch.el |   26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..05aa114 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -775,6 +775,21 @@ non-authors is found, assume that all of the authors 
match."
  (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
   (insert padding

+  
+(defcustom notmuch-search-hide-tag-regexps '()
+  "List of regular expressionss specifying tags to hide in search view.
+
+Notmuch will hide any tags in search view that match the regexps
+specified in the list `notmuch-search-hide-tag-regexp`.  The
+match is case-insensitive.
+
+If you are not comfortable with regular expressions, a list of
+tag words will work, assuming those tags use only alphanumeric
+characters.  An empty list will disable hiding of tags in search
+view.  The list can be set via setq or the customize interface."
+  :type '(repeat  regexp)
+  :group 'notmuch-search)
+
 (defun notmuch-search-insert-field (field format-string result)
   (cond
((string-equal field "date")
@@ -793,7 +808,16 @@ non-authors is found, assume that all of the authors 
match."
 (notmuch-search-insert-authors format-string (plist-get result :authors)))

((string-equal field "tags")
-(let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
+(let ((tags-str
+  (mapconcat 'identity
+ (let ((case-fold-search t))
+   (remove-if
+(lambda (tag)
+  (find tag notmuch-search-hide-tag-regexps
+:test (lambda (tag regexp)
+(string-match regexp tag
+(plist-get result :tags)))
+ " ")))
   (insert (propertize (format format-string tags-str)
  'face 'notmuch-tag-face))

-- 
1.7.10.4


Austin Clements  writes:
> I like it.

Thanks.

[snip]

> I have no idea why, but Emacs typically uses "regexp" instead of
> "regex".

It probably has something to do with rhyming with 'sexp'. ;) It's good
to conform to the vernacular, so I fixed it.

>
>> +
>> +Leave blank to disable hiding of tags in search view.
>
> Saying "Leave blank" supposes that the user knows what the default
> value is.  How about "An empty string disables hiding of tags in
> search view."?

I'm now using a list, but yes, "an empty list" is a good way to describe
it.

>
> Even better, though, would be to use nil to indicate this, since "" is
> a perfectly valid regexp and matches everything.  In that case, this
> should say something like "If nil, no tags will be hidden in search
> view."

"An empty list" is nil, so I think this is covered by my changes.  If
you think the defcustom text could be clearer, I'd appreciate edits.

>
>> +Note: elisp regexes are case-insensitive"
>
> Likewise, "regexps".  Also, Elisp regexps are not, in general,
> case-insensitive.  If we want to control this, we should bind
> case-fold-search to nil around the string-match below and say
> something here like "Matching is case-insensitive."

Good point.

>
>> +  :type 'string
>
> Better would be 'regexp.  Or, '(choice (const :tag "None" nil) regexp)
> to allow nil or a regexp.

Changed to 'regexp.

[snip]

> It would be simpler and more robust to use remove-if here.  What about
> something like
>
>   (let ((tags-str
>  (mapconcat 'identity
> (if notmuch-search-hide-tag-regex
> (let ((case-fold-search t))
>   (remove-if
>(apply-partially #'string-match
> notmuch-search-hide-tag-regex)
>(plist-get result :tags)))
>   (plist-get result :tags))
> " ")))

That's a good idea.  I adjusted the code to use remove-if, and it is
improved by the change.

Thanks,
James
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 



[PATCH] don't show x-foo tags in search view

2012-10-30 Thread Damien Cassou
On Mon, Oct 29, 2012 at 7:57 PM, James Vasile  
wrote:
> My filters create tags like x-bogotrained-spam that are for internal
> bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
> want them cluttering my 'search' view.  This patch omits x-foo and X-foo
> tags from the 'search' view.

what about using notmuch-labeler that let you hide whatever you want
(or replace it by pictures)?
https://github.com/DamienCassou/notmuch-labeler

I'm working on integrating it inside notmuch

-- 
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill


Re: [PATCH] don't show x-foo tags in search view

2012-10-30 Thread Damien Cassou
On Mon, Oct 29, 2012 at 7:57 PM, James Vasile ja...@hackervisions.org wrote:
 My filters create tags like x-bogotrained-spam that are for internal
 bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
 want them cluttering my 'search' view.  This patch omits x-foo and X-foo
 tags from the 'search' view.

what about using notmuch-labeler that let you hide whatever you want
(or replace it by pictures)?
https://github.com/DamienCassou/notmuch-labeler

I'm working on integrating it inside notmuch

-- 
Damien Cassou
http://damiencassou.seasidehosting.st

Success is the ability to go from one failure to another without
losing enthusiasm.
Winston Churchill
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] don't show x-foo tags in search view

2012-10-30 Thread James Vasile
Austin,

Thanks for the helpful comments.  I redid the patch to take a list of
regexps.  That way users can banish different kinds of tags or simply
list the tags themselves.  I've responded to your comments in text below
the patch.

---
 emacs/notmuch.el |   26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..05aa114 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -775,6 +775,21 @@ non-authors is found, assume that all of the authors 
match.
  (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
   (insert padding
 
+  
+(defcustom notmuch-search-hide-tag-regexps '()
+  List of regular expressionss specifying tags to hide in search view.
+
+Notmuch will hide any tags in search view that match the regexps
+specified in the list `notmuch-search-hide-tag-regexp`.  The
+match is case-insensitive.
+
+If you are not comfortable with regular expressions, a list of
+tag words will work, assuming those tags use only alphanumeric
+characters.  An empty list will disable hiding of tags in search
+view.  The list can be set via setq or the customize interface.
+  :type '(repeat  regexp)
+  :group 'notmuch-search)
+
 (defun notmuch-search-insert-field (field format-string result)
   (cond
((string-equal field date)
@@ -793,7 +808,16 @@ non-authors is found, assume that all of the authors 
match.
 (notmuch-search-insert-authors format-string (plist-get result :authors)))
 
((string-equal field tags)
-(let ((tags-str (mapconcat 'identity (plist-get result :tags)  )))
+(let ((tags-str
+  (mapconcat 'identity
+ (let ((case-fold-search t))
+   (remove-if
+(lambda (tag)
+  (find tag notmuch-search-hide-tag-regexps
+:test (lambda (tag regexp)
+(string-match regexp tag
+(plist-get result :tags)))
+  )))
   (insert (propertize (format format-string tags-str)
  'face 'notmuch-tag-face))
 
-- 
1.7.10.4


Austin Clements amdra...@mit.edu writes:
 I like it.

Thanks.

[snip]

 I have no idea why, but Emacs typically uses regexp instead of
 regex.

It probably has something to do with rhyming with 'sexp'. ;) It's good
to conform to the vernacular, so I fixed it.


 +
 +Leave blank to disable hiding of tags in search view.

 Saying Leave blank supposes that the user knows what the default
 value is.  How about An empty string disables hiding of tags in
 search view.?

I'm now using a list, but yes, an empty list is a good way to describe
it.


 Even better, though, would be to use nil to indicate this, since  is
 a perfectly valid regexp and matches everything.  In that case, this
 should say something like If nil, no tags will be hidden in search
 view.

An empty list is nil, so I think this is covered by my changes.  If
you think the defcustom text could be clearer, I'd appreciate edits.


 +Note: elisp regexes are case-insensitive

 Likewise, regexps.  Also, Elisp regexps are not, in general,
 case-insensitive.  If we want to control this, we should bind
 case-fold-search to nil around the string-match below and say
 something here like Matching is case-insensitive.

Good point.


 +  :type 'string

 Better would be 'regexp.  Or, '(choice (const :tag None nil) regexp)
 to allow nil or a regexp.

Changed to 'regexp.

[snip]

 It would be simpler and more robust to use remove-if here.  What about
 something like

   (let ((tags-str
  (mapconcat 'identity
 (if notmuch-search-hide-tag-regex
 (let ((case-fold-search t))
   (remove-if
(apply-partially #'string-match
 notmuch-search-hide-tag-regex)
(plist-get result :tags)))
   (plist-get result :tags))
  )))

That's a good idea.  I adjusted the code to use remove-if, and it is
improved by the change.

Thanks,
James


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


Re: [PATCH] don't show x-foo tags in search view

2012-10-30 Thread James Vasile
Damien Cassou damien.cas...@gmail.com writes:
 On Mon, Oct 29, 2012 at 7:57 PM, James Vasile ja...@hackervisions.org wrote:
 My filters create tags like x-bogotrained-spam that are for internal
 bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
 want them cluttering my 'search' view.  This patch omits x-foo and X-foo
 tags from the 'search' view.

 what about using notmuch-labeler that let you hide whatever you want
 (or replace it by pictures)?
 https://github.com/DamienCassou/notmuch-labeler

 I'm working on integrating it inside notmuch


I wasn't aware of labeler.  It looks like it has some nice
functionality.  When it gets integrated into the trunk, I'll use it,
assuming it can match regexps and not just literal strings.

Thanks!


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


[PATCH] don't show x-foo tags in search view

2012-10-29 Thread Austin Clements
I like it.

Quoth James Vasile on Oct 29 at  5:19 pm:
> This patch hides any tags in search view that match the regex specified
> in `notmuch-search-hide-tag-regex`.  That variable can be set via setq
> or the customize interface.  To hide all tags that begin with "x-" or
> "X-", set `notmuch-search-hide-tag-regex` to "^X-".
> 
> ---
>  emacs/notmuch.el |   16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index f9454d8..4bff538 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -775,6 +775,14 @@ non-authors is found, assume that all of the authors 
> match."
>   (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
>(insert padding
>  
> +(defcustom notmuch-search-hide-tag-regex ""
> +  "Regex specifying tags to hide in search view.

I have no idea why, but Emacs typically uses "regexp" instead of
"regex".

> +
> +Leave blank to disable hiding of tags in search view.

Saying "Leave blank" supposes that the user knows what the default
value is.  How about "An empty string disables hiding of tags in
search view."?

Even better, though, would be to use nil to indicate this, since "" is
a perfectly valid regexp and matches everything.  In that case, this
should say something like "If nil, no tags will be hidden in search
view."

> +Note: elisp regexes are case-insensitive"

Likewise, "regexps".  Also, Elisp regexps are not, in general,
case-insensitive.  If we want to control this, we should bind
case-fold-search to nil around the string-match below and say
something here like "Matching is case-insensitive."

> +  :type 'string

Better would be 'regexp.  Or, '(choice (const :tag "None" nil) regexp)
to allow nil or a regexp.

> +  :group 'notmuch-search)
> +
>  (defun notmuch-search-insert-field (field format-string result)
>(cond
> ((string-equal field "date")
> @@ -793,7 +801,13 @@ non-authors is found, assume that all of the authors 
> match."
>  (notmuch-search-insert-authors format-string (plist-get result 
> :authors)))
>  
> ((string-equal field "tags")
> -(let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
> +(let ((tags-str (mapconcat 'identity
> +  (delq nil
> +(mapcar (lambda (x) (if (and (not (equal 
> notmuch-search-hide-tag-regex ""))
> + 
> (string-match notmuch-search-hide-tag-regex x))
> +nil
> +x)) (plist-get 
> result :tags)))
> +  " ")))

It would be simpler and more robust to use remove-if here.  What about
something like

  (let ((tags-str
 (mapconcat 'identity
(if notmuch-search-hide-tag-regex
(let ((case-fold-search t))
  (remove-if
   (apply-partially #'string-match
notmuch-search-hide-tag-regex)
   (plist-get result :tags)))
  (plist-get result :tags))
" ")))

?

>(insert (propertize (format format-string tags-str)
>   'face 'notmuch-tag-face))
>  


[PATCH] don't show x-foo tags in search view

2012-10-29 Thread James Vasile
This patch hides any tags in search view that match the regex specified
in `notmuch-search-hide-tag-regex`.  That variable can be set via setq
or the customize interface.  To hide all tags that begin with "x-" or
"X-", set `notmuch-search-hide-tag-regex` to "^X-".

---
 emacs/notmuch.el |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..4bff538 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -775,6 +775,14 @@ non-authors is found, assume that all of the authors 
match."
  (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
   (insert padding

+(defcustom notmuch-search-hide-tag-regex ""
+  "Regex specifying tags to hide in search view.
+
+Leave blank to disable hiding of tags in search view.
+Note: elisp regexes are case-insensitive"
+  :type 'string
+  :group 'notmuch-search)
+
 (defun notmuch-search-insert-field (field format-string result)
   (cond
((string-equal field "date")
@@ -793,7 +801,13 @@ non-authors is found, assume that all of the authors 
match."
 (notmuch-search-insert-authors format-string (plist-get result :authors)))

((string-equal field "tags")
-(let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
+(let ((tags-str (mapconcat 'identity
+  (delq nil
+(mapcar (lambda (x) (if (and (not (equal 
notmuch-search-hide-tag-regex ""))
+ (string-match 
notmuch-search-hide-tag-regex x))
+nil
+x)) (plist-get 
result :tags)))
+  " ")))
   (insert (propertize (format format-string tags-str)
  'face 'notmuch-tag-face))

-- 
1.7.10.4

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



[PATCH] don't show x-foo tags in search view

2012-10-29 Thread David Bremner
James Vasile  writes:

> My filters create tags like x-bogotrained-spam that are for internal
> bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
> want them cluttering my 'search' view.  This patch omits x-foo and X-foo
> tags from the 'search' view.

I understand this scratches your itch, but what about something more
customizable?

d


[PATCH] don't show x-foo tags in search view

2012-10-29 Thread James Vasile
David Bremner  writes:
> James Vasile  writes:
>
>> My filters create tags like x-bogotrained-spam that are for internal
>> bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
>> want them cluttering my 'search' view.  This patch omits x-foo and X-foo
>> tags from the 'search' view.
>
> I understand this scratches your itch, but what about something more
> customizable?
>
> d

I thought it was fairly general as is, but you're right it could be more
customizable.  I'll rewrite it with a regex the user can customize.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 



[PATCH] don't show x-foo tags in search view

2012-10-29 Thread James Vasile
My filters create tags like x-bogotrained-spam that are for internal
bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
want them cluttering my 'search' view.  This patch omits x-foo and X-foo
tags from the 'search' view.

---
 emacs/notmuch.el |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..90fafbf 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -793,7 +793,12 @@ non-authors is found, assume that all of the authors 
match."
 (notmuch-search-insert-authors format-string (plist-get result :authors)))

((string-equal field "tags")
-(let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
+(let ((tags-str (mapconcat 'identity
+  (delq nil
+(mapcar (lambda (x) (if (equal (upcase 
(truncate-string-to-width  x 2)) "X-")
+nil
+(identity x))) 
(plist-get result :tags)))
+  " ")))
   (insert (propertize (format format-string tags-str)
  'face 'notmuch-tag-face))

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



[PATCH] don't show x-foo tags in search view

2012-10-29 Thread James Vasile
My filters create tags like x-bogotrained-spam that are for internal
bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
want them cluttering my 'search' view.  This patch omits x-foo and X-foo
tags from the 'search' view.

---
 emacs/notmuch.el |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..90fafbf 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -793,7 +793,12 @@ non-authors is found, assume that all of the authors 
match.
 (notmuch-search-insert-authors format-string (plist-get result :authors)))
 
((string-equal field tags)
-(let ((tags-str (mapconcat 'identity (plist-get result :tags)  )))
+(let ((tags-str (mapconcat 'identity
+  (delq nil
+(mapcar (lambda (x) (if (equal (upcase 
(truncate-string-to-width  x 2)) X-)
+nil
+(identity x))) 
(plist-get result :tags)))
+   )))
   (insert (propertize (format format-string tags-str)
  'face 'notmuch-tag-face))
 
-- 
1.7.10.4


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


Re: [PATCH] don't show x-foo tags in search view

2012-10-29 Thread David Bremner
James Vasile ja...@hackervisions.org writes:

 My filters create tags like x-bogotrained-spam that are for internal
 bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
 want them cluttering my 'search' view.  This patch omits x-foo and X-foo
 tags from the 'search' view.

I understand this scratches your itch, but what about something more
customizable?

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


Re: [PATCH] don't show x-foo tags in search view

2012-10-29 Thread James Vasile
David Bremner da...@tethera.net writes:
 James Vasile ja...@hackervisions.org writes:

 My filters create tags like x-bogotrained-spam that are for internal
 bookkeeping.  I don't mind seeing them in the 'show' view, but I didn't
 want them cluttering my 'search' view.  This patch omits x-foo and X-foo
 tags from the 'search' view.

 I understand this scratches your itch, but what about something more
 customizable?

 d

I thought it was fairly general as is, but you're right it could be more
customizable.  I'll rewrite it with a regex the user can customize.


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


Re: [PATCH] don't show x-foo tags in search view

2012-10-29 Thread James Vasile
This patch hides any tags in search view that match the regex specified
in `notmuch-search-hide-tag-regex`.  That variable can be set via setq
or the customize interface.  To hide all tags that begin with x- or
X-, set `notmuch-search-hide-tag-regex` to ^X-.

---
 emacs/notmuch.el |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f9454d8..4bff538 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -775,6 +775,14 @@ non-authors is found, assume that all of the authors 
match.
  (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
   (insert padding
 
+(defcustom notmuch-search-hide-tag-regex 
+  Regex specifying tags to hide in search view.
+
+Leave blank to disable hiding of tags in search view.
+Note: elisp regexes are case-insensitive
+  :type 'string
+  :group 'notmuch-search)
+
 (defun notmuch-search-insert-field (field format-string result)
   (cond
((string-equal field date)
@@ -793,7 +801,13 @@ non-authors is found, assume that all of the authors 
match.
 (notmuch-search-insert-authors format-string (plist-get result :authors)))
 
((string-equal field tags)
-(let ((tags-str (mapconcat 'identity (plist-get result :tags)  )))
+(let ((tags-str (mapconcat 'identity
+  (delq nil
+(mapcar (lambda (x) (if (and (not (equal 
notmuch-search-hide-tag-regex ))
+ (string-match 
notmuch-search-hide-tag-regex x))
+nil
+x)) (plist-get 
result :tags)))
+   )))
   (insert (propertize (format format-string tags-str)
  'face 'notmuch-tag-face))
 
-- 
1.7.10.4



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


Re: [PATCH] don't show x-foo tags in search view

2012-10-29 Thread Austin Clements
I like it.

Quoth James Vasile on Oct 29 at  5:19 pm:
 This patch hides any tags in search view that match the regex specified
 in `notmuch-search-hide-tag-regex`.  That variable can be set via setq
 or the customize interface.  To hide all tags that begin with x- or
 X-, set `notmuch-search-hide-tag-regex` to ^X-.
 
 ---
  emacs/notmuch.el |   16 +++-
  1 file changed, 15 insertions(+), 1 deletion(-)
 
 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
 index f9454d8..4bff538 100644
 --- a/emacs/notmuch.el
 +++ b/emacs/notmuch.el
 @@ -775,6 +775,14 @@ non-authors is found, assume that all of the authors 
 match.
   (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
(insert padding
  
 +(defcustom notmuch-search-hide-tag-regex 
 +  Regex specifying tags to hide in search view.

I have no idea why, but Emacs typically uses regexp instead of
regex.

 +
 +Leave blank to disable hiding of tags in search view.

Saying Leave blank supposes that the user knows what the default
value is.  How about An empty string disables hiding of tags in
search view.?

Even better, though, would be to use nil to indicate this, since  is
a perfectly valid regexp and matches everything.  In that case, this
should say something like If nil, no tags will be hidden in search
view.

 +Note: elisp regexes are case-insensitive

Likewise, regexps.  Also, Elisp regexps are not, in general,
case-insensitive.  If we want to control this, we should bind
case-fold-search to nil around the string-match below and say
something here like Matching is case-insensitive.

 +  :type 'string

Better would be 'regexp.  Or, '(choice (const :tag None nil) regexp)
to allow nil or a regexp.

 +  :group 'notmuch-search)
 +
  (defun notmuch-search-insert-field (field format-string result)
(cond
 ((string-equal field date)
 @@ -793,7 +801,13 @@ non-authors is found, assume that all of the authors 
 match.
  (notmuch-search-insert-authors format-string (plist-get result 
 :authors)))
  
 ((string-equal field tags)
 -(let ((tags-str (mapconcat 'identity (plist-get result :tags)  )))
 +(let ((tags-str (mapconcat 'identity
 +  (delq nil
 +(mapcar (lambda (x) (if (and (not (equal 
 notmuch-search-hide-tag-regex ))
 + 
 (string-match notmuch-search-hide-tag-regex x))
 +nil
 +x)) (plist-get 
 result :tags)))
 +   )))

It would be simpler and more robust to use remove-if here.  What about
something like

  (let ((tags-str
 (mapconcat 'identity
(if notmuch-search-hide-tag-regex
(let ((case-fold-search t))
  (remove-if
   (apply-partially #'string-match
notmuch-search-hide-tag-regex)
   (plist-get result :tags)))
  (plist-get result :tags))
 )))

?

(insert (propertize (format format-string tags-str)
   'face 'notmuch-tag-face))
  
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch