/usr/share/jed/lib/matlab.sl is in jed-common 1:0.99.19-2.1.
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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | % matlab.sl -*- SLang -*-
%
% This file provides a mode for editing Matlab/Octave files.
%
% Written by Guido Gonzato <guido@ibogeo.df.unibo.it>
% Very simple, but it works.
% Last updated: 19 May 1999
$1 = "matlab";
!if (keymap_p ($1)) make_keymap ($1);
% very few facilities at the moment: simple syntax highlighting,
% indent, and comment/uncomment.
definekey ("matlab_comment", "\e;", $1);
definekey ("matlab_uncomment", "\e:", $1);
% Now create and initialize a simple syntax table.
create_syntax_table ($1);
define_syntax ("%", "", '%', $1); % comments (doesn't work)
define_syntax ("#", "", '%', $1); % comments -- Octave
define_syntax ("([{", ")]}", '(', $1); % parentheses
define_syntax ('"', '"', $1); % strings
define_syntax ('\\', '\\', $1); % escape character
define_syntax ("0-9a-zA-Z_", 'w', $1); % identifiers
define_syntax ("0-9a-fA-F.xXL", '0', $1); % numbers
define_syntax (",;", ',', $1); % delimiters
define_syntax ("!&+-.*^;<>\|~='/:", '+', $1); % operators
set_syntax_flags ($1, 4);
% Matalb/Octave reserved words. Are there more?
() = define_keywords_n ($1, "cdifls", 2, 0);
() = define_keywords_n ($1, "direndforsettrywho", 3, 0);
() = define_keywords_n ($1, "caseechoelsegsethdirhelpholdloadmoresaveshowtypewhos", 4, 0);
() = define_keywords_n ($1, "breakcatchcleardiaryendifgplotgshowwhichwhile", 5, 0);
() = define_keywords_n ($1, "elseifendforformatglobalgsplotreturnswitch", 6, 0);
() = define_keywords_n ($1, "casesenhistory", 7, 0);
() = define_keywords_n ($1, "continueendwhilefunction", 8, 0);
() = define_keywords_n ($1, "endswitch", 9, 0);
() = define_keywords_n ($1, "all_va_argsendfunctionrun_history", 11, 0);
() = define_keywords_n ($1, "edit_history", 12, 0);
() = define_keywords_n ($1, "end_try_catch", 13, 0);
() = define_keywords_n ($1, "unwind_protect", 14, 0);
() = define_keywords_n ($1, "end_unwind_protect", 18, 0);
() = define_keywords_n ($1, "unwind_protect_cleanup", 22, 0);
variable Matlab_Continue_Char = "\\";
variable Matlab_Indent = 2;
% Matlab indent routine.
define matlab_indent ()
{
variable goal = 1;
variable cs = CASE_SEARCH;
variable ch;
% goto beginning of line and skip past continuation char
USER_BLOCK0
{
bol ();
skip_chars (" \t");
if (looking_at(Matlab_Continue_Char)) go_right_1 ();
skip_white ();
}
push_spot ();
push_spot ();
CASE_SEARCH = 1; % Octave is case sensitive
while (up_1 ())
{
bol_skip_white();
if (eolp() or looking_at(Matlab_Continue_Char)) continue;
X_USER_BLOCK0 ();
goal = what_column ();
if (looking_at("switch"))
goal += 2 * Matlab_Indent; % to account for 'case'
if (looking_at ("if ") or looking_at ("if(") or
looking_at ("case") or
looking_at ("otherwise") or
looking_at ("while") or
looking_at ("for ") or
looking_at ("else") or looking_at ("elseif") or
looking_at ("unwind_protect_cleanup") or
looking_at ("unwind_protect") or
looking_at ("try") or looking_at ("catch") or
looking_at ("function") )
goal += Matlab_Indent;
break;
}
% now check the current line
pop_spot ();
push_spot ();
X_USER_BLOCK0 ();
if (looking_at ("endswitch"))
goal -= 2 * Matlab_Indent;
if (looking_at ("end") or
looking_at ("endif") or
looking_at ("case") or
looking_at ("endwhile") or
looking_at ("endfor") or
looking_at ("end_try_catch") or
looking_at ("unwind_protect_cleanup") or
looking_at ("end_unwind_protect") or
looking_at ("else") or
looking_at ("endfunction") )
goal -= Matlab_Indent;
CASE_SEARCH = cs; % done getting indent
if (goal < 1) goal = 1;
pop_spot ();
bol_skip_white ();
ch = char(what_char());
bol_trim ();
goal--;
insert_spaces (goal);
pop_spot ();
skip_white ();
} % matlab_indent
define matlab_newline ()
{
if (bolp ())
{
newline ();
return;
}
matlab_indent ();
newline ();
matlab_indent ();
}
% Matlab comment routines.
define matlab_is_comment ()
{
bol ();
skip_chars (" \t0-9");
bolp () and not (eolp());
}
define matlab_uncomment ()
{
push_spot ();
if (matlab_is_comment ())
{
bol ();
if (looking_at ("%") | looking_at("#"))
deln (1);
else del ();
}
matlab_indent ();
pop_spot ();
go_down_1 ();
}
define matlab_comment ()
{
!if (matlab_is_comment ())
{
push_spot_bol ();
insert ("%");
}
pop_spot ();
go_down_1 ();
}
%!%+
%\function{matlab_mode}
%\synopsis{matlab_mode}
%\description
% Protoytype: Void matlab_mode ();
% This is a mode that is dedicated to facilitate the editing of
% Matlab/Octave language files.
% Functions that affect this mode include:
%#v+
% function: default binding:
% matlab_indent RETURN
%#v-
% Variables affecting indentation include:
% Hooks: \var{matlab_mode_hook}
%!%-
define matlab_mode ()
{
variable kmap = "matlab";
set_mode(kmap, 2);
use_keymap(kmap);
use_syntax_table (kmap);
set_buffer_hook ("indent_hook", "matlab_indent");
set_buffer_hook ("newline_indent_hook", "matlab_newline");
run_mode_hooks("matlab_mode_hook");
}
% --- End of file matlab.sl ---
|