1% Lisp mode 2 3$1 = "LISP"; 4create_syntax_table ($1); 5define_syntax ("([", ")]", '(', $1); 6define_syntax (";", "", '%', $1); 7define_syntax ('"', '"', $1); 8define_syntax ('\\', '\\', $1); 9 10define_syntax ("0-9a-zA-Z_", 'w', $1); % words 11define_syntax ("-+0-9", '0', $1); % Numbers 12% define_syntax ("", ',', $1); % Delimiters 13define_syntax ('#', '#', $1); % preprocessor 14% define_syntax ("%-+/&*=<>|!~^", '+', $1); % binary operators 15 16() = define_keywords ($1, "eqifor", 2); 17() = define_keywords ($1, "letnot", 3); 18() = define_keywords ($1, "setq", 4); 19() = define_keywords ($1, "defunprognwhile", 5); 20 21define lisp_indent_line () 22{ 23 variable val, col; 24 push_spot (); 25 bol (); 26 val = find_matching_delimiter (')'); 27 col = what_column (); 28 if (val == 1) col += 3; 29 pop_spot (); 30 push_spot (); 31 bol_skip_white (); 32 if (col != what_column ()) 33 { 34 bol_trim (); 35 col--; whitespace (col); 36 } 37 pop_spot (); 38 push_mark (); 39 bskip_white (); 40 if (bolp ()) 41 { 42 skip_white (); 43 pop_mark_0 (); 44 } 45 else pop_mark_1 (); 46} 47 48define lisp_mode () 49{ 50 set_mode("lisp", 2); 51 set_buffer_hook ("indent_hook", "lisp_indent_line"); 52 use_syntax_table ("LISP"); 53 runhooks ("lisp_mode_hook"); 54} 55