Sublime Forum

Help with SublimeLinter

#1

Disclaimer: I hope it’s okay to post this here, but neither my support request on the SublimeLinter repository, nor the my question on StackOverflow, was ever answered. I was hoping someone familiar with Sublime Text might be able to help.

A couple of months ago, I have released my first SublimeLinter plugin for makensis. It currently has limited functionality, since it only reports errors and no warnings. Commenting out one line and uncommenting another, I can make it work for warnings, but then it will not report errors.

regex = (
        # r'(?P<warning>warning): (?P<message>.*) \(.*:(?P<line>\d+)\)'
        r'(?P<message>[^\r?\n]+)\r?\n(?P<error>Error) in script "[^"]+" on line (?P<line>\d+) -- aborting creation process$'
    )

I don’t know the technically correct term for this RegEx flavour, but the problem seems to be that I can’t use those named matches, e.g. (?P<message>.*), more than once, which is why a combined RegEx for errors and warnings does not work.

Can anybody explain to me how I can provide two patterns, one for errors and one for warnings?

0 Likes

#2

It’s fine to post this here, imo at least.

Taking a look into the documentation, it seems like you must provide exactly one pattern but don’t have to use the “message” capturing group

Actually the pattern doesn’t have to have these named capture groups, but if it doesn’t you must override the split_match method and provide those values yourself.

So you can combine the patterns, name one of the message groups “message2” and deduce that in the split_match method.

1 Like