1%!%+ 2%\function{text_indent_relative} 3%\synopsis{Indent to next indentation point} 4%\description 5% The \var{text_indent_relative} function inserts enough whitespace to move 6% the editing point to the next indentation level defined by the whitespace 7% pattern of the previous non-blank line. If the current point is beyond 8% the last indentation level of the reference line, then a literal TAB will 9% be inserted into the buffer. 10%\seealso{set_buffer_hook, newline_and_indent} 11%!%- 12public define text_indent_relative () 13{ 14 variable c0, c; 15 16 push_spot (); 17 c0 = what_column (); 18 bol (); 19 bskip_chars ("\n\t "); 20 if (bobp ()) 21 { 22 pop_spot (); 23 insert ("\t"); 24 return; 25 } 26 27 c = goto_column_best_try (c0); 28 skip_white (); 29 30 if (c == what_column ()) 31 { 32 skip_chars ("^ \t\n"); 33 skip_white (); 34 } 35 36 c = what_column (); 37 pop_spot (); 38 if (c <= c0) 39 { 40 insert ("\t"); 41 return; 42 } 43 whitespace (c - c0); 44} 45 46define text_newline_and_indent_relative () 47{ 48 push_spot (); 49 bol_skip_white (); 50 variable skip_indent = bolp (); 51 pop_spot (); 52 newline (); 53 if (skip_indent) 54 return; 55 indent_line (); 56} 57 58$1 = "Text"; 59!if (keymap_p ($1)) make_keymap ($1); 60definekey ("indent_line", "\t", $1); 61 62%!%+ 63%\function{text_mode} 64%\synopsis{text_mode} 65%\description 66% Mode for indenting and wrapping text 67% Functions that affect this mode include: 68% 69%#v+ 70% Function: Default Binding: 71% text_indent_relative TAB 72% newline_and_indent RETURN 73% format_paragraph ESC Q 74% narrow_paragraph ESC N 75%#v- 76% 77%\seealso{no_mode, c_mode, set_buffer_hook} 78%\seealso{WRAP_INDENTS, WRAP, TAB, TAB_DEFAULT} 79%!%- 80public define text_mode() 81{ 82 variable mode = "Text"; 83 no_mode (); 84 set_mode(mode, 1); 85 use_keymap (mode); 86 %set_buffer_hook ("indent_hook", "text_indent_relative"); 87 %set_buffer_hook ("newline_indent_hook", "text_newline_and_indent_relative"); 88 unset_buffer_hook ("indent_hook"); 89 unset_buffer_hook ("newline_indent_hook"); 90 run_mode_hooks ("text_mode_hook"); 91} 92