/usr/share/jed/lib/cmisc.sl is in jed-common 1:0.99.19-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | %
% Miscellaneous functions for C mode:
%
% c_make_comment ()
% c_format_paragraph ()
% c_comment_region ()
% c_top_of_function ()
% c_end_of_function ()
% c_mark_function ()
% produce a comment for C---
define c_make_comment ()
{
variable d, cbeg, cend, file, mode;
cbeg = "/*";
cend = "*/";
(, mode) = what_mode ();
!if (mode & 2) return;
(file,,,) = getbuf_info();
if (mode & 8)
{
cbeg = "%";
cend = "";
}
%% search for a comment on the line
eol();
if (bfind(cbeg))
{
!if (bolp())
{
go_left_1 ();
trim();
() = ffind(cbeg);
}
d = C_Comment_Column - what_column;
if (d > 0) whitespace(d);
!if (ffind(cend))
{
eol();
insert_spaces (2);
insert (cend);
}
bfind(cbeg); pop();
go_right(strlen(cbeg) + 1);
}
else %/* not found */
{
if (what_column() <= C_Comment_Column)
{
goto_column(C_Comment_Column);
}
else insert(" ");
insert(cbeg); insert(" ");
if (strlen(cend))
{
insert (cend);
go_left(3);
}
}
}
% This routine formats a comment in C mode. It is assumed that the standard
% Jed comment format is used.
private variable Cmode_Fill_Chars = "";
define c_paragraph_sep ()
{
if (strlen (Cmode_Fill_Chars)) return 0;
push_spot ();
bol_skip_white ();
if (looking_at ("*"))
skip_chars ("*");
else if (looking_at ("//"))
{
go_right (2);
}
skip_white ();
if (looking_at ("@ ")) eol ();
eolp () or (-2 != parse_to_point ());
pop_spot ();
}
define c_format_paragraph ();
define c_format_paragraph ()
{
variable n, dwrap;
% !if (is_c_mode ()) return;
Cmode_Fill_Chars = "";
if (c_paragraph_sep ()) return;
push_spot (); push_spot (); push_spot ();
while (not(c_paragraph_sep ()))
{
!if (up_1 ()) break;
}
if (c_paragraph_sep ()) go_down_1 ();
push_mark ();
pop_spot ();
while (not(c_paragraph_sep ()))
{
!if (down_1 ()) break;
}
if (c_paragraph_sep ()) go_up_1 ();
narrow ();
pop_spot ();
bol ();
push_mark ();
skip_white ();
if (looking_at ("* ")) go_right (2);
else if (looking_at ("// ")) go_right (3);
Cmode_Fill_Chars = bufsubstr ();
dwrap = what_column ();
bob ();
do
{
bol_trim ();
if (looking_at ("* ")) deln (2);
else if (looking_at ("// ")) deln (3);
}
while (down_1 ());
WRAP -= dwrap;
unset_buffer_hook ("format_paragraph_hook");
call ("format_paragraph");
set_buffer_hook ("format_paragraph_hook", &c_format_paragraph);
WRAP += dwrap;
bob ();
do
{
insert (Cmode_Fill_Chars);
}
while (down_1 ());
bol ();
go_right (strlen (Cmode_Fill_Chars));
skip_white ();
if (looking_at ("*/"))
{
push_mark ();
bol_skip_white ();
del_region ();
}
Cmode_Fill_Chars = "";
widen ();
pop_spot ();
}
define c_comment_region ()
{
#iffalse
return comment_region ();
#else
variable cbeg = "/* ", cmid = " * ", cend = " */";
variable c, c1, celm, extra;
check_region (1);
exchange_point_and_mark ();
c = what_column ();
narrow ();
bob ();
USER_BLOCK0
{
extra = (); celm = ();
bol_skip_white ();
c1 = what_column ();
if (c1 > c)
{
goto_column (c);
insert (celm);
trim ();
whitespace (c1 - what_column () + extra);
}
else
{
if (eolp ()) goto_column (c);
insert (celm);
}
}
X_USER_BLOCK0 (cbeg, 0);
while (down_1 ())
{
X_USER_BLOCK0 (cmid, 1);
}
widen ();
bol_skip_white ();
if (looking_at(cmid))
{
deln (3);
}
else
{
eol ();
!if (right(1)) newline ();
}
X_USER_BLOCK0 (cend, 0);
pop_spot ();
#endif
}
define c_top_of_function ()
{
!if (bol_bsearch_char ('{'))
{
error ("Top of function not found.");
}
}
define c_end_of_function ()
{
eol ();
!if (bol_fsearch_char ('}'))
error ("End of function not found");
% was:
% !if (bolp () and looking_at_char ('{'))
% c_top_of_function ();
% call ("goto_match");
}
define c_mark_function ()
{
c_end_of_function ();
push_visible_mark ();
eol ();
go_down_1 ();
exchange_point_and_mark ();
c_top_of_function ();
go_up(2);
bol ();
}
%% This function creates a C++ style comment in the same manner as
%% c_make_comment.
%% Written by MDJ
%% I've bound this to "\e:" (c_make_comment is bound to "^e;")
define c_plus_plus_make_comment()
{
variable d, cbeg, mode;
cbeg = "//";
%% search for a comment on the line
eol();
if (bfind(cbeg))
{
!if (bolp())
{
go_left_1 ();
trim();
() = ffind(cbeg);
}
d = C_Comment_Column - what_column;
if (d > 0) whitespace(d);
bfind(cbeg); pop();
go_right(strlen(cbeg) + 1);
}
else %/* not found */
{
if (what_column() <= C_Comment_Column)
{
goto_column(C_Comment_Column);
}
else insert("\t");
insert(cbeg); insert(" ");
}
}
|