adsr/mle

How do I make my own syntax have precedence over syn_generic?

hovsater opened this issue · 2 comments

I've setup my own syntax for Ruby. But whenever I open a Ruby file, syn_generic kicks in and I have to do M-o y, syn_ruby to switch the syntax to what I want. Both syntaxes are matching Ruby files.

I found this in the source

mle/bview.c

Lines 628 to 635 in eb37d13

} else if (self->buffer->path) {
// Set by path
HASH_ITER(hh, self->editor->syntax_map, syntax, syntax_tmp) {
if (util_pcre_match(syntax->path_pattern, self->buffer->path, strlen(self->buffer->path), NULL, NULL)) {
use_syntax = syntax;
break;
}
}

I guess since syn_generic is registered first and is matching Ruby files as well, it will always be chosen over any customisations. Is that right?

adsr commented

Ah yes, good catch! Let's see if we can iterate in reverse so that later syntaxes take priority.

adsr commented

Let me know how that works for you @KevinSjoberg. Thanks again.