On Mon, Oct 18, 2010 at 3:46 PM, Edward K. Ream <[email protected]> wrote:

> I suspect the only way would be to add a new rule to the rulesets for
> all (or a set of) languages.  The rule would use the match_seq_regexp
> method to specify regex.

Adding the following to modes/python.py works:

h_url_regex = r"""(http|https)://[^\s'"]+[\w=/]"""
f_url_regex = r"""(file|ftp)://[^\s'"]+[\w=/]"""

def python_rule_h_url(colorer, s, i):
    return colorer.match_seq_regexp (s,i,kind="keyword",regexp=h_url_regex,
        at_line_start = False,at_whitespace_end = False,at_word_start
= False,delegate = "")

def python_rule_f_url(colorer,s,i):
    return colorer.match_seq_regexp (s,i,kind="keyword",regexp=f_url_regex,
        at_line_start = False,at_whitespace_end = False,at_word_start
= False,delegate = "")

These must be connected as follows in rulesDict1:

"F": [python_rule_f_url,python_rule21,],
"H": [ python_rule_h_url,python_rule21,],

"f": [python_rule_f_url,python_rule21,],
"h": [ python_rule_h_url,python_rule21,],

The order of rules is important: python_rule21 calls
colorer.match_keywords. There is
a hack that fails immediately if match_keywords fails.  So the "url
rules" must appear first.

It would be possible for the detect_urls plugin to make such patches
automatically, but doing so might be tricky.  It's an initialization
problem and such problems are particularly severe for the qt
colorizer.

Before going further, it would be good to know the languages for which
you need the detect_urls capability.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to