[PATCH 4/5] nmbug-status: Wrap query phrases in parentheses when and-ing together

2015-12-30 Thread 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 | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 9a6a757..1c618d1 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ A new `nmbug-status(5)` describes `nmbug-status`'s JSON config 
file.
 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 336d0d2..a477af8 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())
-- 
2.1.0.60.g85f0837

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


[PATCH 5/5] status-config.json: Remove parens from query entry

2015-12-30 Thread 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

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


[PATCH 3/5] nmbug-status: Add an nmbug-status(5) man page

2015-12-30 Thread W. Trevor King
To describe the config file format, so folks don't have to dig through
NEWS or the nmbug-status source to get that information.
---
 NEWS  |   5 ++
 devel/nmbug/nmbug-status  |  19 ---
 doc/conf.py   |   6 ++
 doc/index.rst |   1 +
 doc/man5/nmbug-status.rst | 136 ++
 5 files changed, 159 insertions(+), 8 deletions(-)
 create mode 100644 doc/man5/nmbug-status.rst

diff --git a/NEWS b/NEWS
index 9f2e860..9a6a757 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 Notmuch 0.22 (UNRELEASED)
 =
 
+Documentation
+-
+
+A new `nmbug-status(5)` describes `nmbug-status`'s JSON config file.
+
 nmbug-status
 
 
diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index d72f1db..336d0d2 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -309,14 +309,17 @@ class HtmlPage (Page):
 return self._slug_regexp.sub('-', string)
 
 parser = argparse.ArgumentParser(description=__doc__)
-parser.add_argument('--text', help='output plain text format',
-action='store_true')
-parser.add_argument('--config', help='load config from given file',
-metavar='PATH')
-parser.add_argument('--list-views', help='list views',
-action='store_true')
-parser.add_argument('--get-query', help='get query for view',
-metavar='VIEW')
+parser.add_argument(
+'--text', action='store_true', help='output plain text format')
+parser.add_argument(
+'--config', metavar='PATH',
+help='load config from given file.  '
+'The format is described in nmbug-status(5).')
+parser.add_argument(
+'--list-views', action='store_true', help='list views')
+parser.add_argument(
+'--get-query', metavar='VIEW', help='get query for view')
+
 
 args = parser.parse_args()
 
diff --git a/doc/conf.py b/doc/conf.py
index 65adafe..eac747e 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -118,6 +118,9 @@ man_pages = [
 u'add/remove tags for all messages matching the search terms',
 [u'Carl Worth and many others'], 1),
 
+('man5/nmbug-status','nmbug-status',
+u'configuration for nmbug-status',
+[u'Carl Worth and many others'], 5),
 
 ]
 # If true, show URL addresses after external links.
@@ -180,4 +183,7 @@ texinfo_documents = [
 ('man1/notmuch-tag','notmuch-tag',u'notmuch Documentation',
   u'Carl Worth and many others', 'notmuch-tag',
   'add/remove tags for all messages matching the search 
terms','Miscellaneous'),
+('man5/nmbug-status','nmbug-status',u'notmuch Documentation',
+  u'Carl Worth and many others', 'nmbug-status',
+  'configuration for nmbug-status','Miscellaneous'),
 ]
diff --git a/doc/index.rst b/doc/index.rst
index 3f0e6e6..bcb1dd0 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -23,6 +23,7 @@ Contents:
man7/notmuch-search-terms
man1/notmuch-show
man1/notmuch-tag
+   man5/nmbug-status
 
 Indices and tables
 ==
diff --git a/doc/man5/nmbug-status.rst b/doc/man5/nmbug-status.rst
new file mode 100644
index 000..5b59bdd
--- /dev/null
+++ b/doc/man5/nmbug-status.rst
@@ -0,0 +1,136 @@
+
+nmbug-status
+
+
+NAME
+
+
+status-config.json - configure output for **nmbug-status(1)**
+
+DESCRIPTION
+===
+
+The config file is JSON_ with the following fields:
+
+meta
+  An object with page-wide information
+
+  title
+Page title used in the default header.
+
+  blurb
+Introduction paragraph used in the default header.
+
+  header
+`Python format string`_ for the HTML header.  Optional.  It is
+formatted with the following context:
+
+date
+  The current UTC date.
+
+datetime
+  The current UTC date-time.
+
+title
+  The **meta.title** value.
+
+blurb
+  The **meta.blurb** value.
+
+encoding
+  The encoding used for the output file.
+
+inter_message_padding
+  0.25em, for consistent CSS generation.
+
+border_radius
+  0.5em, for consistent CSS generation.
+
+  footer
+`Python format string`_ for the HTML footer.  It is formatted with
+the same context used for **meta.header**.  Optional.
+
+  message-url
+`Python format string`_ for message-linking URLs.  Optional.
+Defaults to linking Gmane_.  It is formatted with the following
+context:
+
+message-id
+  The quoted_ message ID.
+
+subject
+  The message subject.
+
+views
+  An array of view objects, where each object has the following
+  fields:
+
+  title
+Header text for the view.
+
+  comment
+Paragraph describing the view in more detail.  Optional.
+
+  id
+Anchor string for the view.  Optional, defaulting to a slugged
+form of the view title
+
+  query
+An array of strings, which will be joined with 'and' to form the
+view query.
+
+.. _Gmane: http://gmane.org/
+.. _JSON: http://json.org/
+.. _Python format 

[PATCH 2/5] nmbug-status: Add meta.message-url config setting

2015-12-30 Thread 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('\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'] = (
-'http://mid.gmane.org/{message-id};>{subject}'
+'{subject}'
 ).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

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


[PATCH 1/5] NEWS: Remove trailing comma from an old nmbug-status config

2015-12-30 Thread 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

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


[PATCH 0/5] nmbug-status: meta.message-url, man page, and query parens

2015-12-30 Thread W. Trevor King
I needed meta.message-url for [1], and then felt like the config file
was getting complicated enough that it deserved some docs.

The query paren and trailing-comma fixups are drive-bys, and I can
split then out into their own series if that's easier.  I'm also happy
having patches cherry-picked out of this series as each patch passes
review.  The only strict dependency is that the man page has to land
after the meta.message-url patch, because it documents that field.

Cheers,
Trevor

[1]: https://github.com/wking/nmbug-oci

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

 NEWS   |  30 -
 devel/nmbug/nmbug-status   |  35 +++
 devel/nmbug/status-config.json |   2 +-
 doc/conf.py|   6 ++
 doc/index.rst  |   1 +
 doc/man5/nmbug-status.rst  | 136 +
 6 files changed, 196 insertions(+), 14 deletions(-)
 create mode 100644 doc/man5/nmbug-status.rst

-- 
2.1.0.60.g85f0837

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


[PATCH 1/2] nmbug-status: Adjust headers to start with h1

2015-12-30 Thread W. Trevor King
We've been leading off with h2s since 3e5fb88f (contrib/nmbug: add
nmbug-status script, 2012-07-07), but the semantically-correct headers
are:

  {title}
  ...
  Views
  ...
  View 1
  ...
  View 2
  ...

We can always add additional CSS if the default h1 formatting is too
intense.
---
 devel/nmbug/nmbug-status | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index b36b6ad..8fd736c 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -367,10 +367,10 @@ header_template = config['meta'].get('header', 
'''
   
 
 
-{title}
+{title}
 {blurb}
 
-Views
+Views
 ''')
 
 footer_template = config['meta'].get('footer', '''
-- 
2.1.0.60.g85f0837

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


[PATCH 2/2] nmbug-status: Fix unbalanced tags in default header/footer

2015-12-30 Thread W. Trevor King
These were broken by b70386a4 (Move the generated date from the top of
the page to the footer, 2014-05-31), which moved 'Generated ...' to
the footer with the opening tag, but didn't replace the blurb opening
tag or add a closing tag after 'Generated ...'.
---
 devel/nmbug/nmbug-status | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 8fd736c..f33f660 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -368,6 +368,7 @@ header_template = config['meta'].get('header', '''
 
 
 {title}
+
 {blurb}
 
 Views
@@ -375,7 +376,7 @@ header_template = config['meta'].get('header', '''
 
 footer_template = config['meta'].get('footer', '''
 
-Generated: {datetime}
+Generated: {datetime}
 
 
 ''')
-- 
2.1.0.60.g85f0837

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


[PATCH 0/2] nmbug-status: h1 title and unbalanced fixups to default templates

2015-12-30 Thread W. Trevor King
Polishing the templates a bit.  Details in the individual patches.

Cheers,
Trevor

W. Trevor King (2):
  nmbug-status: Adjust headers to start with h1
  nmbug-status: Fix unbalanced  tags in default header/footer

 devel/nmbug/nmbug-status | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
2.1.0.60.g85f0837

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


Re: file-error "not a regular file"

2015-12-30 Thread Michal Sojka
Hi fauno,

On Tue, Dec 29 2015, fauno wrote:
> David Bremner  writes:
>
>> I guess the tl;dr is that I can't duplicate this problem. Looking at the
>> traceback Peter provided, it looks like he is using
>> "send-message-without-bullets" to send the message. Since this isn't a
>> notmuch function, it's likely bypassing the notmuch fcc setup that
>> notmuch-mua-send and notmuch-mua-send-and-exit do.
>
> i've found the issue.  i'm using jl-encrypt that expects email written
> in message-mode, and since notmuch is now a minor mode some functions
> that were expected to be there didn't work anymore.

can you share more details about how do you use jl-encrypt and which
functions do not work? Recently, I posted a few patches that fix some
problems related to the replacing message-mode with
notmuch-message-mode. Maybe, there is more what we can do to not break
user's setups.

From a brief look at jl-encrypt, it seems it is tightly bound to gnus,
because it uses gnus-message-setup-hook. Maybe it will work again with
notmuch if you use my patch [1] and run

(add-hook 'message-setup-hook 'jl-encrypt-if-possible)

-Michal

[1] id:1450690875-2111-2-git-send-email-sojk...@fel.cvut.cz
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


notmuch-mua and jl-encrypt (was: file-error "not a regular file")

2015-12-30 Thread fauno
Michal Sojka  writes:
> can you share more details about how do you use jl-encrypt and which
> functions do not work? Recently, I posted a few patches that fix some
> problems related to the replacing message-mode with
> notmuch-message-mode. Maybe, there is more what we can do to not break
> user's setups.

i've been using jl-encrypt unmodified with notmuch for a while now.  i
just require it on my .emacs

since 0.21, i had to rebind notmuch-message-mode C-c C-c and C-s C-s
keys:

(define-key notmuch-message-mode-map (kbd "C-c C-c") 'jl-message-send-and-exit)
(define-key notmuch-message-mode-map (kbd "C-c C-s") 'jl-message-send)

and solved the issue of fcc by setting notmuch-fcc-dirs to nil and
making my mta send me bcc of my own email.

this has worked correctly for the last week.

> From a brief look at jl-encrypt, it seems it is tightly bound to gnus,
> because it uses gnus-message-setup-hook. Maybe it will work again with
> notmuch if you use my patch [1] and run
>
> (add-hook 'message-setup-hook 'jl-encrypt-if-possible)

i applied your patch to the 0.21 release and byte-compiled notmuch-mua.el

the message is sent unencrypted unless i rebind C-c C-c as before.  the
email is encrypted but it asks for the recipient, which i'm guessing
emacs can't figure out for itself anymore?

also tested with `emacs -q` and loading this file, and jl-encrypt never
asks to encrypt the email when possible:

# /tmp/emacs

(require 'notmuch)
(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'jl-encrypt)
(add-hook 'message-setup-hook 'jl-encrypt-if-possible)
(add-hook 'message-setup-hook 'mml-secure-message-sign-pgpmime)

by adding the C-c C-c rebind, it gets to encrypt, but asks for recipient
again.

i hope this info is useful :)

> -Michal
>
> [1] id:1450690875-2111-2-git-send-email-sojk...@fel.cvut.cz

-- 
:D


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


Re: [PATCH v2] emacs: Improve notmuch-message-mode initialization

2015-12-30 Thread David Bremner
Michal Sojka  writes:

> Recent addition of notmuch-message-mode introduced several problems:
>
> 1. When message-setup-hook is used to set buffer local variables,
>these settings are not effective, because all buffer local
>variables are immediately erased by notmuch-message-mode
>initialization.
>
> 2. message-mode-hook gets invoked twice - first when message-mail
>invokes message-mode and second when notmuch-mua-mail invokes
>notmuch-message-mode.
>
> This commit fixes these problems by replacing a call to message-mail
> with notmuch-specific code that is (hopefully) equivalent to
> message-mail functionality before introduction of
> notmuch-message-mode.
>
> We first initialize notmuch-message-mode with
> notmuch-mua-pop-to-buffer, which is a modified version of
> message-pop-to-buffer and then call message-setup-1, which is the only
> functionality of message-mail that is needed for notmuch.

This doesn't break anything for me, and looks fairly sane. I'm not sure
if the indirectrion of notmuch-mua-get-switch-function is still needed,
but that can wait for an optional followup patch. 
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] test: Always use paths without symlinks

2015-12-30 Thread David Bremner
Michal Sojka  writes:


>
> This commit makes all paths in test scripts physical. With it, all
> tests pass even when run from a symlinked directory.

pushed.

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


Re: [Patch v3 3/8] cli: let the user know which protocol is unknown or unsupported

2015-12-30 Thread David Bremner
David Bremner  writes:

> From: Jani Nikula 
>
> The current error message is not helpful.

pushed the first 3 patches in this series

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


Re: [PATCH v2] test: Unset ALTERNATE_EDITOR before running emacsclient

2015-12-30 Thread David Bremner
Michal Sojka  writes:

> ALTERNATE_EDITOR causes emacsclient to run an alternate editor if the
> emacs server is not ready. This can collide with intended
> functionality in test-lib.sh.
>

pushed,

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


Re: [RFC 1/5] cli: fix function name in notmuch new debug logging

2015-12-30 Thread David Bremner
Jani Nikula  writes:

> add_files_recursive has been renamed add_files long ago.

pushed,

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