From 936d95b3786e2dfa76bf5e5f988ce12e883fcb89 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Tue, 28 Jul 2015 19:00:28 +0000 Subject: [PATCH] make r_lang probe more restrictive, fixed small issues --- rlang.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rlang.c b/rlang.c index d233753..e13c5be 100644 --- a/rlang.c +++ b/rlang.c @@ -93,7 +93,7 @@ static void r_colorize_line(QEColorizeContext *cp, case '%': for (j = i; qe_isalpha(str[j]); j++) continue; - if (str[j] == '%') { + if (j > i && str[j] == '%') { i = j + 1; style = R_STYLE_KEYWORD; break; @@ -161,7 +161,7 @@ static void r_colorize_line(QEColorizeContext *cp, style = R_STYLE_ARGDEF; break; } - if (str[j] == '=') { + if (str[j] == '=' && str[j + 1] != '=') { style = R_STYLE_ARGNAME; break; } @@ -185,11 +185,22 @@ static void r_colorize_line(QEColorizeContext *cp, cp->colorize_state = colstate; } +static int r_mode_probe(ModeDef *mode, ModeProbeData *p) +{ + /* check file name or extension */ + if (match_extension(p->filename, mode->extensions) + && !(p->buf[0] == '/' && p->buf[1] == '*')) + return 80; + + return 1; +} + static ModeDef r_mode = { .name = "R", .extensions = "R", .keywords = r_keywords, .types = r_types, + .mode_probe = r_mode_probe, .colorize_func = r_colorize_line, };