]> git.donarmstrong.com Git - lilypond.git/blob - TODO
patch::: 1.1.43.crypton1
[lilypond.git] / TODO
1 -*-outline-layout:(2 (-1 -1 0 :) 0);outline-stylish-prefixes:nil -*-
2
3 * GNU LilyPond TODO
4 Features you cannot find in the doco as working, should be
5 mentioned here.  This is an assorted collection of stuff that will be
6 done, might be done, or is an idea that I want to think about
7
8 Most of the items are marked in the code as well
9 Grep for TODO and ugh/ugr/urg.  
10
11 .* BUGS
12 . * junk separate mudela versioning. 
13 . * PostScript
14 .  * header for PS enteredby = "bla <bla@bar.com>"
15 .  * ps/lily.ps see comments.
16 . * devise standard for functioning of Vertical_align_element.
17 . * midi key.
18 . * Repeats
19 .  * unfold broken: 
20 .   * without alternatives: repeat unfold 4 { a b c d }
21 .   * count > alternatives: repeat unfold 79 { a b c d } 
22 \alternative { { c c c c } { d d d d } }
23 .  * kind of 'initial property' iso fold/volta(semi)/unfold strings
24 . * fix singleStaffBracket
25 . * declare performers in \midi
26 . * fix MIDI
27 . * \shape 1st dim skipped? 
28 . * turn slope-damping on/off
29 . * tremolo stuff
30 . * We need feta-din*.mf files for more sizes than 10.
31 . * fix dynamics decently, ie. use kerning & ligatures.  
32 . * dots & rest collisions?
33 . * mudela-book.py
34 .  * fix \mudelafile{} to have decent functionality
35 .  * P.P.S. It can be cool in mudela-book to distinguish in
36 pre,postMudelaExample, whether MudelaExample is epsed or not: ( if
37 this fragment is floating eps, than 1, otherwise 2). say
38 preMudelaExample[eps]{}, and change it in document body sometimes.
39 .  * use less RE's
40 . * slurs colllide with lyrics.
41 . * Is there any reasonable way to do this: I would like to have one file
42 that can generate the same tune in two different modes without having
43 to go through and rewrite all the music in the other mode.
44
45 Long lyrics don't get a space at the end.  They just run right up
46 against the next lyric.  (I don't think this used to be the case.)
47
48 Lyrics and scripts collide.
49
50 \key b; \time 4/4; looks bad.  The clef and time signature are too close.
51
52 restStyle=mensural doesn't seem to work (lots of characters not found
53 for rests.fly)
54 . * Phrasing:  Indicating the textual underlay of a piece, or
55 otherwise dividing a piece into phrases.
56
57 There are distinct ways of specifying the first two (although at
58 present, they're not properly distinguished) but no distinct way to
59 specify the third.  Should there be?
60 . * rest collision minimum dist.
61 . * 1. is there a "no key signature mode" for lily yet so that i can just
62 enter the notes without worrying about it instead of having to
63 remember to put a "!" after each accidental?
64
65 a note with a circle after it, meaning:
66
67    note + circle = note + 1/4 of its length
68
69    the circle is like a dot that's not filled in.  for example, on
70    page three, the c-sharp on the second line should be a quarter with 
71    a circle, not a quarter tied to a sixteenth.  is this at all
72    possible with lily?
73 tuplets that are written as "number : note", for example
74    "3 : [image of a half note here]".  possible?
75 "p+" and "p-" for dynamic markings.  possible?
76 . * repeat engraver, gallina.ly
77
78 . * Matanya's tips: 
79 .  * spacing for prefatory matter
80 .  * The line length is 7.5 inch (19.05
81 cm) and the height of normal size is equivalent to the traditional raster 1
82 > size. (The Schott company sells Letraset sheets of musical symbols which are
83 > measured in raster sizes). It is agreed among most engravers I know that the
84 > standard size for adult readers in solo music should 70% of raster 1.  Jeff's
85 > example was 75%, so I had to modify my file to match. 
86
87 So that makes for a staff space of 4 2/3 point. I'll add the
88 dimensions to the TODO file.
89 .  * accidentals closer to note head
90 .  * to space the staffs/staffgroups contained in the score.  
91
92 In the orchestscore.ly file, I tried:
93 \paper{
94     \translator {
95         \OrchestralScoreContext
96         minVerticalAlign = 3.0*\staffheight;
97     }
98     \translator { 
99         \StaffGroupContext
100         minVerticalAlign = 3.0*\staffheight;
101     }
102     \translator { 
103         \StaffContext
104         minVerticalAlign = 3.0*\staffheight;
105     }
106 }
107 .  * heavier beams?
108
109 .* Cleanups needed
110 . * Beam
111 . * Stem
112 . * Slur
113 . * Rhythmic_grouping
114 . * Duration
115 . * Spring generation
116 . * Collision
117 . * Rest_collision
118 . * clef grav prop's 
119
120 .* TODO before 1.2
121 . * Morally pure LilyPond.
122 .  * Remove mutopia ramblings.
123 .  * Remove non-free software links.
124 .  * Remove meta article LilyPond.
125 . * break priority setting from SCM.
126 . * Gade score
127 .  * remove [] in favour of auto-beamer
128 . * hangOnClef with non-breakable clefs.
129 . * Aha, the problem is the new TeX code generation for changing fonts.
130 > (The explanation below is mostly intended for Han-Wen and Jan)
131 > Before, the font was changed with macros declared separately for 
132 > pure TeX and LaTeX, but now all the fonts are declared directly in
133 > the generated code using the low-level TeX commands. This circumvents
134 > the fontencoding mechanism of LaTeX and is a potential source of
135 > problems also for us users of the Latin-1 character set. 
136 > I think it still works since the inputencoding latin1 is 
137 > declared by ly2dvi, but it still means that e.g. an o with
138 > umlaut is typeset as a combination of the two symbols 'o' and
139 > 'umlaut' instead of as a single character, as would be the case
140 > if fontencoding OT1 had been used. This shouldn't give any 
141 > difference in layout, though. One of the main argument for using
142 > fontencoding OT1 is for the hyphenation mechanism to work, an 
143 > argument that's clearly irrelevant in our application. Yet we
144 > see the problem for August.
145 . * Abstraction for engravers:
146 .  * make "in-between" engraver (Tie, Extender)
147 .  * make wide_spanner_engraver (line_group_spanne,r staff_symbol)
148 . * remove Interval dim_ from Dimension_cache and rename the struct.
149 . * do scaled fonts generally 
150 . * The Lilypond accidental symbols are available through the TeX macros, 
151 \textflat, \textsharp and \textnatural defined in the init file
152 lilyponddefs.tex. All the symbols are defined in the files fetaXX.tex
153 where XX corresponds to the size. I don't know where (or even if) they
154 are installed but they are generated in the mf/out/ directory during the
155 compilation.
156 . * make dependencies () a virtual function.
157 . * one big ly2dvi input that includes *all* tests.
158 . * store req -> element, element -> element causes for warnings
159 . * include examples in RPM.
160 . * fix partial measures in meaningful way.
161 . * add scripts to bars eg.  |^"bla" 
162 . * relative mode for mi2mu
163 . * uniformise recent feta contributions.
164 .  * use SCM and Molecules for {accordeon stuff, }
165 .  * bigger and fatter 4/4 C
166 . * sort out directory stuff.
167 .  * --prefix option?
168 .  * -I option per filetype?
169 .  * kpathsea?
170 . * ly2dvi/lilypond logfile.
171 . * fractional chord durs.
172 . * hang Item on Spanner
173 . * do --safe for PS output?
174 . * convert-mudela --output
175 . * Staff_margin (with a partial measure.)
176 . * fix pletvisibility properties:
177 .  * bracket on/off/no-bracket-when-beam
178 .  * num on/off/no-num-when-beam
179 . * fix: standchen.
180 . * junk text{sharp,flat,etc}
181 . * fix convert-mudela manpage
182 . * decimal point in \paper {}
183 . * {  \voiceone <a'4.*2/3  d''4.*2/3 fis''4.*2/3>  [g''8 fis'' e''] d''4 |}
184          and
185          { \voicetwo  d'4 d'2.*2/3 } spacing
186 . * tied notes for MIDI
187 . * sharp / flat on trills (in MIDI ??)
188 . * scm-ify \property values.
189 . * move class Lookup {} into scm
190 . * msgfmt -o check?
191 . * \breathmark TeX macro 
192 . * add new glyphs to font.ly
193 . * formatting of input stuff. 
194 . * \notes{ a \< b \cr } vs \notes{ a \< b \! }
195 . * space after bars?
196 . * 'hinterfleisch' before bar (e.g. wtk1-fugue2)?
197 . * Summary of minor spelling irregularities:
198 .  *  capitalization/use of underscores in property names
199 .  * fix SkipBars  -> skipBars
200 . * broken scripts:
201         lbheel = \script { "bheel" 0 0 -1  0 0 }
202         rbheel = \script { "bheel" 0 0 1 0 0 }
203         lbtoe = \script { "btoe" 0 0 -1 0 0 }
204         rbtoe = \script { "btoe" 0 0 1 0 0 }
205         lfheel = \script { "fheel" 0 0 -1  0 0 }
206         rfheel = \script { "fheel" 0 0 1 0 0 }
207         lftoe = \script { "ftoe" 0 0 -1 0 0 }
208         rftoe = \script { "ftoe" 0 0 1 0 0 }
209         and also
210         portato= \script { "portato" 0 -1 0 1 0 }
211 . * ly2dvi
212 .  * bottomnote for ly2dvi
213 .  * deps for ly2dvi
214 .* STUFF
215 . * compulsory hshift
216 . * Give # lines in linebreaking.  
217 . * arrows on slurs.
218 . * rewrite context defs using Scheme
219 . * \selectmusic to cut pieces from music. 
220 . * TODO: merge atom & molecule; make  tree from molecule.
221 . * Align_element::padding  ?
222 . * uniformise property names...
223 .  * ydirection <-> yDirection
224 .  * rather allow '_' in identifiers first (i.e. junk ^ and _),
225 and do y_direction?
226 .  * typo checks on property names?
227 . * use streambufs and iostream
228         to provide IO handling for TeX stream, mudela stream, data-file.
229 . * seriously buffer TeX output (do profile of writing .5 mb TeX file.)
230 . * strip EXEs before installing
231 . * zip target for binary windows dist (JBR)
232 . * junking \skip req in lyrics
233 . * mi2mu empty staffs.
234 . * use Fourier transformation for rhythmic quantisation.
235 . * horizontal centering of dynamics 
236 . * $DEPENDENCIES_OUTPUT support
237 . * Xdvi zooming ?! Try to understand GS garbage collection.
238 gs: Error: /undefined in draw_beam
239 gs: Operand stack:
240 . * fix vertical alignment and stafflines
241 . * declaring Performers
242 . * *.yo: fix pod manpage layout legacy
243 . * text-items clash with stems/beams
244 . * --include, -I option for ly2dvi (pass on to lily)
245 . * fix placement of beam-less abbrev
246 . * \meter 3/4;
247         <{\voiceone cis4. cis8 cis4 | cis4 cis cis | r1 }
248          {\voicetwo cis,4 r r | r2. | r1 }> |
249         }
250 . * Musical_pitch (analogous to Duration and Rhythmic_req)
251           think about, analogous to pitch: 
252            * { a4 a16 } c <-- duration of c?
253            * < a4 b8 > c <-- duration of c?
254 . * \tempo 4. = 90;
255 . * fix audio-items (don't use (input) requests, but copy data)
256 . * make sure all ex's have a mudela-version
257 . * do rest-collisions for Multi_measure_rests as well.
258 . * split error/warning in error/warning/non_fatal_error
259 . * add a Duration_convert member to Duration_iter to set parameters.
260         Junk global duration settings. 
261 . * en-,discouraged linebreaking: 
262 .  * handle DISALLOW < penalty > FORCE
263 .  * discourage breaking of slurs
264 . * fix variable define/lookup parser global<->paper
265 . * fix title/instrument placements; see input/test/title.ly
266 . * <\voiceone c4. \voicetwo c4>
267 . * add full cello suites to web site (kom op, Maarten!)
268 . * add mudela-book-doc source to webstie.
269 . * Rethink Time_description
270 \cadenza , \meter, \grouping should all be \properties
271 . * rename
272 .  * measure -> bar
273 .  * abbrev -> tremolo
274 .  * abbreviation-beam -> (measured/unmeasured) tremolo
275 .  * partial -> anacrouse
276 . * robustify Beam (in case of no stems, 32nd notes)
277 . * move paper vars into engraver properties
278 . * check for groff / troff/ nroff et
279 . * more intelligent file searching
280 . * disable spaces in TeX stuff
281 . * handle ^C for tmp/file creation.
282 . * make LilyPond RPM fully relocatable
283 . * dots & rest collisions.
284 . * the warning about the negative slur/tie length appears twice
285 which is irritating.
286 . * better hshift (dots, distance, head dependent)
287 . * clefs (AG): The "8" should appear closer to the actual clef,
288 touching it.
289 . * put errorlevel in Input class
290 . * junk nesting slurs
291 . * integrate midi-elts from mi2mu and lily?
292 . * distinguish between unset and empty properties. 
293
294 .* FONT
295 . * the bracket is ugly (wings are too parabolic, should be more circular)
296 . * versioning for Feta
297 . * rewrite dynamic signs.  They're kind of spaghetti now. 
298 . * The `3' in the meter key is a one or two pixels too thin (at 600dpi)
299         in the middle:
300 . * design macro for penstroke with rounded endings
301 . * timesig C: fat yet less curved.  Check out relations. 
302 . * design decent macro for bulbed endings
303 . * printer dependencies.
304 . * versioning  
305 . * lo-res fixes.
306 . * work out sizes of character fonts.
307 . * more symbols
308 .  * piano pedals: Ped/*
309 .  * maxima notehead
310 .  * coda signs: Segno, O+
311 .  * glissando, arpeggio
312 .  * lengthened trill
313 . * include important spacing dims in fetalog 
314 . * scalability: use blot_diameter everywhere, make font chubbier for
315     small sizes.
316
317 .* 3RD PARTY BUGS
318 . * GNU diff 2.7: diff -rN does not see a new directory with empty file
319 . * check out GCC signatures?
320 . * glibc 2.0:
321           f = fopen ("/dev/null", "r")
322           assert (feof (f))
323
324 . * tetex: mfplain.mem
325 .* 3RD PARTY PROJECTS:
326 . * make GCC warn about ctor that leaves member vars  uninitialised.
327 . * GNU patch 
328 .  * 'double-fix' mode: ignore identical fix, rather than suggest 
329             to revert patch direction when (more or less? exactly) the same 
330             thing is fixed
331 .* PROJECTS
332 . * Scripts:
333 .  * stack scripts in chords:
334           % fingering:        footing:
335             < a-4 c-2 g-1 >   < c-\ltoe e-\lheel >
336 .  * script-spacing
337 .  * slur parts as a script
338 .  * stack parameterised scripts for fingering and footing:
339
340 . * convert-mudela:
341 .  * automatically add  a \version if not present.
342 .  * better parsing
343 .  * make smarter
344 .  * convert-mudela -e empty.ly
345
346 . * emacs mudela-mode
347 .  *  should handle block comments too.
348 .  *  handle lexer modes (\header, \melodic, \lyric) etc.
349 .  *  indentation
350 .  *  notenames?
351 .  *  fontlock: \melodic \melodic
352
353 . * use properties for:
354 .  * default tempo.
355 .  * cadenza mode? 
356
357 . * page handling:
358 .  * PS output
359 .  * optimal pagebreaking.
360
361 . * Unicode support? -> man 7 unicode
362 .  * 16 bit Strings
363 .  * -u switch
364 .  * detect of 16/8 bit files
365 .  * examples to go with it.
366
367 . * Spring_spacer:
368 .  * write a faster Spring_spacer (without matrices if possible)
369 .  * relate energybound to linelen unitspace fontsize etc.
370 .  * used fixed point fp?
371
372 . * \header
373 .  * output header info to MIDI too.
374
375 . * a musical dictionary. See Documentation/vocabulary-*, other
376 languages:
377 .  * explanations
378 .  * italian
379 .  * german
380 .  * dutch
381 .  * swedish
382          .. ?
383
384 . * chords
385 .  * guitar chords (fret diagrams)
386 .  * other chord name styles (american(?) style)
387 .  * basso continuo
388 .  * MIDI output?
389
390 . * Debug logs:
391 .  * derive lily_stream, Dstream, texstream from ostream?
392 .  * indentable stream as baseclass for TeX stream, lily stream, Dstream.
393 .  * use dstream feature in mi2mu
394 .  * integrate IO checking into stream class
395
396 . * input converters
397 .  * NIFF?
398 .  * ABC? 
399 .  * SMDL?
400
401 . * add to MIDI output:
402 .  * tempo change
403 .  * ornaments (and trills?)
404 .  * slurs
405 .  * accents
406 .  * dynamics
407 > Would it be hard to add support for proper dynamics in MIDI output?  I
408 > would really like to have this feature...
409
410 To answer this, I have to give a little background.  Please say so if
411 I am being obtuse.
412
413 Both audio and notation elements are created decentrally, when
414 LilyPond says "Interpreting music ... [8][16] etc."  After all
415 elements are created, they are processed again to calculate all
416 parameters.  After that is done, they are dumped onto the output (the
417 MIDI stream or the TeX file).
418
419 The audio and notation elements are created by objects called
420 performer and engraver respectively.  They work by taking a chunk of
421 input (a so-called request), and using the request to create an audio
422 or notation element.
423
424 After some processing, the engraver sends the created elements to
425 its enclosing notation/performance context.
426
427 In the case of notation, engravers can also modify existing elements
428 created by sibling engravers.  Eg. the beam-engraver will modify stems
429 when it creates a beam over a couple of stems.  This is done in
430 Engraver::do_acknowledge_element () and
431 Engraver::do_process_acknowledged ().
432
433 In the case of audio, there are no mechanisms to modify existing audio
434 elements. After the audio elements are created, they are sent directly
435 to the enclosing context (an instance of Performer_group_performer),
436 through the method Performer::play ()
437
438 Concretely spoken, for dynamics you have to write a performer
439 (Dynamics_performer), that will take the input requests. If I
440 understand correctly, every MIDI note played must have its dynamic
441 strength set separately.  That means the the Dynamics_performer must
442 set the strength of every Audio_note it finds.  This means that one
443 has to modify existing Audio items.  The best way of doing this is
444 with a broadcast/acknowledge process.
445
446 So the best way of handling this, is
447
448   1 supporting dynamic settings in Audio_note
449
450   2 mimicking the broadcast/acknowledge mechanism of the Engravers in
451   the Performers
452
453   3 using that mechanism to write a Dynamics_performer that will modify
454   any notes it finds to set appropriate strengths.
455
456 You could also kludge this by deriving from Performer_group_performer
457 a performer that also sets dynamics within notes, but that is not the
458 elegant way to do it.
459
460 I'd say that the work involved is not hard, but you have to be fluent
461 with C++ and need some insight into the working of Notation Contexts
462 and friends.  I guess I could do it in a day or so, but if you are not
463 so fluent with the inner workings of LilyPond, it could take you some
464 more time (A few more days?).
465
466 Please note, that I am *not* going to code this myself: my days are
467 valuable, and I think I have more interesting things to do than fixing
468 the MIDI output (I don't even have a soundcard).  But I *do* want to help
469 you or other people with implementing this, so if you need help, don't
470 hesitate to ask.
471
472 .  * account for rhythmic position in measure
473 .  * etc.
474
475 . * grace notes
476 .  * make separate class for Grace_*_engravers 
477         (which is at Voice_gravs level)
478 .  * make encapsulated spacing problems.
479
480 . * accidentals per Voice_group
481
482 . * Output class, handles : (smallish)
483 .  * help text /(c) notice?
484 .  * version line
485 .  * warning /errors/progress
486 .  * abort on error/warning; exit status
487 .  * quiet/ignore-version options
488 .  * logfile output
489
490 . * PS 
491 .  * speed up PS code.
492 .  * PS lines to .eps files
493 .  * write custom prolog
494
495 . * SGML input
496
497 . * Documentation
498 .  * remove links to non-free SW.
499 .  * internal documentation
500 .  * a general paper. 
501 .  * \properties
502 .   * left/rightbeamcount
503 .   * various other new properties.
504 .  * introduction?
505 .  * info?
506 .  * LaTeX?
507 .  * more manpages?
508 .  * Doc (C) stuff of sheet music
509 .  * a better format?  SGML?  TeX?  Info?
510 .  * a better tutorial
511
512 . * more spanners (smallish)
513 .  * Glissando
514 .  * trill
515
516 . * Rewrite Stem, Beam and Rhythmic_grouping (hairy)
517 .  * [c8. c32 c32]
518 .  * doc on Rhythmic_grouping
519 .  * general shaving on Beam and Stem
520 .  * use plet grouping
521 .  * separate visual from rhythmic info even more
522 .  * beams over bars
523
524 . * lines:
525 .  * Ledger lines, should be separate item: Ledger_lines
526 .  * set different line sizes / thicknesses
527 .  * beam stem showthrough, inter beam sizes (french vs german style)
528
529 . * Collisions
530 .  * left/right note balls should be handled by Collision:
531         < \multi 2; { \stem 1; <b c> } { <f as b> } >
532
533 . * Keys:
534 .  * merge key{item} & localkey{item}?
535 .  * spacing, national styles?
536
537 . * Support for TAB
538 .  * redo Notehead to allow digits as heads
539 .  * add a \tablature {} lexer mode for easy entering
540
541 . * should adjust stemlength for flag number.
542
543 . * breaking:
544 .  * caching breakpoints
545 .  * saving them
546 .  * specify number of lines
547
548 .* INPUTLANGUAGE
549 . * \rhythms 4 16 16 16 16; c c c c c -> c4 c16 etc. 
550 . * Language:
551 .  * \translator -> ?
552 .  * fix \partial 
553 .  * \bla {} vs \bla ; 
554 .  * mix engraver hacking with music ?
555 .  * \once\property  KEY = VAL
556 .  * \addtranslator, \removetranslator
557 .  * junk ^ and _ for scripts
558 .  * junk _ for lyrics.
559 .  * abstract grammar.
560 . * Figure out semicolons.
561 . * c4 4 4 4 for c4 c4 c4 c4?
562 . * <c f a>4 ?
563 . * Viola mode?
564
565                 @c c g e g 
566         for
567                 c g es g, 
568
569                 @A c g e g
570         for
571                 cis gis e gis
572 . * configure pitch_byte
573 . * rest name configurable
574
575
576 .* SMALLISH PROJECTS
577
578 . * Faulenzer sign (% repeat).  Perhaps also use \repeat syntax?
579
580 . * fix confusing naming in Engraver vs Engraver_group_engraver (context)
581
582 . * progress when creating MIDI elts.
583
584 . * A range for context errors (eg. mark both { and }. )
585
586 . * lyric in staff  (sharpsharp in staff, text below)
587
588 . * half sharps/flats
589
590 . * write Dynamic_line (to group dynamics horizontally)
591
592 . * use Real for all y positions.
593
594 . * half-sharps, half-flats
595
596 . * adaptive accidental spacing.
597
598 . * handle EOF graciously in error messages.
599
600 . * midi esp.: use I32 iso int where 32 bits are needed (or assumed...)
601
602 . * stafftypes: voice names/ instrument names.
603
604 . * lily \tempo
605
606 . *   % toe to bheel   four to five
607             %   ^_u            4_5  
608             %     -                           
609             %  --|x--         --|x--
610             %  --|---         --|---
611             %  --|---         --|---
612           (where "to" is a tiny bow)
613
614 . * auxilliary file for caching info.
615
616 . * Text_crescendo
617
618 . * revise calcideal
619
620 .* IDEAS
621 . * Output data structures of Mudela in XML/SGML.
622 . * create libmudela, or liblily_frontend
623 . * move MIDI stuff (including Quantization) to a ANSI C libmidi library.
624 . * Spacing_request for manually adjusting spacing
625 . * caching breakpoints
626 . * used fixedpoint arithmetic for min. energy.
627 . * move towards incremental algorithms.
628 . * versioning stuff (cvt mudela, mudela, etc.)
629 . * dynamic loading of engravers? 
630 .* SMOBS
631 Han-Wen Nienhuys <hanwen@cs.uu.nl> writes:
632
633 >       class Foo_class {
634 >               Foo_smob *smob_ptr_;
635 >       }
636
637 >       struct Foo_smob {
638 >               Foo_class *class_ptr_
639 >       }
640
641 Usually you can get away without having this interlinked structure.
642 One piece of information you need when exporting objects to scheme is
643 the smob tag for your class.  You might store this value (a long) into
644 a class static variable, or a file static variable.  I'll use a class
645 static variable in this example.
646
647 I typically use code that works like this (untested code ahead):
648
649 class Foo_class {
650     static long *Foo_smob_tag;
651     SCM obj; // representation as a scheme object, description comes later
652 }
653
654 // call this once on startup
655 void init_Foo_class {
656     static scm_smobfuns type_rec;
657
658     type_rec.mark = foo_mark;
659     type_rec.free = foo_free;
660     type_rec.print = foo_display;
661     type_rec.equalp = 0;
662     Foo_class::Foo_smob_tag = new int(scm_new_smob(type_rec));
663 }
664
665 When you want to export an object to scheme, you put a pointer to the
666 object itself in the cdr of the cell, and the tag in the car of the
667 cell.  The code looks like this:
668
669 // Is this a Foo?
670 static int
671 foo_p(SCM obj)
672 {
673     return(SCM_NIMP(obj) && SCM_CAR(obj) == Foo_class::Foo_smob_tag);
674 }
675
676 // given a Scheme representation, return, a C++ representation
677 static Foo_class *
678 foo_unbox(SCM obj)
679 {
680     return((Foo_class*)SCM_CDR(obj));
681 }
682
683 // the SCM representation of the object is stored inside itself
684 // this will become useful when destructor gets called
685 static SCM
686 foo_box(Foo_class *foo)
687 {
688     SCM_DEFER_INTS;
689     SCM_NEWCELL(foo->obj);
690     SCM_SETCAR(foo->obj, Foo_class::Foo_smob_tag);
691     SCM_SETCDR(foo->obj, (SCM)foo);
692     SCM_ALLOW_INTS;
693     return foo->obj;
694 }
695
696 > C++ determines life time, so what is the strategy?
697
698 What happens now when the destructor gets called?  Lets set the cdr to
699 NULL, and then check for that in all of the primitive functions that
700 use your smob.  We'll call this notion 'live'; a scheme object is
701 'live' if the C++ representation still exists, it's dead if the C++
702 object is gone.  You can still have references to dead objects in
703 scheme code; it's just an error to use them.  This idea is stolen from
704 Emacs's handling of buffers ('buffer-live-p' and friends).
705
706 Add another function, foo_live_p:
707
708 static int
709 foo_live_p(SCM obj)
710 {
711     return(foo_p(obj) && SCM_CDR(obj) != NULL);
712 }
713
714 In you destructor, you need to do:
715
716 ~Foo_class()
717 {
718     SCM_CDR(this->obj, NULL);
719 }
720
721 When writing new primitives, now just check foo_live_p().
722
723 I hope the above helps,
724
725
726 * OUTLINE SETUP
727 .* .EMACS
728 ;;; from outline.el
729 (defvar outline-font-lock-keywords
730   '(;; Highlight headings according to the level.
731     ;; must change this to allout node layout
732     ;;("^\\(\\*+\\)[ \t]*\\(.+\\)?[ \t]*$"
733     ("^\\([.]*[ ]*[*]\\)[ \t]*\\(.*\\)$"
734      (1 font-lock-string-face)
735      (2 (let ((len (- (match-end 1) (match-beginning 1))))
736           (or (cdr (assq len '((1 . font-lock-function-name-face)
737                                (2 . font-lock-keyword-face)
738                                (3 . font-lock-comment-face))))
739               font-lock-variable-name-face))
740         nil t))
741     ;; Highlight citations of the form [1] and [Mar94].
742     ("\\[\\([A-Z][A-Za-z]+\\)*[0-9]+\\]" . font-lock-type-face))
743   "Additional expressions to highlight in Outline mode.")
744
745 (add-hook 'outline-mode-hook
746           '(lambda ()
747             (setq font-lock-maximum-decoration t)
748             (setq font-lock-maximum-decoration t)
749             (make-local-variable 'font-lock-defaults)
750             (setq font-lock-defaults '(outline-font-lock-keywords t))
751             (font-lock-mode global-font-lock-mode)
752         ))
753  
754 (require 'allout)
755 (outline-init 't)