% Fishell mode with syntax highlighting and indentation. % Put something like this into your .jedrc: % % add_mode_for_extension ("fishell", "sh"); % autoload ("prolog_mode","/home/andre/src/s-lang/fishell.sl"); % % Indentation is based on matching against the end of lines so this is % where you will want your delimiters. % % $Log:$ % % Author: Andre Rognes % % % Copyright (c) 2003, Andre Rognes % All rights reserved. % % This program is free software; you can redistribute it and/or modify it % under the terms of the GNU General Public License as published by the Free % Software Foundation; either version 2 of the License, or (at your option) % any later version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for % more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., 675 % Mass Ave, Cambridge, MA 02139, USA. message ("Reading Fishell Syntax_table"); $1 = "Fishell"; !if (keymap_p ($1)) make_keymap ($1); % definekey ("indent_line", "\t", $1); create_syntax_table ("Fishell"); define_syntax ("#", "", '%', "Fishell"); % comments define_syntax ("{", "}", '(', "Fishell");% delimiters define_syntax ('"', '"', "Fishell"); % Fishell strings define_syntax ('\'', '\'', "Fishell"); % Fishell atoms or 0'x: No! define_syntax ('\\', '\\', "Fishell"); define_syntax ("a-zA-Z0-9_", 'w', "Fishell"); % words define_syntax (".!,;:^*/<>=-+@\\", ',', "Fishell"); set_syntax_flags ("Fishell", 0); % And Commonly Used Fishell Predicates % Type 0 keywords () = define_keywords_n ("Fishell","cdpl",2,1); () = define_keywords_n ("Fishell","mapouttcl",3,1); () = define_keywords_n ("Fishell","exitopenpipe",4,1); () = define_keywords_n ("Fishell","closeopenaopenrshellsplitsubstunify",5,1); () = define_keywords_n ("Fishell","buffersocketsourceunconc",6,1); () = define_keywords_n ("Fishell","numericunchain",7,1); () = define_keywords_n ("Fishell","chainmodecharclass",9,1); % Fishell Arithmetic Functions. % Type 1 keywords () = define_keywords_n ("Fishell","cd",2,0); () = define_keywords_n ("Fishell","case",4,0); () = define_keywords_n ("Fishell","sourceuncase",6,0); define lp_reset_point () { push_mark (); bskip_white (); if (bolp ()) { skip_white (); pop_mark_0 (); } else pop_mark_1 (); } define lp_column_line_arr(lines) { variable i,str,col; col = 0; foreach (lines) { str = (); str = strcompress(str," \t\f\r\n"); if (str == "}") continue; % the initial } if (string_match(str,"^#",1)) continue; %this line is a comment if (string_match(str,"{$",1)) col += TAB; if (string_match(str,"}$",1)) col -= TAB; } return col; } define lp_column() { variable val,str,lines; bol(); push_spot(); push_mark(); if (re_bsearch("}[ \t\f\r]*$") == 0) bob(); str = bufsubstr(); lines = strchop(str,'\n',0); pop_mark_0(); pop_spot(); return lp_column_line_arr(lines); } define lp_indent_line () { variable col; push_spot (); col = lp_column(); bol_skip_white (); bol_trim (); whitespace (col); pop_spot (); lp_reset_point(); } define fishell_mode () { variable mode = "Fishell"; set_mode (mode, 0x4); set_buffer_hook("indent_hook","lp_indent_line"); use_keymap (mode); use_syntax_table (mode); mode_set_mode_info (mode, "fold_info", "%{{{\r%}}}\r\r"); run_mode_hooks("fishell_mode_hook"); }