L
luser- -droog
I've just cobbled together a few tricks that save a bunch of
keystrokes when generating the .h file from a freshly written
..c file.
A freshly written .c file:
1
2 #include "m.h"
3 #include "ob.h"
4
5 object consarr(mfile *mem, unsigned sz) {
6 unsigned ent = mtalloc(mem, sz * sizeof(object));
7 return (object){ .tag = arraytype, .sz = sz, .ent = ent, .off
= 0};
8 }
9
10 void arrput(mfile *mem, object a, integer i, object o) {
11 put(mem, a.comp_.ent, a.comp_.off + i, sizeof(object), &o);
12 }
13
14 object arrget(mfile *mem, object a, integer i) {
15 object o;
16 get(mem, a.comp_.ent, a.comp_.off + i, sizeof(object), &o);
17 return o;
18 }
19
"ar.c" 19L, 472C written
then switch to new file
:e ar.h
load previous file
:r #
trim headers
d}
replace function body with semicolon
j$c%;ESC
reposition, repeat change
jj$.
again
jj.
et voila:
1
2 object consarr(mfile *mem, unsigned sz);
3
4 void arrput(mfile *mem, object a, integer i, object o);
5
6 object arrget(mfile *mem, object a, integer i);
7
"ar.h" 7L, 149C written
keystrokes when generating the .h file from a freshly written
..c file.
A freshly written .c file:
1
2 #include "m.h"
3 #include "ob.h"
4
5 object consarr(mfile *mem, unsigned sz) {
6 unsigned ent = mtalloc(mem, sz * sizeof(object));
7 return (object){ .tag = arraytype, .sz = sz, .ent = ent, .off
= 0};
8 }
9
10 void arrput(mfile *mem, object a, integer i, object o) {
11 put(mem, a.comp_.ent, a.comp_.off + i, sizeof(object), &o);
12 }
13
14 object arrget(mfile *mem, object a, integer i) {
15 object o;
16 get(mem, a.comp_.ent, a.comp_.off + i, sizeof(object), &o);
17 return o;
18 }
19
"ar.c" 19L, 472C written
then switch to new file
:e ar.h
load previous file
:r #
trim headers
d}
replace function body with semicolon
j$c%;ESC
reposition, repeat change
jj$.
again
jj.
et voila:
1
2 object consarr(mfile *mem, unsigned sz);
3
4 void arrput(mfile *mem, object a, integer i, object o);
5
6 object arrget(mfile *mem, object a, integer i);
7
"ar.h" 7L, 149C written