unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 0/4] nmbug-status: meta.message-url and query parens
@ 2016-01-02  6:07 W. Trevor King
  2016-01-02  6:07 ` [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config W. Trevor King
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: W. Trevor King @ 2016-01-02  6:07 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner, Tomi Ollila, Jani Nikula, Carl Worth,
	W. Trevor King

Changes since v1 [1]:

* [4/5, v2 3/4] Added parentheses handling for ‘nmbug-status
  --get-query VIEW’ too [2].
* [3/5] Dropped the man page, and will file a separate series that
  adds man pages to the script directory [3].

Cheers,
Trevor

[1]: id:cover.1451502495.git.wking@tremily.us
     http://thread.gmane.org/gmane.mail.notmuch.general/21523
     http://thread.gmane.org/gmane.mail.notmuch.general/21535
[2]: id:20151231164719.GA20010@odin.tremily.us
     http://thread.gmane.org/gmane.mail.notmuch.general/21523/focus=21534

W. Trevor King (4):
  NEWS: Remove trailing comma from an old nmbug-status config
  nmbug-status: Add meta.message-url config setting
  nmbug-status: Wrap query phrases in parentheses when and-ing together
  status-config.json: Remove parens from query entry

 NEWS                           | 25 ++++++++++++++++++++++++-
 devel/nmbug/nmbug-status       | 18 +++++++++++++-----
 devel/nmbug/status-config.json |  2 +-
 3 files changed, 38 insertions(+), 7 deletions(-)

-- 
2.1.0.60.g85f0837

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config
  2016-01-02  6:07 [PATCH v2 0/4] nmbug-status: meta.message-url and query parens W. Trevor King
@ 2016-01-02  6:07 ` W. Trevor King
  2016-01-07 13:27   ` David Bremner
  2016-01-02  6:07 ` [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting W. Trevor King
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: W. Trevor King @ 2016-01-02  6:07 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner, Tomi Ollila, Jani Nikula, Carl Worth,
	W. Trevor King

That closing brace is the end of the config JSON; there won't be
anything coming after it.
---
 NEWS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 6681699..0a7a0e0 100644
--- a/NEWS
+++ b/NEWS
@@ -409,7 +409,7 @@ from the config file.  Use something like:
          ...
       },
       ...
-    },
+    }
 
 Python Bindings
 ---------------
-- 
2.1.0.60.g85f0837

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting
  2016-01-02  6:07 [PATCH v2 0/4] nmbug-status: meta.message-url and query parens W. Trevor King
  2016-01-02  6:07 ` [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config W. Trevor King
@ 2016-01-02  6:07 ` W. Trevor King
  2016-03-23 11:19   ` David Bremner
  2016-01-02  6:07 ` [PATCH v2 3/4] nmbug-status: Wrap query phrases in parentheses when and-ing together W. Trevor King
  2016-01-02  6:07 ` [PATCH v2 4/4] status-config.json: Remove parens from query entry W. Trevor King
  3 siblings, 1 reply; 9+ messages in thread
From: W. Trevor King @ 2016-01-02  6:07 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner, Tomi Ollila, Jani Nikula, Carl Worth,
	W. Trevor King

So you can link to archives other than Gmane.  For example, I'm doing
this in [1].

[1]: https://github.com/wking/nmbug-oci
---
 NEWS                     | 20 ++++++++++++++++++++
 devel/nmbug/nmbug-status | 13 ++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 0a7a0e0..9f2e860 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,23 @@
+Notmuch 0.22 (UNRELEASED)
+=========================
+
+nmbug-status
+------------
+
+`nmbug-status` now supports `meta.message-url` to override the Gmane
+template.  For example, you can use:
+
+    {
+      "meta": {
+        "message-url": "https://groups.google.com/a/opencontainers.org/forum/#!search/messageid$3A%22{message-id}%22"
+         ...
+      },
+      ...
+    }
+
+To link to messages in the [opencontainers.org Google
+Groups](https://groups.google.com/a/opencontainers.org/forum/#!overview).
+
 Notmuch 0.21 (2015-10-29)
 =========================
 
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index b36b6ad..d72f1db 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -19,11 +19,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/ .
 
-"""Generate HTML for one or more notmuch searches.
+"""Generate text and/or HTML for one or more notmuch searches.
 
 Messages matching each search are grouped by thread.  Each message
 that contains both a subject and message-id will have the displayed
-subject link to the Gmane view of the message.
+subject link to an archive view of the message (defaulting to Gmane).
 """
 
 from __future__ import print_function
@@ -232,6 +232,10 @@ class Page (object):
 class HtmlPage (Page):
     _slug_regexp = re.compile('\W+')
 
+    def __init__(self, message_url_template, **kwargs):
+        self.message_url_template = message_url_template
+        super(HtmlPage, self).__init__(**kwargs)
+
     def _write_header(self, views, stream):
         super(HtmlPage, self)._write_header(views=views, stream=stream)
         stream.write('<ul>\n')
@@ -292,8 +296,9 @@ class HtmlPage (Page):
                 'message-id': quote(display_data['message-id']),
                 'subject': xml.sax.saxutils.escape(display_data['subject']),
                 }
+            d['url'] = self.message_url_template.format(**d)
             display_data['subject'] = (
-                '<a href="http://mid.gmane.org/{message-id}">{subject}</a>'
+                '<a href="{url}">{subject}</a>'
                 ).format(**d)
         for key in ['message-id', 'from']:
             if key in display_data:
@@ -395,6 +400,8 @@ _PAGES['text'] = Page()
 _PAGES['html'] = HtmlPage(
     header=header_template.format(**context),
     footer=footer_template.format(**context),
+    message_url_template=config['meta'].get(
+        'message-url', 'http://mid.gmane.org/{message-id}'),
     )
 
 if args.list_views:
-- 
2.1.0.60.g85f0837

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/4] nmbug-status: Wrap query phrases in parentheses when and-ing together
  2016-01-02  6:07 [PATCH v2 0/4] nmbug-status: meta.message-url and query parens W. Trevor King
  2016-01-02  6:07 ` [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config W. Trevor King
  2016-01-02  6:07 ` [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting W. Trevor King
@ 2016-01-02  6:07 ` W. Trevor King
  2016-01-02  6:07 ` [PATCH v2 4/4] status-config.json: Remove parens from query entry W. Trevor King
  3 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2016-01-02  6:07 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner, Tomi Ollila, Jani Nikula, Carl Worth,
	W. Trevor King

For example:

  "query": ["tag:a", "tag:b or tag:c"]

is now converted to:

  ( tag:a ) and ( tag:b or tag:c )

instead of the old:

  tag:a and tag:b or tag:c

This helps us avoid confusion due to Xapian's higher-precedence AND
[1], where the old query would be interpreted as:

  ( tag:a and tag:b ) or tag:c

[1]: http://xapian.org/docs/queryparser.html
---
 NEWS                     | 3 +++
 devel/nmbug/nmbug-status | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 9f2e860..403a046 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Notmuch 0.22 (UNRELEASED)
 nmbug-status
 ------------
 
+`nmbug-status` now wraps query phrases in parentheses when and-ing
+them together, to avoid confusion about clause grouping.
+
 `nmbug-status` now supports `meta.message-url` to override the Gmane
 template.  For example, you can use:
 
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index d72f1db..7d3a76e 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -167,7 +167,8 @@ class Page (object):
                 view['title'], sort_key))
         if 'query-string' not in view:
             query = view['query']
-            view['query-string'] = ' and '.join(query)
+            view['query-string'] = ' and '.join(
+                '( {} )'.format(q) for q in query)
         q = notmuch.Query(database, view['query-string'])
         q.set_sort(sort)
         threads = self._get_threads(messages=q.search_messages())
@@ -411,7 +412,7 @@ if args.list_views:
 elif args.get_query != None:
     for view in config['views']:
         if args.get_query == view['title']:
-            print(' and '.join(view['query']))
+            print(' and '.join('( {} )'.format(q) for q in view['query']))
     sys.exit(0)
 else:
     # only import notmuch if needed
-- 
2.1.0.60.g85f0837

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] status-config.json: Remove parens from query entry
  2016-01-02  6:07 [PATCH v2 0/4] nmbug-status: meta.message-url and query parens W. Trevor King
                   ` (2 preceding siblings ...)
  2016-01-02  6:07 ` [PATCH v2 3/4] nmbug-status: Wrap query phrases in parentheses when and-ing together W. Trevor King
@ 2016-01-02  6:07 ` W. Trevor King
  2016-03-24 10:53   ` David Bremner
  3 siblings, 1 reply; 9+ messages in thread
From: W. Trevor King @ 2016-01-02  6:07 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner, Tomi Ollila, Jani Nikula, Carl Worth,
	W. Trevor King

These are now added by nmbug-status.
---
 devel/nmbug/status-config.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devel/nmbug/status-config.json b/devel/nmbug/status-config.json
index b926946..48b6f19 100644
--- a/devel/nmbug/status-config.json
+++ b/devel/nmbug/status-config.json
@@ -62,7 +62,7 @@
 		"not tag:notmuch::obsolete",
 		"not tag:notmuch::stale",
 		"not tag:notmuch::wontfix",
-		"(tag:notmuch::moreinfo or tag:notmuch::needs-review)"
+		"tag:notmuch::moreinfo or tag:notmuch::needs-review"
 	    ],
 	    "title": "Review"
 	}
-- 
2.1.0.60.g85f0837

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config
  2016-01-02  6:07 ` [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config W. Trevor King
@ 2016-01-07 13:27   ` David Bremner
  0 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2016-01-07 13:27 UTC (permalink / raw)
  To: W. Trevor King, notmuch

"W. Trevor King" <wking@tremily.us> writes:

> That closing brace is the end of the config JSON; there won't be
> anything coming after it.
> ---
>  NEWS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/NEWS b/NEWS
> index 6681699..0a7a0e0 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -409,7 +409,7 @@ from the config file.  Use something like:
>           ...
>        },
>        ...
> -    },
> +    }
>  

Pushed this patch. 

d

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting
  2016-01-02  6:07 ` [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting W. Trevor King
@ 2016-03-23 11:19   ` David Bremner
  2016-03-23 16:42     ` W. Trevor King
  0 siblings, 1 reply; 9+ messages in thread
From: David Bremner @ 2016-03-23 11:19 UTC (permalink / raw)
  To: W. Trevor King, notmuch

"W. Trevor King" <wking@tremily.us> writes:

>  from __future__ import print_function
> @@ -232,6 +232,10 @@ class Page (object):
>  class HtmlPage (Page):
>      _slug_regexp = re.compile('\W+')
>  
> +    def __init__(self, message_url_template, **kwargs):
> +        self.message_url_template = message_url_template
> +        super(HtmlPage, self).__init__(**kwargs)
> +

> @@ -395,6 +400,8 @@ _PAGES['text'] = Page()
>  _PAGES['html'] = HtmlPage(
>      header=header_template.format(**context),
>      footer=footer_template.format(**context),
> +    message_url_template=config['meta'].get(
> +        'message-url', 'http://mid.gmane.org/{message-id}'),
>      )
>  

Maybe I'm missing some python knowledged, but it looks the constructor
is defined to take a regular argument for message_url_template, but only
passed in as a keyword. Does this really work?

d

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting
  2016-03-23 11:19   ` David Bremner
@ 2016-03-23 16:42     ` W. Trevor King
  0 siblings, 0 replies; 9+ messages in thread
From: W. Trevor King @ 2016-03-23 16:42 UTC (permalink / raw)
  To: David Bremner; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 2525 bytes --]

On Wed, Mar 23, 2016 at 08:19:34AM -0300, David Bremner wrote:
> W. Trevor King writes:
> >  from __future__ import print_function
> > @@ -232,6 +232,10 @@ class Page (object):
> >  class HtmlPage (Page):
> >      _slug_regexp = re.compile('\W+')
> >
> > +    def __init__(self, message_url_template, **kwargs):
> > +        self.message_url_template = message_url_template
> > +        super(HtmlPage, self).__init__(**kwargs)
> > +
>
> > @@ -395,6 +400,8 @@ _PAGES['text'] = Page()
> >  _PAGES['html'] = HtmlPage(
> >      header=header_template.format(**context),
> >      footer=footer_template.format(**context),
> > +    message_url_template=config['meta'].get(
> > +        'message-url', 'http://mid.gmane.org/{message-id}'),
> >      )
> >
>
> Maybe I'm missing some python knowledged, but it looks the
> constructor is defined to take a regular argument for
> message_url_template, but only passed in as a keyword. Does this
> really work?

Yup.  From [1]:

  positional-only: specifies an argument that can be supplied only by
    position. Python has no syntax for defining positional-only
    parameters. However, some built-in functions have positional-only
    parameters (e.g. abs()).

I can't find a similar Python 3 glossary, but see [2].  Whether we use:

  def __init__(self, message_url_template, **kwargs):
      …

or:

  def __init__(self, message_url_template='foobar', **kwargs):
      …

just controls whether the message_url_template has a default or not,
and not whether it can be set via positional or keyword arguments.

There is Python syntax for keyword-only arguments, and it would look
like [2]:

  def __init__(self, *, message_url_template, **kwargs):
      …

or:

  def __init__(self, *, message_url_template='foobar', **kwargs):
      …

in the former case, you'd have to call __init__ with a
message_url_template=… keyword argument or you'd get:

  TypeError: __init__() missing 1 required keyword-only argument: 'message_url_template'

With the latter case, calling __init__ without a message_url_template
argument would just get you the default value (‘foobar’ in these
examples).

Cheers,
Trevor

[1]: https://docs.python.org/2/glossary.html#term-parameter
[2]: https://docs.python.org/3/reference/compound_stmts.html#function-definitions

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/4] status-config.json: Remove parens from query entry
  2016-01-02  6:07 ` [PATCH v2 4/4] status-config.json: Remove parens from query entry W. Trevor King
@ 2016-03-24 10:53   ` David Bremner
  0 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2016-03-24 10:53 UTC (permalink / raw)
  To: W. Trevor King, notmuch

"W. Trevor King" <wking@tremily.us> writes:

> These are now added by nmbug-status.
> ---
>  devel/nmbug/status-config.json | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/devel/nmbug/status-config.json b/devel/nmbug/status-config.json
> index b926946..48b6f19 100644
> --- a/devel/nmbug/status-config.json
> +++ b/devel/nmbug/status-config.json
> @@ -62,7 +62,7 @@
>  		"not tag:notmuch::obsolete",
>  		"not tag:notmuch::stale",
>  		"not tag:notmuch::wontfix",
> -		"(tag:notmuch::moreinfo or tag:notmuch::needs-review)"
> +		"tag:notmuch::moreinfo or tag:notmuch::needs-review"
>  	    ],
>  	    "title": "Review"
>  	}
> -- 
> 2.1.0.60.g85f0837

These are now merged as well.

d

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-03-24 10:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-02  6:07 [PATCH v2 0/4] nmbug-status: meta.message-url and query parens W. Trevor King
2016-01-02  6:07 ` [PATCH v2 1/4] NEWS: Remove trailing comma from an old nmbug-status config W. Trevor King
2016-01-07 13:27   ` David Bremner
2016-01-02  6:07 ` [PATCH v2 2/4] nmbug-status: Add meta.message-url config setting W. Trevor King
2016-03-23 11:19   ` David Bremner
2016-03-23 16:42     ` W. Trevor King
2016-01-02  6:07 ` [PATCH v2 3/4] nmbug-status: Wrap query phrases in parentheses when and-ing together W. Trevor King
2016-01-02  6:07 ` [PATCH v2 4/4] status-config.json: Remove parens from query entry W. Trevor King
2016-03-24 10:53   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).