jschlatow / taskopen

Tool for taking notes and open urls with taskwarrior
GNU General Public License v2.0
364 stars 31 forks source link

Change default file regex #105

Closed Nicop06 closed 7 years ago

Nicop06 commented 7 years ago

The file regex was conflicting with my custom command of the form:

CUSTOM1_REGEX=protocol://123456
CUSTOM1_CMD=protocol-handler.sh

Maybe a better way would be to evaluate custom commands before the file regex? If that's the case, I will change my pull request.

jschlatow commented 7 years ago

@Nicop06, thanks for your contribution and I'd like to include a patch for this issue. Unfortunately, I'm afraid your patch is not the correct way to approach this. Let me elaborate on this:

Currently, taskopen already adds the ^ anchor to every regex. On the one hand, this has a benefit in readability. On the other hand, this simplifies the implementation of the label feature. This feature allows predixing any annotation with a labelname:. This feature is also the cause of your troubles. In your case protocol: is interpreted as the label and //123456 as the file. Edit: actually not (see below)

The only solution I can come up with at the moment is to enforce a space after the labelname:. There might also be the possiblity to play with greedy/non-greedy matching when extracting the labelname. Honestly, I haven't tried reproducing your problem yet and am not 100% sure at which point it breaks.

Regarding your suggestion of changing the order of evaluation: I see that in certain cases this would simplify things (although not fix your problem). However, I'm always hesitant to change the behaviour of taskopen in such a way. Nevertheless, I could imagine to make the evaluation order configurable by the user.

jschlatow commented 7 years ago

Actually, I was wrong.

Can you give the commit https://github.com/ValiValpas/taskopen/commit/610c25efd6112262212a6163973dceb53f3b8599 a try?

Nicop06 commented 7 years ago

I pulled the your devel branch and remove the FILE_REGEX entry from my taskopenrc and it seems to work, although I am remotely connected to my work laptop so I will need to check again tomorrow. Thanks for fixing this bug so quickly.

Basically, the urls I open with taskopen correspond to a bug record from our internal bug tracking tool. These url can be directly opened with firefox, which will then call a script that will call again firefox with the actual http url of the report, but this will leave an empty tab. Calling directly the script from taskopen was a much better solution.

However, there might be an even better way. I will try to set up bugwarrior to automatically synchronize my tasks (for jira at first, and I might add support for our bug tacking tool later). A cool feature for taskopen would be to read the custom attributes added by bugwarrior and open the corresponding url. If you think this is a useful feature, I can open a pull request with the changes one its done.

In the meanwhile, I am closing this pull request.

jschlatow commented 7 years ago

@Nicop06 feel free to create further pull requests. I always appreciate valuable contributions such as new features or usability improvements.