Allow for tags with whitespaces and special characters#30
Allow for tags with whitespaces and special characters#30digitalsignalperson wants to merge 1 commit intoakissinger:masterfrom
Conversation
| import email | ||
| import email.message | ||
| import tempfile | ||
| import shlex |
There was a problem hiding this comment.
oops this should be in util.py instead
| # print(cmd) | ||
| return cmd | ||
|
|
||
| def format_tag_args(tag_expr: str=None, tags_add: list=None, tags_remove: list=None) -> list: |
There was a problem hiding this comment.
This seems wrong. Additional quotes actually passed to notmuch are only required when a shell is involved, but this isn't the case here. I'm pretty sure this would now add the tags with the quotes, like doing '+"foo bar"' in a shell. No such quotes are needed when not using shell=True, at least for notmuch tag.
There was a problem hiding this comment.
Thanks for the review. I'll have to test this out. What you say makes sense I could see it adding the double quotes to the tags themselves. Yet in search and tag view I definitely needed the double quotes for some parts. I can review the different cases and print what the actual commands being sent to notmuch are and if they work as expected.
As noted I still haven't tested adding/removing tags, just mainly search and tag view. Also furthering that in #31
so still some testing to do
There was a problem hiding this comment.
For a query, that's true - from what I understand, that uses Xapian query syntax, which needs literal quotes:
Phrase searches
A phrase surrounded with double quotes (
"") matches documents containing that exact phrase. [...]Searching within a free-text field
If the database has been indexed with prefixes on terms generated from certain free-text fields, you can set up a prefix map so that the user can search within those fields. For example
author:dickens title:shopmight find documents by dickens with shop in the title. You can also specify a prefix on a quoted phrase (e.g.author:"charles dickens") [...]
Compare that to shell usage, where notmuch tag '+foo bar' tag:test adds the tag foo bar to a message (passing the argument +foo bar to notmuch), but then to find it, notmuch search tag:"foo bar" won't work, you'll need notmuch search 'tag:"foo bar"' (passing a literal tag:"foo bar" to notmuch/Xapian).
Here's an attempt to solve #29
I've tested
tags like/thisin the tag panelNot tested: