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