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