AnthonyDiGirolamo / todotxt-machine

an interactive terminal based todo.txt file editor with an interface similar to mutt
https://pypi.python.org/pypi/todotxt-machine/
GNU General Public License v3.0
245 stars 37 forks source link

E-mail addresses being picked up as contexts #2

Closed darrenkenny closed 10 years ago

darrenkenny commented 10 years ago

Really like this, but one thing I've noticed the first time I used it is that I have some todo items with e-mail addresses in them, and they are getting picked up as contexts.

Maybe it's the regexp that is used, but you should be able to assume that either the context is at the start/end of the line, or if not, then it has to have a whitespace before it.

Taking a quick look, you have a regex which is :

_context_regex       = re.compile(r'\s*(@\S+)\s*')

This might work better as:

_context_regex       = re.compile(r'(?:^|\s+)(@\S+)(?:\s+|$)')

Possibly, \S is also too 'open' in that it should be \w, in that it's a character that makes up a word (specifically [a-zA-Z0-9_])?

Thanks for doing, this!

AnthonyDiGirolamo commented 10 years ago

Hi Darren,

Thanks for catching this! I exposed it with a test and updated the regexes for projects and contexts. I agree \S might be too open but I'll leave it for now. Some folks might like to use odd characters in their projects/contexts.

darrenkenny commented 10 years ago

No problem - I think the tool looks really good - been looking for something like it for a while now... Just never got around to writing one myself :(

On 8 November 2013 16:08, Anthony DiGirolamo notifications@github.comwrote:

Hi Darren,

Thanks for catching this! I exposed it with a test and updated the regexes for projects and contexts. I agree \S might be too open but I'll leave it for now. Some folks might like to use odd characters in their projects/contexts.

— Reply to this email directly or view it on GitHubhttps://github.com/AnthonyDiGirolamo/todotxt-machine/issues/2#issuecomment-28074277 .