File: indmac.sl

package info (click to toggle)
lurkftp 1.00-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 324 kB
  • ctags: 375
  • sloc: ansic: 4,551; sh: 186; makefile: 162
file content (122 lines) | stat: -rw-r--r-- 1,861 bytes parent folder | download | duplicates (2)
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
% Jed C-Mode enhancement for indenting multi-line macros
% Still slightly buggy, but it works well enough for me..
%  - dark@mama.indstate.edu -

define indmac ()
{
    variable numlines;

    push_spot();
    EXIT_BLOCK
    {
	pop_spot();
    }
    bol();
    !if (looking_at("#define"))
      return;
    eol();
    go_left_1();
    !if(looking_at_char('\\'))
      return;
    eol();
    insert(" \n{");
    go_down_1();
    eol();
    go_left_1();
    numlines = 0;
    while(looking_at_char('\\')) {
	++numlines;
	c_indent_line();
	eol();
	go_left_1();
	del();
	trim();
	go_down_1();
	eol();
	go_left_1();
    }
    pop_spot();
    push_spot();
    eol(); trim();
    go_down_1();
    bol();
    del_through_eol();
    go_up_1();
    loop(numlines) {
	go_down_1();
	eol();
	insert(" \\");
    }
}

define do_c_indent()
{
    push_spot();
    while(up_1()) {
	eol(); trim();
	!if(bolp())
	  go_left_1();
	!if(looking_at_char('\\')) {
	    go_down_1();
	    break;
	}
    }
    bol();
    if (looking_at("#define")) {
	indmac();
	pop_spot();
	push_spot();
	eol();
	go_left_1();
	while(looking_at_char('\\')) {
	    go_down_1();
	    eol();
	    go_left_1();
	}
	bol_skip_white();
	pop_spot();
    } else {
	pop_spot();
	c_indent_line();
    }
}

define do_c_indent_nl()
{
    variable did_up = 0;

    push_spot();
    do {
	eol(); trim();
	!if(bolp())
	  go_left_1();
	!if(looking_at_char('\\')) {
	    if(did_up)
	      go_down_1();
	    break;
	}
	did_up = 1;
    } while(up_1());
    bol();
    if (looking_at("#define")) {
	push_mark();
	pop_spot();
	newline();
	push_spot();
	insert(";\\");
	pop_mark_1();
	indmac();
	pop_spot();
	skip_white();
	del();
    } else {
	pop_spot();
	c_newline_and_indent();
    }
}

define c_mode_hook ()
{
    set_buffer_hook("indent_hook", "do_c_indent");
    set_buffer_hook("newline_indent_hook", "do_c_indent_nl");
}