1% This is a simple shell mode. It does not defined any form of indentation 2% style. Rather, it simply implements a highlighting scheme. 3 4$1 = "SH"; 5 6create_syntax_table ($1); 7define_syntax ("#", "", '%', $1); 8define_syntax ("([{", ")]}", '(', $1); 9 10% Unfortunately, the editor cannot currently correctly deal with multiple 11% string characters. So, inorder to handle something like: 12% echo "I'd rather be home" 13% make the '"' character the actual string character but also give '\'' 14% a string syntax. However, this will cause '"' to give problems but 15% usually, '"' characters will be paired. 16define_syntax ('\'', '"', $1); 17define_syntax ('"', '"', $1); 18 19define_syntax ('\\', '\\', $1); 20define_syntax ("-0-9a-zA-Z_", 'w', $1); % words 21define_syntax ("-+0-9", '0', $1); % Numbers 22define_syntax (",;:", ',', $1); 23define_syntax ("%-+/&*=<>|!~^", '+', $1); 24 25#ifdef HAS_DFA_SYNTAX 26%%% DFA_CACHE_BEGIN %%% 27private define setup_dfa_callback (name) 28{ 29 dfa_enable_highlight_cache ("shmode.dfa", name); 30 dfa_define_highlight_rule ("\\\\.", "normal", name); 31 dfa_define_highlight_rule ("#.*$", "comment", name); 32 dfa_define_highlight_rule ("\"([^\\\\\"]|\\\\.)*\"", "string", name); 33 dfa_define_highlight_rule ("\"([^\\\\\"]|\\\\.)*$", "string", name); 34 dfa_define_highlight_rule ("'[^']*'", "string", name); 35 dfa_define_highlight_rule ("'[^']*$", "string", name); 36 dfa_define_highlight_rule ("[\\|&;\\(\\)<>]", "Qdelimiter", name); 37 dfa_define_highlight_rule ("[\\[\\]\\*\\?]", "Qoperator", name); 38 dfa_define_highlight_rule ("[^ \t\"'\\\\\\|&;\\(\\)<>\\[\\]\\*\\?]+", 39 "Knormal", name); 40 dfa_define_highlight_rule (".", "normal", name); 41 dfa_build_highlight_table (name); 42} 43dfa_set_init_callback (&setup_dfa_callback, "SH"); 44%%% DFA_CACHE_END %%% 45#endif 46 47() = define_keywords ($1, "cddofiifin", 2); 48() = define_keywords ($1, "forletpwdset", 3); 49() = define_keywords ($1, "casedoneechoelifelseesacevalexitifeqreadtestthentype", 4); 50() = define_keywords ($1, "aliasbreakendifendswifdefifneqlocalshiftumaskunsetuntilwhile", 5); 51() = define_keywords ($1, "exportifndefreturnsetenvsourceswitch", 6); 52() = define_keywords ($1, "breaksw", 7); 53() = define_keywords ($1, "continuefunction", 8); 54 55define sh_mode () 56{ 57 set_mode("SH", 0); 58 use_syntax_table ("SH"); 59 mode_set_mode_info ("SH", "fold_info", "#{{{\r#}}}\r\r"); 60 run_mode_hooks("sh_mode_hook"); 61} 62 63