Skip to content

Allow for tags with whitespaces and special characters#30

Draft
digitalsignalperson wants to merge 1 commit intoakissinger:masterfrom
digitalsignalperson:tagfixing
Draft

Allow for tags with whitespaces and special characters#30
digitalsignalperson wants to merge 1 commit intoakissinger:masterfrom
digitalsignalperson:tagfixing

Conversation

@digitalsignalperson
Copy link

Here's an attempt to solve #29

I've tested

  • see correct [read/unread] counts for tags like/this in the tag panel
  • double clicking a tag in the tag panel correctly gives the search results for that tag
  • the tag in the search query itself is excluded from the shows tags

Not tested:

  • adding/removing tags
  • command bar
  • probably some other things I'm unfamiliar with since I haven't fully explored all the features in dodo yet. I'm mainly using as a read-only interface for now as I get used to things.

import email
import email.message
import tempfile
import shlex
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:shop might 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants