/usr/share/jed/jed-extra/extra/custmode.sl is in jed-extra 2.5.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | % Created : 08 Oct 2004
% Author : Marko Mahnic
%
% Create a custom syntax table for the current buffer.
% The syntax is defined after the modeline.
% Each custom_mode buffer creates its own syntax table named custom_N.
% The name of the syntax table is stored in a buffer-local variable.
%
%
%
%
require ("keywords");
static variable custom_syn="custom";
static variable blvar_modename="custom_mode";
static variable blvar_modeflgs="custom_flags";
static variable custom_count = 0;
static define extract_eol(eq_char)
{
() = ffind_char(eq_char);
go_right(1);
push_mark();
eol();
return strtrim(bufsubstr());
}
static define extract_char(eq_char)
{
() = ffind_char(eq_char);
go_right(1);
skip_white();
return what_char();
}
static define prepare_syntax_table(modename)
{
variable n = 0, kwds1 = NULL, kwds2 = NULL;
variable modeflags = 2;
variable kwdflags;
create_syntax_table(modename);
bob();
n = re_fsearch ("-\\*- *mode: *custom");
if (n < 1) return;
if (what_line() > 4) return;
go_down(1);
bol();
n = ffind ("###");
while (n)
{
go_right(3);
skip_white();
if (looking_at("%"))
{
if (looking_at("%keywords1="))
{
if (kwds1 == NULL) kwds1 = keywords->new_keyword_list ();
keywords->add_keywords (kwds1, extract_eol('='));
}
else if (looking_at("%keywords2="))
{
if (kwds2 == NULL) kwds2 = keywords->new_keyword_list ();
keywords->add_keywords (kwds2, extract_eol('='));
}
else if (looking_at("%words=")) define_syntax (extract_eol('='), 'w', modename);
else if (looking_at("%numbers=")) define_syntax (extract_eol('='), '0', modename);
else if (looking_at("%commenteol=")) define_syntax (extract_eol('='), "", '%', modename);
else if (looking_at("%string1=")) define_syntax (extract_char('='), '\'', modename);
else if (looking_at("%string2=")) define_syntax (extract_char('='), '\"', modename);
else if (looking_at("%preprocessor=")) define_syntax (extract_char('='), '#', modename);
else if (looking_at("%quote=")) define_syntax (extract_char('='), '\\', modename);
else if (looking_at("%parens="))
{
variable parens = extract_eol('=');
variable len = strlen(parens);
if ((len > 1) and ((len mod 2) == 0) )
define_syntax (substr(parens, 1, len/2), substr(parens, len/2+1, len/2), '(', modename);
}
else if (looking_at("%modeflags="))
{
kwdflags = strlow(extract_eol('='));
modeflags = 0;
if (is_substr(kwdflags, "wrap")) modeflags |= 0x01;
if (is_substr(kwdflags, "c")) modeflags |= 0x02;
if (is_substr(kwdflags, "language")) modeflags |= 0x04;
if (is_substr(kwdflags, "slang")) modeflags |= 0x08;
if (is_substr(kwdflags, "fortran")) modeflags |= 0x10;
if (is_substr(kwdflags, "tex")) modeflags |= 0x20;
}
else if (looking_at("%syntaxflags="))
{
kwdflags = strlow(extract_eol('='));
variable syntax = 0;
if (is_substr(kwdflags, "nocase")) syntax |= 0x01;
if (is_substr(kwdflags, "comfortran")) syntax |= 0x02;
if (is_substr(kwdflags, "nocmodeldspc")) syntax |= 0x04;
if (is_substr(kwdflags, "tex")) syntax |= 0x08;
if (is_substr(kwdflags, "comeolspc")) syntax |= 0x10;
if (is_substr(kwdflags, "preprocline")) syntax |= 0x20;
if (is_substr(kwdflags, "preprocldspc")) syntax |= 0x40;
if (is_substr(kwdflags, "nostrspan")) syntax |= 0x80;
set_syntax_flags(modename, syntax);
}
}
go_down(1);
if (eobp()) break;
bol();
n = ffind ("###");
}
if (kwds1 != NULL)
{
keywords->sort_keywords(kwds1);
if (syntax & 0x01) keywords->strlow_keywords(kwds1);
keywords->define_keywords(kwds1, modename, 0);
}
if (kwds2 != NULL)
{
keywords->sort_keywords(kwds2);
if (syntax & 0x01) keywords->strlow_keywords(kwds1);
keywords->define_keywords(kwds2, modename, 1);
}
return modeflags;
}
% --------------------------------------------------------------
% Main entry
%
public define custom_mode ()
{
variable custom_id, modename, modeflags = 2;
if (blocal_var_exists(blvar_modename))
{
modename = get_blocal_var(blvar_modename);
}
else
{
create_blocal_var(blvar_modename);
modename = sprintf("%s_%d", custom_syn, custom_count);
set_blocal_var(modename, blvar_modename);
custom_count++;
modeflags = prepare_syntax_table(modename);
create_blocal_var(blvar_modeflgs);
set_blocal_var(modeflags, blvar_modeflgs);
}
if (blocal_var_exists(blvar_modeflgs))
modeflags = get_blocal_var(blvar_modeflgs);
set_mode(modename, modeflags);
use_syntax_table(modename);
}
|