Reindent output/face.lisp.
[clon.git] / doc / enduser.texi
blob30cd2148b3d69acea31cf70d974197b98b82827b
1 \input texinfo
3 @c enduser.texi --- End-user manual
5 @c Copyright (C) 2010, 2011 Didier Verna
7 @c Author:        Didier Verna <didier@lrde.epita.fr>
8 @c Maintainer:    Didier Verna <didier@lrde.epita.fr>
10 @c This file is part of Clon.
12 @c Permission to use, copy, modify, and distribute this software for any
13 @c purpose with or without fee is hereby granted, provided that the above
14 @c copyright notice and this permission notice appear in all copies.
16 @c THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17 @c WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18 @c MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19 @c ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 @c WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21 @c ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 @c OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 @c Commentary:
27 @c Contents management by FCM version 0.1.
30 @c ====================================================================
31 @c Header
32 @c ====================================================================
33 @c %**start of header
34 @setfilename clon-enduser.info
35 @settitle The Clon End-User Manual
36 @afourpaper
37 @c %**end of header
41 @c ====================================================================
42 @c Settings
43 @c ====================================================================
44 @set VERSION 1.0 beta 20 "Michael Brecker"
45 @set COPYRIGHT_DATE 2010, 2011
46 @setchapternewpage odd
47 @setcontentsaftertitlepage
48 @documentdescription
49 The Clon End-User Manual for version @value{VERSION}.
50 @end documentdescription
54 @c ====================================================================
55 @c New Commands
56 @c ====================================================================
58 @macro clon
59 @t{Clon}
60 @end macro
62 @macro cl
63 Common Lisp
64 @end macro
66 @macro tty
67 @t{tty}
68 @end macro
70 @macro etc
71 @i{etc.}
72 @end macro
74 @macro eg
75 @i{e.g.}
76 @end macro
78 @macro ie
79 @i{i.e.}
80 @end macro
82 @macro perse
83 @i{per-se}
84 @end macro
86 @macro cmdline
87 command-line
88 @end macro
90 @macro CmdLine
91 Command-Line
92 @end macro
94 @macro bioption{name}
95 @option{--clon-\name\}
96 @end macro
99 @c The following 3 macros are here to circumvent the info filenames
100 @c changes, when referencing the user manual:
102 @macro pxuserref{node}
103 @ifinfo
104 @pxref{\node\, , , clon-user, The Clon User Manual}
105 @end ifinfo
106 @ifnotinfo
107 @pxref{\node\, , , user, The Clon User Manual}
108 @end ifnotinfo
109 @end macro
111 @macro xuserref{node}
112 @ifinfo
113 @xref{\node\, , , clon-user, The Clon User Manual}
114 @end ifinfo
115 @ifnotinfo
116 @xref{\node\, , , user, The Clon User Manual}
117 @end ifnotinfo
118 @end macro
120 @macro userref{node}
121 @ifinfo
122 @ref{\node\, , , clon-user, The Clon User Manual}
123 @end ifinfo
124 @ifnotinfo
125 @ref{\node\, , , user, The Clon User Manual}
126 @end ifnotinfo
127 @end macro
130 @c ---------------
131 @c Indexing macros
132 @c ---------------
134 @c Concept index
135 @c -------------
137 @c Built-in options
138 @macro bioindex{opt}
139 @cindex @t{--clon-\opt\}
140 @cindex Built-In Options, @t{--clon-\opt\}
141 @cindex Options, built-in, @t{--clon-\opt\}
142 @end macro
144 @c Environment variables
145 @macro evindex{name}
146 @cindex @t{\name\}
147 @cindex Environment, @t{\name\}
148 @end macro
150 @c Built-in environment variables
151 @macro bievindex{var}
152 @evindex{CLON_\var\}
153 @end macro
157 @c ====================================================================
158 @c Info Category and Directory
159 @c ====================================================================
160 @dircategory Common Lisp
161 @direntry
162 * Clon End-User: (clon-enduser).        The Clon End-User Manual.
163 @end direntry
167 @c ====================================================================
168 @c Copying
169 @c ====================================================================
170 @copying
171 @quotation
172 Copyright @copyright{} @value{COPYRIGHT_DATE} Didier Verna
174 Permission is granted to make and distribute verbatim copies of this
175 manual provided the copyright notice and this permission notice are
176 preserved on all copies.
178 @ignore
179 Permission is granted to process this file through TeX and print the
180 results, provided the printed document carries a copying permission
181 notice identical to this one except for the removal of this paragraph
182 (this paragraph not being relevant to the printed manual).
184 @end ignore
185 Permission is granted to copy and distribute modified versions of this
186 manual under the conditions for verbatim copying, provided also that the
187 section entitled ``Copying'' is included exactly as in the original.
189 Permission is granted to copy and distribute translations of this manual
190 into another language, under the above conditions for modified versions,
191 except that this permission notice may be translated as well.
192 @end quotation
193 @end copying
197 @c ====================================================================
198 @c Title Page
199 @c ====================================================================
200 @titlepage
201 @title The Clon End-User Manual
202 @subtitle The @CmdLine{} Options Nuker, Version @value{VERSION}
203 @vskip 2cm
204 @image{splash,16cm}
205 @author Didier Verna <@email{didier@@lrde.epita.fr}>
206 @page
207 @vskip 0pt plus 1filll
208 @insertcopying
210 @hfill Cover art by Alexis Angelidis.
211 @end titlepage
215 @c ====================================================================
216 @c Table of Contents
217 @c ====================================================================
218 @contents
222 @c ====================================================================
223 @c Master Menu
224 @c ====================================================================
225 @ifnottex
226 @node Top, Copying, (dir), (dir)
227 @top The Clon End-User Manual
229 This is the @clon{} End-User Manual for @clon{} version @value{VERSION}:
230 it describes the use of applications powered by @clon{}.
232 @menu
233 * Copying::             The BSD license
234 * Introduction::        What Clon is all about
235 * Clonification::       Determining whether a program is powered by Clon
236 * The Command Line::    Making use of @clon{}'s @cmdline{} features
237 * Output::              Understanding and customizing @clon{}'s output
238 * Conclusion::          That's all folks
239 * Concept Index::       Concept Index
240 @end menu
242 @insertcopying
243 @end ifnottex
247 @c ====================================================================
248 @c Copying
249 @c ====================================================================
250 @node Copying, Introduction, Top, Top
251 @unnumbered Copying
253 @quotation
254 Permission to use, copy, modify, and distribute this software for any
255 purpose with or without fee is hereby granted, provided that the above
256 copyright notice and this permission notice appear in all copies.
258 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
259 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
260 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
261 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
262 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
263 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
264 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
265 @end quotation
269 @c ====================================================================
270 @c Introduction
271 @c ====================================================================
272 @node Introduction, Clonification, Copying, Top
273 @chapter Introduction
275 @clon{} is a library for managing @cmdline{} options in standalone @cl{}
276 applications. It provides a unified option syntax with both short and
277 long names, automatic completion of partial names and automatic
278 retrieval/conversion of option arguments from the @cmdline{}, associated
279 environment variables, fallback or default values. @clon{} comes with a
280 set of extensible option types (switches, paths, strings @etc{}).
281 @clon{} also provides automatic generation and formatting of help
282 strings, with support for highlighting on @tty{}'s through ISO/IEC 6429
283 SGR. This formatting is customizable through @emph{themes}.
285 Depending on the target audience, @clon{} stands for either ``The
286 @CmdLine{} Options Nuker'' or ``The @cl{} Options Nuker''. @clon{} also
287 has a recursive acronym: ``@clon{} Likes Options Nuking'', and a reverse
288 one: ``Never Omit to Link with @clon{}''. Other possible expansions of
289 the acronym are still being investigated.
291 This manual is for the @clon{} @emph{end-user}, that is, the user of an
292 application powered by @clon{}. It describes how to use the @cmdline{}
293 of clonified@footnote{An application using @clon{} for its @cmdline{}
294 option management is said to be @emph{clonified}. It is also possible to
295 say @emph{clonfiscated}. However, we advise against using
296 @emph{clonistified}. The term @emph{clonificated} is also considered bad
297 style, and the use of @emph{clonificationated} is strictly prohibited.}
298 applications and how to customize @clon{}'s output. Everybody should
299 read this manual first. If you want to use @clon{} in one of your
300 applications, then you are considered a @clon{} @emph{user}, as opposed
301 to a @clon{} @emph{end-user}, and you should then read the corresponding
302 manual (@pxuserref{Top}).
304 @ref{Clonification} shows how to verify that an application is powered
305 by @clon{}. @ref{The Command Line} explains how to use the @cmdline{} of
306 a clonified application, and @ref{Output} describes how to customize the
307 output of @clon{}.
311 @c ====================================================================
312 @c Clonification
313 @c ====================================================================
314 @node Clonification, The Command Line, Introduction, Top
315 @chapter Clonification
316 @bioindex{help}
317 @bioindex{banner}
318 @bioindex{version}
319 Given this wonderful standalone @cl{} application, how do I know if it
320 uses @clon{} for handing the @cmdline{}? Perhaps the simplest way to
321 know is to type
323 @example
324 program --clon-help
325 @end example
327 @cindex Built-in Options
328 @cindex Options, built-in
329 and see what happens. If you get an error, then you are out of luck.
330 Otherwise, you will get a list of @clon{}-specific options. Every
331 clonified application has these options built-in, and they are all
332 called @t{--clon-}@i{something}. We will describe most of them when
333 appropriate in this manual, but here's already the description for a
334 couple of them (in addition to @bioption{help} that we've just
335 mentioned).
337 @table @bioption
338 @item banner
339 When given this option, the application outputs a whole bunch of
340 information, including the version of @clon{} it is using, and
341 @clon{}-specific copyright information.
343 @item version
344 This option makes the application output the version of @clon{} it is
345 using. By default (or by using it like this: @bioption{version=long}),
346 this information is provided in @emph{long} form (release number, status
347 and name; just try it). If you ask for @bioption{version=short}, you'll
348 get a more compact version information, and if you try
349 @bioption{version=number}, you will end up with a purely numerical
350 version number. For more information on @clon{} version numbering, see
351 @userref{Version Numbering}.
352 @end table
356 @c ====================================================================
357 @c The Command Line
358 @c ====================================================================
359 @node The Command Line, Output, Clonification, Top
360 @chapter The Command Line
361 @cindex Command-Line
363 @clon{} provides applications with usual @cmdline{} features such as
364 option names coming in short (@eg{} @samp{-h}) or long (@eg{}
365 @samp{--help}) form. @clon{} also comes with a set of more specific
366 features, such as @emph{packs} or abbreviated forms, that you might want
367 to become familiar with in order to use an application's @cmdline{} to
368 its full extent.
370 @menu
371 * Option Calls::        Different ways to specify options
372 * Option Packs::        Grouping option calls together
373 * Option Separator::    Telling @clon{} to mind it's own business
374 * Option Retrieval::    How @clon{} computes the value of an option
375 @end menu
378 @c -------------
379 @c Option Calls
380 @c -------------
381 @node Option Calls, Option Packs, The Command Line, The Command Line
382 @section Option Calls
383 @cindex Command-Line, options
384 @cindex Options, command-line
386 @clon{} offers a set of precise syntactic rules that every clonified
387 application follows implicitly, making them work in a homogeneous way.
388 Although application programmers have the ability to extend @clon{} by
389 defining their own option @emph{types}, even those new options obey the
390 same syntactic rules as the built-in ones.
392 @menu
393 * Option Names::        Long, short or abbreviated
394 * Option Arguments::    None, mandatory or optional
395 @end menu
397 @node Option Names, Option Arguments, Option Calls, Option Calls
398 @subsection Option Names
399 @cindex Options, names
400 An option can come with either a short name, a long name, or both. It is
401 also possible to abbreviate long names.
403 @menu
404 * Full Names::          Long or short
405 * Abbreviations::       Shorter long names
406 @end menu
408 @node Full Names, Abbreviations, Option Names, Option Names
409 @subsubsection Full Names
410 @cindex Long Form
411 @cindex Short Form
412 @cindex Command-Line, options, long form
413 @cindex Command-Line, options, short form
414 @cindex Options, names, full
415 @cindex Options, names, long
416 @cindex Options, names, short
417 @cindex Options, command-line, long form
418 @cindex Options, command-line, short form
419 To provide an option by short name, use a @emph{short form}: a single
420 dash followed by the option's short name (@eg{} @samp{-h}). To provide
421 an option by long name, use a @emph{long form}: two dashes followed by
422 the option's long name (@eg{} @samp{--help}).
424 Short names typically consist of a single character. They are concise
425 but more difficult to remember. Long names can be whole words, or even
426 word sequences (usually separated by dashes). They are easier to
427 remember but longer to type on the @cmdline{}.
429 You should be aware of the fact that in a clonified application, neither
430 short names nor long ones are restricted in length. In fact, it would
431 be perfectly possible to have an option's short name longer than the
432 corresponding long one, although that would make little sense. The only
433 real difference is whether you use one or two dashes. Some other
434 differences also come into play when an option expects an argument
435 (@pxref{Option Arguments}) though (it would be no fun otherwise).
437 @node Abbreviations, , Full Names, Option Names
438 @subsubsection Abbreviations
439 @cindex Abbreviated Form
440 @cindex Abbreviated Long Form
441 @cindex Long Form, abbreviated
442 @cindex Options, names, abbreviated
443 @cindex Options, names, long, abbreviated
444 @cindex Command-Line, options, abbreviated form
445 @cindex Command-Line, options, abbreviated long form
446 @cindex Command-Line, options, long form, abbreviated
447 @cindex Options, command-line, abbreviated form
448 @cindex Options, command-line, abbreviated long form
449 @cindex Options, command-line, long form, abbreviated
450 When calling an option by long form, it is possible to abbreviate its
451 name, at the risk of being ambiguous. An abbreviation is simply the
452 beginning of the option's name (for instance, @samp{--he} can stand for
453 @samp{--help}). In case of ambiguity, @clon{} always chooses the option
454 which is ``closest'' to the abbreviation (here, the ``distance'' between
455 an abbreviation and an option's name is the number of missing
456 characters).
458 @node Option Arguments, , Option Names, Option Calls
459 @subsection Option Arguments
460 @cindex Arguments
461 @cindex Options, arguments
462 In @clon{}, there are different kinds of options: in addition to having
463 a short and/or long name, an option may or may not take an argument. For
464 those taking one, the argument may be either mandatory or optional.
465 Then, there is also an additional, extended call syntax for some of
466 them. But then again, that is not the whole story about getting an
467 option's value (@pxref{Option Retrieval}). If everything goes well, you
468 are now wondering whether you really want to use a @cmdline{} at all.
470 @menu
471 * Flags::                       Options with no argument
472 * Valued Options::              Options with arguments
473 * Switches::                    Options with Boolean arguments
474 @end menu
476 @node Flags, Valued Options, Option Arguments, Option Arguments
477 @subsubsection Flags
478 @cindex Flags
479 @cindex Options, types, flags
480 First of all, some options don't take an argument at all. In the @clon{}
481 jargon, these options are called @emph{flags}. Flags just stand for
482 themselves: either they are present on the @cmdline{}, or they are not
483 (as a matter of fact, this is a lie, @pxref{Option Retrieval}). A
484 typical example of a flag would be displayed like this in a standard
485 help string (but @pxref{Output}):
487 @example
488   -h, --help        Print this help and exit.
489 @end example
491 @node Valued Options, Switches, Flags, Option Arguments
492 @subsubsection Valued Options
493 @cindex Valued Options
494 @cindex Options, types, valued
495 @cindex Values
496 @cindex Options, values
497 Options taking an argument are said to be @emph{valued}. We need a bit
498 of terminology here: and option's @emph{argument} is typically what you
499 provide on the @cmdline{} (or elsewhere, @pxref{Option Retrieval}). An
500 option's argument is thus a string. An option's @emph{value} is what
501 results from the conversion of the option's argument to the proper type
502 (the same string, a number, whatever).
504 @cindex Sticky Arguments
505 @cindex Arguments, sticky
506 @cindex Options, arguments, sticky
507 @cindex Mandatory Arguments
508 @cindex Arguments, mandatory
509 @cindex Options, arguments, mandatory
510 @cindex Optional Arguments
511 @cindex Arguments, optional
512 @cindex Options, arguments, optional
513 In @clon{}, a valued option's argument can be either mandatory or
514 optional. We know that valued options, just like flags, may be provided
515 in short or long form. When using the long form, the proper way of
516 providing an argument is to append it after an @samp{=} sign, like this:
517 @samp{--phone=01020304}. When using the short form, the proper way of
518 providing an argument is to stick it right behind the option's name,
519 like this: @samp{-p01020304}. In both long and short form, we call these
520 arguments ``sticky''. All this should look familiar.
522 @cindex Separated Arguments
523 @cindex Arguments, separated
524 @cindex Options, arguments, separated
525 When the option's argument is mandatory, you also have the ability to
526 provide it in the next @cmdline{} item instead of sticking it to the
527 option's name. These arguments are said to be ``separated''. Back to the
528 previous example, this means that you can also say @samp{--phone
529 01020304} or @samp{-p 01020304}. Keep in mind that this is not possible
530 when the argument is optional (in the general case, it is not possible
531 to decide whether the next @cmdline{} item is an option's argument, a
532 new option or something else).
534 @cindex Arguments, looking like options
535 @cindex Options, as argument to other options
536 @cindex Options, arguments, looking like options
537 There is also another case where you can't use this alternate syntax,
538 even when the argument is mandatory: that is when the argument itself
539 looks like an option. @clon{} will think it is, and consequently will
540 also think that the previous one lacks its mandatory argument.
542 The phone example above would look like this in a standard help string
543 (but @pxref{Output}):
545 @example
546   -p, --phone=NUM    Set phone number to NUM.
547 @end example
549 And here is an example illustrating a typical output when the argument
550 is optional:
552 @example
553   -f, --fax[=NUM]    Set fax number to NUM, or same as phone.
554 @end example
556 @node Switches, , Valued Options, Option Arguments
557 @subsubsection Switches
558 @cindex Switches
559 @cindex Options, types, switches
560 For those of you who are not satisfied with short and long forms,
561 @clon{} provides a specific option type for Boolean values, along with
562 an additional call syntax. These options are called @emph{switches}.
564 Just like any other kind of valued option, a switch can have a short
565 and/or a long name, and its argument may be mandatory or optional.
566 However, the possible arguments for a switch are restricted to true or
567 false. In fact, you can freely use @samp{yes}, @samp{on}, @samp{true},
568 @samp{yup}, @samp{yeah} and @samp{no}, @samp{off}, @samp{false},
569 @samp{nope}, @samp{nah} respectively.@footnote{If you want more, a very
570 modest additional fee will be charged.}
572 @cindex Negated Form
573 @cindex Negated Short Form
574 @cindex Short Form, negated
575 @cindex Options, command-line, negated form
576 @cindex Options, command-line, negated short form
577 @cindex Options, command-line, short form, negated
578 @cindex Command-Line, options, negated form
579 @cindex Command-Line, options, negated short form
580 @cindex Command-Line, options, short form, negated
581 In addition to the standard short and long forms, a switch can be
582 provided in @emph{negated form}, that is, by appending its short name
583 behind a @samp{+} character. This form never takes any argument and
584 always means false (turn the switch off, if you prefer).
586 Although an application might do something different, the intended usage
587 for switches is to take an optional argument that defaults to true. A
588 typical example would look like this in a standard help string (but
589 @pxref{Output}):
591 @example
592   -(+)d, --debug[=yes/no]    Whether to enable debugging.
593 @end example
595 Given such an option, you can turn debugging on by saying just @samp{-d}
596 or @samp{--debug} (but you can also provide an explicit argument like
597 this: @samp{-dyes} or that: @samp{--debug=yes}). Similarly, to turn
598 debugging off, use @samp{+d} or @samp{--debug=no}.
600 One last word about switches: @clon{} lets application developers create
601 new options based on (but not limited to) switches. These options
602 typically accept Boolean arguments as well as some other value(s). As
603 soon as an option is switch-based (and has a short name), the negated
604 form becomes automatically available, and this should be advertised in
605 the application's help string.
608 @c ------------
609 @c Option Packs
610 @c ------------
611 @node Option Packs,  Option Separator, Option Calls, The Command Line
612 @section Option Packs
613 @cindex Packs
614 @cindex Command-Line, packs
615 @cindex Options, command-line, packed
617 In addition to using options individually (@pxref{Option Calls}),
618 @clon{} offers the possibility to group option calls together under some
619 circumstances. This feature is know as option @emph{packs}. @clon{}
620 offers two kinds of packs.
622 @menu
623 * Short Packs::         Grouping short forms together
624 * Negated Packs::       Grouping negated forms together
625 @end menu
627 @node Short Packs, Negated Packs, Option Packs, Option Packs
628 @subsection Short Packs
629 @cindex Short packs
630 @cindex Packs, short
631 @cindex Command-Line, short packs
632 @cindex Command-Line, packs, short
633 A short pack allows you to group multiple short forms in a single
634 @cmdline{} item. For instance, instead of calling your program like
635 this: @samp{program -c -u -p}, you can directly use: @samp{program
636 -cup}.
638 @cindex Options, names, short, one character
639 A short pack can only contain options the short names of which are
640 exactly one character long. Also, it should be obvious that you cannot
641 provide an argument to an option in a pack. As a consequence, only flags
642 and options with optional (and not provided) arguments may appear in a
643 short pack.
645 There is one exception however: it @emph{is} possible to provide an
646 argument to the @emph{last} option in the pack. If provided, this
647 argument must be located in the next @cmdline{} item. It cannot be
648 sticked to the option, so this means in particular that this option's
649 argument is mandatory (@pxref{Valued Options}).
651 Beware that using short packs comes at the risk of ambiguity. When
652 @clon{} parses a @cmdline{} item beginning with only one dash, it tries
653 to detect options first, options with a sticky argument next, and then
654 short packs. For that reason, you cannot possibly start a pack with a
655 valued option. Indeed, suppose that the option @samp{-c} takes an
656 argument. What you @emph{think} is a short pack (@samp{-cup}) will in
657 fact be interpreted as the option @samp{-c} with a sticky (and maybe
658 invalid) argument @samp{up}. On the other hand, if the option @samp{-u}
659 is only a flag (@pxref{Flags}), then you can safely pack your options in
660 a different order, like this: @samp{-ucp}.
662 A single @cmdline{} may contain as many short packs as you like, and
663 they can also be intermixed with regular option calls.
665 @node Negated Packs, , Short Packs, Option Packs
666 @subsection Negated Packs
667 @cindex Negated packs
668 @cindex Negated Short Packs
669 @cindex Negated packs, short
670 @cindex Packs, negated
671 @cindex Packs, short, negated
672 @cindex Command-Line, negated packs
673 @cindex Command-Line, negated short packs
674 @cindex Command-Line, short packs, negated
675 @cindex Command-Line, packs, negated
676 @cindex Command-Line, packs, short, negated
677 In a very similar way, a negated pack allows you to group multiple
678 negated forms in a single @cmdline{} item. As such, this feature only
679 applies to switches or switch-based options (@pxref{Switches}). For
680 instance, instead of calling your program like this: @samp{program +c +u
681 +p}, you can directly use: @samp{program +cup}.
683 @cindex Options, names, short, one character
684 A negated pack can only contain options the short names of which are
685 exactly one character long. Also, remember that negated forms never take
686 any argument.
688 Beware that using negated packs comes at the risk of ambiguity (although
689 much less than with short packs). When @clon{} parses a @cmdline{} item
690 beginning with a @samp{+}, it tries to detect options first, and then
691 negated packs. For that reason, the order in which you specify the
692 options in the pack is important. Indeed, suppose that your application
693 has a @samp{+cup} switch (this would be a very bad idea, but
694 still@dots{}). If you want to provide the same pack as above, then you
695 need to modify the options order, like this: @samp{+ucp}.
697 A single @cmdline{} may contain as many negated packs as you like, and
698 they can also be intermixed with regular option calls or short packs.
701 @c ----------------
702 @c Option Separator
703 @c ----------------
704 @node Option Separator, Option Retrieval, Option Packs, The Command Line
705 @section Option Separator
706 @cindex Separator
707 @cindex Command-Line, separator
708 @cindex Postfix
709 @cindex Command-Line, postfix
711 @clon{} separates the @cmdline{} in two parts. The left part contains
712 option calls and packs while the right part contains the rest. The right
713 part is also called the @emph{postfix}).
715 @cindex Explicit separator
716 @cindex Separator, explicit
717 @cindex Command-Line, explicit separator
718 @cindex Command-Line, separator, explicit
719 You can force this distinction by using the special construct @samp{--}
720 on the @cmdline{}. Everything that follows it will be completely ignored
721 by @clon{} (not necessarily by the application itself though).
723 @cindex Implicit separator
724 @cindex Separator, implicit
725 @cindex Command-Line, implicit separator
726 @cindex Command-Line, separator, implicit
727 In the case you don't split your @cmdline{} explicitly, @clon{} does
728 this for you automatically by noticing where the last option (or its
729 potential argument) stands. The behavior is different from that of
730 explicit splitting in one regard however: if the application is not
731 expecting any postfix and there's an implicit one, then @clon{} will
732 throw an error at your face.
734 @cindex Postfix, options in
735 @cindex Options, in postfix
736 @cindex Command-Line, postfix, options in
737 @cindex Command-Line, options, in postfix
738 One final note on @cmdline{} separation: in the case an application's
739 postfix is supposed to contain something looking like an option (perhaps
740 real options to pass on to another program), you @strong{need} an
741 explicit separator. Otherwise, @clon{} will be confused: it could for
742 instance wrongly detect unknown options, junk on the @cmdline{} @etc{}
744 You don't want to confuse @clon{}. @clon{} is nasty when it is scared.
748 @c ----------------
749 @c Option Retrieval
750 @c ----------------
751 @node Option Retrieval, , Option Separator, The Command Line
752 @section Option Retrieval
754 @cindex Retrieval
755 @cindex Options, retrieval
756 The process of getting a value for a specific option is called
757 @dfn{retrieval}. This section explains how it works.
759 @menu
760 * Value Sources::       The command-line, and more
761 * Error Management::    What to do when something goes wrong
762 @end menu
764 @node Value Sources, Error Management, Option Retrieval, Option Retrieval
765 @subsection Value Sources
766 The @cmdline{} is not the only place where @clon{} looks for option
767 @emph{values}. Other sources for option values are: @emph{fallback}
768 values, @emph{environment} variables and @emph{default} values. The
769 existence of a fallback value, environment variable or default value
770 should be advertised in the application's help string (@pxref{Output}).
772 @itemize @bullet
773 @item
774 @cindex Fallback values
775 @cindex Values, fallback
776 @cindex Retrieval, from fallback value
777 @cindex Options, retrieval, from fallback value
778 Fallback values are used when an option exists on the @cmdline{} without
779 a corresponding argument (so this applies only to options taking
780 @emph{optional} arguments only).
781 @item
782 @cindex Environment
783 @cindex Retrieval, from environment
784 @cindex Options, retrieval, from environment
785 Applications may also associate an option with a specific environment
786 variable which contains a value for it.
787 @item
788 @cindex Default values
789 @cindex Values, default
790 @cindex Retrieval, from default value
791 @cindex Options, retrieval, from default value
792 Finally, default values are used when every other source has failed.
793 @end itemize
795 When @clon{} attempts to retrieve a value for a particular option, it
796 always does so in a specific order: first, the @cmdline{} is searched.
797 If an argument is present, it is used. Otherwise, a fallback or default
798 value is used in that order (note that when an option's argument is
799 optional, the option is required to provide at least a fallback or a
800 default value). Next, an environment variable is tried (when
801 appropriate). Finally, when everything else fails, the option's default
802 value is used (if any).
804 @cindex Retrieval, from command-line
805 @cindex Command-Line, retrieval
806 @cindex Options, retrieval, from command-line
807 @clon{} always scans the @cmdline{} from left to right, and stops at the
808 first match. Please note that the match in question may be a regular
809 option call or a pack, depending on what appears first on the
810 @cmdline{}. There is no concept of priority amongst option forms.
812 @cindex Options, multiple calls
813 Also, note that it is possible to provide several calls to the same
814 option on a single @cmdline{}. Some applications may take advantage of
815 this: every consecutive request for an option will use the next match on
816 the @cmdline{} until there is none left.
818 @cindex Flags
819 @cindex Options, types, flags
820 @cindex Environment
821 @cindex Retrieval, from environment
822 @cindex Options, retrieval, from environment
823 Finally, note that fallback or default values don't make any sense for
824 flags, but flags can still be associated with environment variables. In
825 such a case, the very @emph{existence} of the variable in the
826 environment, regardless of its value, stands for the presence of the
827 corresponding option on the @cmdline{}.
829 @node Error Management, , Value Sources, Option Retrieval
830 @subsection Error Management
831 @cindex Error Management
832 @cindex Retrieval, errors
833 @cindex Options, retrieval, errors
834 OK, now you're completely overwhelmed by the power and flexibility of
835 @clon{}, to the point that the fact that you didn't write it (because
836 @emph{I} did) even starts to upset you. So I know what you're thinking:
837 ``there's gotta be a way to break it''. I don't know, like, giving a
838 value to a flag, using an unknown option, providing an invalid value for
839 an option, using an equal sign in a negated call @etc{}
841 Unfortunately for you, @clon{} is like a pitbull. Whatever you do to
842 beat it, it @emph{will} fight back. The behavior of @clon{} with respect
843 to error management during option retrieval is well defined, but
844 contrary to the traditional approach, @emph{you}, the end-user have
845 control over it. Not the application. Error handling may occur when the
846 @cmdline{} is parsed, but also when environment variables are used.
848 @bioindex{error-handler}
849 @bievindex{ERROR_HANDLER}
850 The error management behavior of @clon{} is controlled by a built-in
851 option named @bioption{error-handler}, and its accompanying environment
852 variable @code{CLON_ERROR_HANDLER}. Possibles values for it are
853 currently the following.
855 @table @t
856 @item quit
857 @cindex Error Management, quitting
858 This is the default. It means that when @clon{} encounters an error
859 related to option retrieval, it prints an informative message about the
860 error and terminates the application immediately (with an exit status of
861 1). This is the behavior of most programs out there I guess.
862 @item interactive
863 When interactive error handling is selected and an error is signaled,
864 you are presented with a list of possible options to ``fix'' the
865 problem. Such options include notably the ability to modify an option's
866 name or value (handy in case of @cmdline{} typo), discard the call
867 altogether and many others, depending on the exact error.
869 When the error implies a bad value for a particular option, you will
870 notice that some of the choices that @clon{} proposes in order to fix
871 the problem involve providing another @emph{value} or another
872 @emph{argument}. Again, you need to remember the terminology here
873 (@pxref{Valued Options}). The argument is what you provide on the
874 @cmdline{}, and the value is the conversion of the argument to the
875 proper type. This means that most of the time, you will want to use the
876 ``argument'' choice. If you know the @cl{} language (see below), you can
877 also provide a value directly, in which case what you type in is in fact
878 @cl{} code.
879 @item none
880 @cindex Debugger
881 @cindex Error Management, interactive debugging
882 @i{Using this option is not encouraged, unless you are the author of the
883 application and you are debugging it.} A value of @code{none} literally
884 means no particular error handler. Here, I must apologize because I need
885 to go into some technical details about @cl{}, the language in which
886 applications using @clon{} are written. @cl{} mandates the existence of
887 a @dfn{debugger} in which you are dropped in when an unhandled error
888 condition is thrown. However some @cl{} implementations may disable the
889 debugger when creating standalone programs. So the situation when the
890 @clon{} error handler is set to @code{none} depends on the application.
891 @end table
893 One last note about the @bioption{error-handler} option: we have a
894 chicken-and-egg problem with it. The error handler must be known for
895 parsing the @cmdline{}, but in order to get it, we need to retrieve the
896 option which implies parsing the @cmdline{}@dots{} Whoops. Because of
897 this problem, the option is treated in a very special way.
899 @enumerate
900 @item
901 First of all, a built-in default value of @code{quit} is used initially.
902 @item
903 However, if the @code{CLON_ERROR_HANDLER} environment variable is set,
904 its value will be used immediately, even before trying to get the option
905 on the @cmdline{} (if an error happens when trying the environment
906 variable, the @code{quit} handler is used).
907 @item
908 Finally, if the option is found on the @cmdline{} during the parsing of
909 it, its value is updated immediately (so it also applies for parsing the
910 rest of the @cmdline{}).
911 @end enumerate
913 Now you need to get some rest.
917 @c ====================================================================
918 @c Output
919 @c ====================================================================
920 @node Output, Conclusion, The Command Line, Top
921 @chapter Output
923 In the previous chapter, we have seen how to make the best usage of a
924 clonified application's command-line. The second aspect we need to look
925 at is @clon{}'s output, typically what you get when you type
926 @command{program --help}. From an end-user perspective, one key feature
927 of @clon{} is that control on the formatting of the help strings is
928 given to @emph{you} instead of being the programmer's responsibility.
929 What this means is that @emph{you} get to choose the way you want help
930 strings to be formatted, and all of a sudden, every clonified
931 application you use will conform to your specifications.
933 @ref{Output Elements} surveys the different items composing a @clon{}
934 help string by looking at examples in a default setting. @ref{Theme
935 Mechanism} explains how to switch between predefined layouts.
936 @ref{Global Control} describe two built-in options that give you some
937 control over the layout on a global scale. Finally, @ref{Theme Creation}
938 describes how to build your own layouts.
940 @menu
941 * Output Elements::     What appears in help strings
942 * Theme Mechanism::     Switching between available layouts
943 * Global Control::      Line width and highlighting
944 * Theme Creation::      Building your own layouts
945 @end menu
947 @c ---------------
948 @c Output Elements
949 @c ---------------
950 @node Output Elements, Theme Mechanism, Output, Output
951 @section Output Elements
952 Let's look at the output of @command{program --help} in a default
953 setting first:
955 @cartouche
956 @verbatim
957 Usage: program [-hdF] [+d] [OPTIONS] FILES...
959 A clonified program.
961   -h, --help                  Print this help and exit.
962 Runtime options:
963   -(+)d, --debug[=yes/no]     Turn debugging on or off.
964                               Fallback: yes
965                               Environment: DEBUG
966                               Default: no
967   --simulate=yes/no           Simulate only. Nothing will happen for real,
968                               except for log messages.
969 User identification:
970   -f, --first-name=STR        Set the user's first name to STR.
971   -F, --family-name[=NAME]    Set the user's family name to NAME.
972                               Fallback: unknown
973 @end verbatim
974 @end cartouche
976 @cindex Synopsis
977 @cindex Output, synopsis
978 @cindex Postfix
979 @cindex Short packs
980 @cindex Packs, short
981 @cindex Negated packs
982 @cindex Negated Short Packs
983 @cindex Negated packs, short
984 @cindex Packs, negated
985 @cindex Packs, short, negated
986 The first line of output is what's called the @emph{synopsis}. This
987 synopsis indicates that the program accepts a number of options and also
988 a postfix consisting of file names. The set of available options is not
989 detailed in the synopsis but for convenience, @clon{} shows the
990 available short and negated packs explicitly.
992 @cindex Text
993 @cindex Arbitrary Text
994 @cindex Text, arbitrary
995 The next non-empty line is just text. A clonified application is free to
996 put arbitrary text anywhere in its help string. This can be used to
997 describe what the application is about for instance.
999 @cindex Groups
1000 @cindex Arbitrary Text, in groups
1001 @cindex Text, in groups
1002 @cindex Options, in groups
1003 @cindex Groups, in groups
1004 @cindex Groups, titles
1005 Two other lines in the help string look like arbitrary text, but in fact
1006 are not: ``Runtime options:'' and ``User identification:''. These are
1007 not arbitrary text, but @emph{group titles}. A group is a way of putting
1008 help string items together, for instance because they are related to the
1009 same topic. A group has an optional title, and may contain options,
1010 arbitrary text or even sub-groups.
1012 @cindex Groups
1013 @cindex Groups, built-in
1014 @bioindex{help}
1015 In addition to displaying the full help string, a clonified application
1016 may display a group's help string only (in such a case, you don't get to
1017 see the synopsis). This is what happens when you type @command{program
1018 --clon-help} for instance. @clon{}'s built-in options belong to a
1019 reserved built-in group.
1021 @cindex Flags
1022 @cindex Options, types, flags
1023 @cindex Valued Options
1024 @cindex Options, types, valued
1025 @cindex Switches
1026 @cindex Options, types, switches
1027 @cindex Long Form
1028 @cindex Short Form
1029 @cindex Command-Line, options, long form
1030 @cindex Command-Line, options, short form
1031 @cindex Negated Form
1032 @cindex Negated Short Form
1033 @cindex Short Form, negated
1034 @cindex Options, command-line, negated form
1035 @cindex Options, command-line, negated short form
1036 @cindex Options, command-line, short form, negated
1037 @cindex Command-Line, options, negated form
1038 @cindex Command-Line, options, negated short form
1039 @cindex Command-Line, options, short form, negated
1040 Let's have a look at the options now. In the first column, you can see
1041 that depending on the option, the long, short and negated forms are
1042 advertised. Valued options also advertise their argument, enclosed in
1043 square brackets when it is optional. In this example, @samp{-h} is a
1044 flag, @samp{-d} and @samp{--simulate} are switches with different
1045 settings, while @samp{-f} and @samp{-F} are standard valued options.
1047 @cindex Options, description
1048 The second column of the help string provides each option's
1049 @emph{description}. Descriptions can span across several lines, as in
1050 the case of @samp{--simulate}. @clon{} takes care of properly aligning
1051 all the material that needs to be displayed.
1053 @cindex Fallback values
1054 @cindex Values, fallback
1055 @cindex Environment
1056 @cindex Default values
1057 @cindex Values, default
1058 Finally, you can see that potential fallback values, environment
1059 variables and default values are also advertised in that order, when
1060 appropriate.
1064 @c ---------------
1065 @c Theme Mechanism
1066 @c ---------------
1067 @node Theme Mechanism, Global Control, Output Elements, Output
1068 @section Theme Mechanism
1069 @cindex Theme Mechanism
1071 @cindex Themes
1072 @cindex Themes, built-in
1073 @cindex Themes, built-in, @t{raw}
1074 @cindex Built-in themes
1075 @cindex Built-in themes, @t{raw}
1076 The output of @command{program --help} that we have seen in the previous
1077 section corresponds to a default setting, but is really just one
1078 possibility. As the user of a clonified application, you have the
1079 ability to customize the appearance of @clon{}'s output. The way things
1080 look is specified by so-called @emph{themes}. @clon{} has a theme named
1081 @t{raw} which every clonified application has built-in.
1083 @cindex Themes, files
1084 @cindex Themes, files, @t{cth} extension
1085 @cindex @t{cth} extension
1086 @cindex File Extension
1087 @cindex File Extension, @t{cth}
1088 Other themes are stored in files the standard extension of which is
1089 @samp{cth} (as in @b{C}lon @b{TH}eme). In fact, theme files can be named
1090 as you like; this is just a convention.
1092 @menu
1093 * Standard Themes::     Some example themes are provided
1094 * Search Path::         Where to find theme files
1095 * Theme Selection::     How to select a theme
1096 @end menu
1098 @node Standard Themes, Search Path, Theme Mechanism, Theme Mechanism
1099 @subsection Standard Themes
1100 @cindex Themes, files, standard
1101 @cindex Standard Themes
1102 @cindex Standard Themes, files
1103 @clon{} comes with several standard themes in files that can be used
1104 as-is or serve as the basis for creating new ones (@pxref{Theme
1105 Creation}). The list is given below.
1107 @table @t
1108 @item raw
1109 @cindex Standard Themes, files, @file{raw.cth}
1110 @cindex Themes, files, standard, @file{raw.cth}
1111 Exactly the same as the built-in one, only copied into a theme file.
1112 @item optlist
1113 @cindex Standard Themes, files, @file{optlist.cth}
1114 @cindex Themes, files, standard, @file{optlist.cth}
1115 Displays only a list of available options, one per line, without any
1116 description, group indication or arbitrary text. This can be used to
1117 quickly remember the name or the syntax of an option.
1118 @item refcard
1119 @cindex Standard Themes, files, @file{refcard.cth}
1120 @cindex Themes, files, standard, @file{refcard.cth}
1121 Displays a very compact help string. The synopsis is there, so are the
1122 group titles and arbitrary texts, but the options are displayed without
1123 any description, and the lines are filled as much as possible. The
1124 intent of this theme is to produce some sort of ``reference card'' that
1125 could be printed.
1126 @item roomy
1127 @cindex Standard Themes, files, @file{roomy.cth}
1128 @cindex Themes, files, standard, @file{roomy.cth}
1129 Displays a full help string occupying more space than the @t{raw} theme.
1130 Option descriptions don't start @emph{after} the option's name, but
1131 @emph{under} it. As a result, they occupy more horizontal space. Also,
1132 sub-groups are indented to the right.
1133 @item dvl
1134 @cindex Standard Themes, files, @file{dvl.cth}
1135 @cindex Themes, files, standard, @file{dvl.cth}
1136 This is my personal theme that I personally use myself in person.
1137 @item christmas
1138 @cindex Standard Themes, files, @file{christmas.cth}
1139 @cindex Themes, files, standard, @file{christmas.cth}
1140 This one is full of bells and whistles, which makes it essentially
1141 unusable. It exists only to provide a concrete example of all the
1142 available formatting and highlighting features of @clon{}. The
1143 @t{christmas} theme is only available once a year, at exactly 23:59:59
1144 on December the 24th.
1145 @end table
1147 @node Search Path, Theme Selection, Standard Themes, Theme Mechanism
1148 @subsection Search Path
1149 @cindex Search Path
1150 @cindex Search Path, themes
1151 @cindex Themes, search path
1152 @clon{} maintains a search path for looking up files. Theme files are
1153 supposed to be located in a @file{themes} directory of every
1154 directory in the search path. By default, the search path is as follows:
1155 @itemize @w{}
1156 @item
1157 @t{~/.clon/}
1158 @item
1159 @t{~/Library/Application Support/Clon/} (MacOS only)
1160 @item
1161 @t{~/share/clon/}
1162 @item
1163 @t{/Library/Application Support/Clon/} (MacOS only)
1164 @item
1165 @t{/usr/local/share/clon/}
1166 @item
1167 @t{/usr/share/clon/}
1168 @end itemize
1170 @bioindex{search-path}
1171 @bievindex{SEARCH_PATH}
1172 The search path can be modified with the @bioption{search-path} built-in
1173 option or its accompanying @env{CLON_SEARCH_PATH} environment variable.
1174 It takes a list of colon-separated directories as argument. This
1175 argument is in fact optional. Not providing an argument is equivalent to
1176 providing an empty one, which basically reduces the search path to the
1177 application's current directory.
1180 @node Theme Selection, , Search Path, Theme Mechanism
1181 @subsection Theme Selection
1182 @bioindex{theme}
1183 @bievindex{THEME}
1184 In order to select a theme, you can use the built-in option
1185 @bioption{theme} or its accompanying environment variable
1186 @env{CLON_THEME}. Just provide it with the theme name, and the
1187 corresponding theme file will be looked up in the search path
1188 (@pxref{Search Path}), stopping at the first match.
1190 @cindex File Extension, @t{cth}
1191 @cindex @t{cth} extension
1192 @cindex Themes, files, @t{cth} extension
1193 You can omit the @samp{cth} extension: @clon{} looks for a file named
1194 exactly as you said first and attempts to add the theme extension next.
1195 Note that searching with or without extension has priority over the
1196 search path. For instance, suppose that the following files exist:
1197 @itemize @w{}
1198 @item
1199 @t{/usr/local/share/clon/themes/foobar}
1200 @item
1201 @t{/usr/share/clon/themes/foobar.cth}
1202 @end itemize
1203 Using @bioption{theme=foobar} will match the first one while
1204 @bioption{theme=foobar.cth} will match the second.
1206 Now suppose that the following files exist:
1207 @itemize @w{}
1208 @item
1209 @t{/usr/local/share/clon/themes/foobar.cth}
1210 @item
1211 @t{/usr/share/clon/themes/foobar}
1212 @end itemize
1213 Using either @bioption{theme=foobar} or @bioption{theme=foobar.cth} will
1214 always match the first file. Which brings us to the next point (how
1215 clever).
1217 It is possible to bypass the search path when looking for a theme: just
1218 provide @bioption{theme} with a theme name starting with a path
1219 component (@ie{} @samp{/}, @samp{./} or @samp{../}). Even in that case,
1220 you can still omit the @samp{cth} extension.
1222 @cindex Built-in themes, @t{raw}
1223 @cindex Themes, built-in, @t{raw}
1224 @cindex Standard Themes, files, @file{raw.cth}
1225 @cindex Themes, files, standard, @file{raw.cth}
1226 Finally, here is an important precision about @bioption{theme}. This
1227 option has a fallback of @t{nil} and a default of @t{raw}. This means
1228 that if you don't use the option at all, a theme named @t{raw} will be
1229 looked up in the search path. This theme exists in the standard
1230 distribution and you are free to modify it. On the other hand, since
1231 this option has a fallback, it means that its argument is optional. If
1232 you don't provide any argument (that is, if you just use
1233 @bioption{theme}), then the @emph{built-in} raw theme will be used. This
1234 theme is originally identical to the one provided in the file
1235 @file{raw.cth} but since it is built in every clonified application, you
1236 cannot change it.
1239 @c --------------
1240 @c Global Control
1241 @c --------------
1242 @node Global Control, Theme Creation, Theme Mechanism, Output
1243 @section Global Control
1245 In addition to selecting the appropriate theme, @clon{} provides two
1246 built-in options that give you additional control on the output. These
1247 options are orthogonal to themes: all themes implicitly honor them.
1248 Since their description is pretty self-explanatory, they are given
1249 below.
1251 The first one allows you to control the output's line width:
1252 @bioindex{line-width}
1253 @bievindex{LINE_WIDTH}
1254 @evindex{COLUMNS}
1255 @verbatim
1256   --clon-line-width=WIDTH     Set Clon's output line width.
1257                               If not given, the value of the COLUMNS
1258                               environment variable, the terminal size,
1259                               or a default of 80 columns will be used.
1260                               Environment: CLON_LINE_WIDTH
1261 @end verbatim
1263 The second one deals with @emph{highlighting} (@pxref{Highlight}).
1264 @clon{} has the ability to highlight the output through ISO/IEC 6429 SGR
1265 escape sequences. The built-in raw theme doesn't do highlighting but
1266 other do.
1267 @bioindex{highlight}
1268 @bievindex{HIGHLIGHT}
1270 @verbatim
1271   --clon-highlight[=ARG]      Set Clon's output highlighting to on/off/auto.
1272                               Auto (the default) means on for tty output and
1273                               off otherwise.
1274                               Fallback: yes
1275                               Default: auto
1276                               Environment: CLON_HIGHLIGHT
1277 @end verbatim
1279 A word of caution is in order here. For technical reasons (in fact, the
1280 potential inability to detect a terminal properly), it is possible that
1281 the @code{auto} setting for @bioption{highlight}, which happens to be
1282 the default, doesn't work. In such a case, highlight is switched off,
1283 and you need to use @bioption{highlight=yes} explicitely to force it.
1285 For the same technical reason, it may be impossible to detect a terminal
1286 line width from time to time, in which case it would fall back to 80
1287 columns. This particular problem is much less likely to bite you because
1288 the @code{COLUMNS} environment variable should be set all the time.
1290 Both of these problems may or may not occur for specific applications,
1291 depending on their underlying implementation.
1294 @c ---------------
1295 @c Theme Creation
1296 @c ---------------
1297 @node Theme Creation, , Global Control, Output
1298 @section Theme Creation
1299 Perhaps the most exciting thing in Computer Science is to spend more
1300 time hacking a tool than actually using it. After reading this section,
1301 you will find yourselves spending days customizing theme files instead
1302 of using clonified applications.
1304 @menu
1305 * Theme Elements::      Faces, properties, comments
1306 * Faces::               Boy, you look just like your mother
1307 * Highlight::           Text Appearance
1308 * Layout::              Text geometry
1309 * Implicit Faces::      Missing definitions and siblings
1310 @end menu
1312 @node Theme Elements, Faces, Theme Creation, Theme Creation
1313 @subsection Theme Elements
1314 @cindex Faces
1315 @cindex Face Properties
1316 @cindex Themes, faces
1317 @cindex Themes, faces, properties
1318 Hear hear! If you understand what @command{M-x all-hail-[x]emacs} means,
1319 you're going to get quite comfy here. @clon{} themes are articulated
1320 around two basic concepts: @emph{faces} and (face) @emph{properties}. A
1321 property describes some visual attribute for some piece of text, for
1322 instance bold, red, indented by 2 columns to the right. A face is more
1323 or less a set of properties (but there's more to it than that; please
1324 hold your post). Every piece of text in @clon{}'s output is associated
1325 with a face, which in turn defines specific values for specific
1326 properties.
1328 @cindex Layout Properties
1329 @cindex Faces, properties, layout
1330 @cindex Themes, faces, properties, layout
1331 @cindex Highlight Properties
1332 @cindex Faces, properties, highlight
1333 @cindex Themes, faces, properties, highlight
1334 There are two property types in @clon{}: @emph{highlight properties},
1335 which describe the visual appearance of characters (color, font @etc{}),
1336 and @emph{layout properties}, which describe the text geometry (line
1337 width, indentation @etc{}). Please see @ref{Highlight Properties} and
1338 @ref{Layout Properties} for an exhaustive list of them.
1340 Let's have a look at a very simple theme file now.
1342 @cartouche
1343 @verbatim
1344 ;; A very simple theme file.
1346 :background black
1347 ;; ...
1349 :face (synopsis :foreground red
1350                 ;; ...
1351                 :face (header :bold t #| ...|#)
1352                 #| ... |#)
1353 ;; ...
1354 @end verbatim
1355 @end cartouche
1357 @cindex Themes, files, comments
1358 The first line is a comment. Comments begin with a semi-colon and extend
1359 to the end of the line. There is another syntax for comments, as show
1360 later in the file: a comment can be opened with @samp{#|} and closed
1361 with @samp{|#}. This form allows you to create comments that span across
1362 several lines, or just part of a single line.@footnote{By now, you have
1363 realized that a theme file is just a piece of @cl{} code@dots{} No,
1364 wait! Don't go!}
1366 @cindex Face Properties
1367 @cindex Themes, faces, properties
1368 @cindex Themes, files, keywords
1369 @cindex Themes, files, keywords, @t{:background}
1370 @cindex Faces, @t{toplevel}
1371 @cindex Themes, faces, @t{toplevel}
1372 The next line sets the @samp{background} property to @samp{black}. It
1373 means that @clon{}'s output will be displayed over a black background
1374 (no kidding). Every property in @clon{} has a name, which you specify by
1375 using a @emph{keyword} (@ie{} the name prepended with a colon). But
1376 wait, properties are supposed to belong to faces, right? So what is that
1377 property doing, floating around like that in the file? That's right,
1378 clever. In fact, the whole output of @clon{} is wrapped in a global face
1379 called @samp{toplevel}. You will never need to mention this face
1380 explicitly, though, because the contents of theme files is always
1381 enclosed in that face.
1383 @cindex Themes, files, keywords
1384 @cindex Themes, files, keywords, @t{:face}
1385 @cindex Themes, files, keywords, @t{:foreground}
1386 @cindex Themes, files, keywords, @t{:bold}
1387 @cindex Faces, @t{synopsis}
1388 @cindex Themes, faces, @t{synopsis}
1389 @cindex Faces, @t{header}
1390 @cindex Themes, faces, @t{header}
1391 Later in the file, you find yourself contemplating a face specification.
1392 Faces are specified by using the keyword @samp{:face}. What follows is a
1393 list beginning with the face name, and continuing with property
1394 specifications. In this particular example, we're specifying that the
1395 synopsis line (the one that says ``Usage: blah blah'') should appear in
1396 red, although as you can see, the story does not stop there.
1398 @cindex Faces, nesting
1399 @cindex Themes, faces, nesting
1400 @cindex Face properties, inheritance
1401 Indeed, there is also a @samp{header} face specification @emph{within}
1402 the @samp{synopsis} one. What it says it that the header part (the
1403 ``Usage:'' portion of the synopsis line) should additionally be
1404 displayed in bold font. So it turns out that face specifications can be
1405 nested. In fact, @emph{all} the faces you specify are sub-faces of the
1406 @samp{toplevel} face at some level. In this example, the @samp{header}
1407 face is a sub-face of the @samp{synopsis} one. This is important for two
1408 reasons:
1409 @enumerate
1410 @item
1411 face nesting leads to the notion of property inheritance
1412 (@pxref{Highlight Inheritance}),
1413 @item
1414 @clon{} makes use of faces with the same name in different (nesting)
1415 contexts. For instance, there are many places where the @samp{header}
1416 face is used (@pxref{Faces}), but this face can have very different
1417 specifications according to where it appears in a face tree.
1418 @end enumerate
1420 @node Faces, Highlight, Theme Elements, Theme Creation
1421 @subsection Faces
1422 @cindex Faces
1423 @cindex Themes, faces
1425 @cindex Built-in themes, @t{raw}
1426 @cindex Themes, built-in, @t{raw}
1427 @cindex Standard Themes, files, @file{raw.cth}
1428 @cindex Themes, files, standard, @file{raw.cth}
1429 @cindex Faces, @t{synopsis}
1430 @cindex Faces, @t{header}
1431 @cindex Faces, @t{program}
1432 @cindex Faces, @t{short-pack}
1433 @cindex Faces, @t{negated-pack}
1434 @cindex Faces, @t{options}
1435 @cindex Faces, @t{postfix}
1436 @cindex Faces, @t{text}
1437 @cindex Faces, @t{option}
1438 @cindex Faces, @t{syntax}
1439 @cindex Faces, @t{short}
1440 @cindex Faces, @t{name}
1441 @cindex Faces, @t{argument}
1442 @cindex Faces, @t{long}
1443 @cindex Faces, @t{usage}
1444 @cindex Faces, @t{description}
1445 @cindex Faces, @t{fallback}
1446 @cindex Faces, @t{value}
1447 @cindex Faces, @t{default}
1448 @cindex Faces, @t{environment}
1449 @cindex Faces, @t{variable}
1450 @cindex Themes, faces, @t{synopsis}
1451 @cindex Themes, faces, @t{header}
1452 @cindex Themes, faces, @t{program}
1453 @cindex Themes, faces, @t{short-pack}
1454 @cindex Themes, faces, @t{negated-pack}
1455 @cindex Themes, faces, @t{options}
1456 @cindex Themes, faces, @t{postfix}
1457 @cindex Themes, faces, @t{text}
1458 @cindex Themes, faces, @t{option}
1459 @cindex Themes, faces, @t{syntax}
1460 @cindex Themes, faces, @t{short}
1461 @cindex Themes, faces, @t{name}
1462 @cindex Themes, faces, @t{argument}
1463 @cindex Themes, faces, @t{long}
1464 @cindex Themes, faces, @t{usage}
1465 @cindex Themes, faces, @t{description}
1466 @cindex Themes, faces, @t{fallback}
1467 @cindex Themes, faces, @t{value}
1468 @cindex Themes, faces, @t{default}
1469 @cindex Themes, faces, @t{environment}
1470 @cindex Themes, faces, @t{variable}
1471 The following figure shows the full face tree defined by @clon{}. In
1472 fact, it is extracted from the theme file @file{raw.cth} (property
1473 specifications have been removed). By the way, that is why it is a good
1474 idea to start from this one when you want to create a new theme: all the
1475 faces are in there. It should be pretty easy to figure out what portion
1476 of text each face applies to.
1478 @cartouche
1479 @verbatim
1480 ;; Remember that everything in here belongs to the toplevel face.
1481 :face (synopsis :face header
1482                 :face program
1483                 :face short-pack
1484                 :face negated-pack
1485                 :face options
1486                 :face postfix)
1487 :face text
1488 :face (option :face (syntax :face (short :face name
1489                                          :face argument)
1490                             :face (long  :face name
1491                                          :face argument))
1492               :face (usage :face description
1493                            :face (fallback :face header
1494                                            :face value)
1495                            :face (default :face header
1496                                           :face value)
1497                            :face (environment :face header
1498                                               :face variable)))
1499 :face (group :face header
1500              :face (items #| :face text :face option :face group |#))
1501 @end verbatim
1502 @end cartouche
1504 As mentioned earlier, you can see that faces of the same name may appear
1505 at different places in the tree (@eg{} the @samp{header} one) and hence
1506 may have different specifications, depending on the context (their
1507 branch in the tree).
1509 Pushing this idea one step further, note the peculiarity of the
1510 @samp{group} face: since group items may be arbitrary text, options or
1511 even sub-groups, you can specify as many levels of group nesting as you
1512 want. In fact, you can spend your whole life specifying sub-groups,
1513 although it is very unlikely that a clonified application provides more
1514 than two or three levels of group imbrication.
1516 One last point to note: you might be surprised to find @emph{empty} face
1517 specifications like this one: @samp{:face description}. This @emph{is} a
1518 valid specification, and this @emph{is} different from not mentioning
1519 the face at all, or specifying some properties explicitly. See
1520 @ref{Layout Inheritance} for an explanation.
1523 @node Highlight, Layout, Faces, Theme Creation
1524 @subsection Highlight
1525 The first category of properties that we are going to describe deals
1526 with @emph{highlighting}, that is, modifying the visual aspect of
1527 characters in the output.
1529 @menu
1530 * Highlight Properties::        What is available
1531 * Highlight Inheritance::       What happens in a face tree
1532 @end menu
1534 @node Highlight Properties, Highlight Inheritance, Highlight, Highlight
1535 @subsubsection Highlight Properties
1536 @cindex Highlight Properties
1537 @cindex Faces, properties, highlight
1538 @cindex Themes, faces, properties, highlight
1539 @clon{} supports 10 highlight properties defined by the ISO/IEC 6429 SGR
1540 standard (under the assumption that your favorite terminal program
1541 supports them). Their description is given below.
1543 @table @t
1544 @item :foreground
1545 @cindex Face Properties, highlight, @t{foreground}
1546 @cindex Themes, faces, properties, highlight, @t{foreground}
1547 @cindex Themes, files, keywords, @t{:foreground}
1548 @item :background
1549 @cindex Face Properties, highlight, @t{background}
1550 @cindex Themes, faces, properties, highlight, @t{background}
1551 @cindex Themes, files, keywords, @t{:background}
1552 The face's foreground and background colors. Possible values are
1553 @t{black}, @t{red}, @t{green}, @t{yellow}, @t{blue}, @t{magenta},
1554 @t{cyan} and @t{white}. It is also possible to use the special values
1555 @t{nil} or @t{reset} to reset the color to the terminal's default value.
1556 @item :intensity
1557 @cindex Face Properties, highlight, @t{intensity}
1558 @cindex Themes, faces, properties, highlight, @t{intensity}
1559 @cindex Themes, files, keywords, @t{:intensity}
1560 The face's intensity. Possible values are @t{bold}, @t{normal} (or
1561 @t{nil}) and @t{faint}. Please note that @t{faint} is usually not very
1562 well supported.
1563 @cindex Face Properties, highlight, @t{bold}
1564 @cindex Themes, faces, properties, highlight, @t{bold}
1565 @cindex Themes, files, keywords, @t{:bold}
1566 For convenience, a @t{:bold} Boolean property is also provided which
1567 will set the face's intensity to @t{bold} if true (@t{t}) and @t{normal}
1568 if false (@t{nil}).
1569 @item :italic
1570 @cindex Face Properties, highlight, @t{italic}
1571 @cindex Themes, faces, properties, highlight, @t{italic}
1572 @cindex Themes, files, keywords, @t{:italic}
1573 Whether to display the face's contents in italics. This is a Boolean
1574 property. Possible values are @t{t} or @t{nil}. The effect of this
1575 property depends a lot on the font you use in your terminal application.
1576 @item :underline
1577 @cindex Face Properties, highlight, @t{underline}
1578 @cindex Themes, faces, properties, highlight, @t{underline}
1579 @cindex Themes, files, keywords, @t{:underline}
1580 Whether to underline the face's contents. Possible values are @t{single}
1581 (or @t{on} or @t{t}), @t{double} and @t{none} (or @t{off} or @t{nil}).
1582 Please note that @t{double} is usually not very well supported.
1583 @item :blink
1584 @cindex Face Properties, highlight, @t{blink}
1585 @cindex Themes, faces, properties, highlight, @t{blink}
1586 @cindex Themes, files, keywords, @t{:blink}
1587 The face's blink speed. Possible values are @t{slow} (or @t{on} or
1588 @t{t}), @t{rapid} and @t{off} (or @t{nil}). Please note that @t{rapid}
1589 is usually not very well supported.
1590 @item :inverse
1591 @cindex Face Properties, highlight, @t{inverse}
1592 @cindex Themes, faces, properties, highlight, @t{inverse}
1593 @cindex Themes, files, keywords, @t{:inverse}
1594 Whether to display the face's contents in inverse video. This is a
1595 Boolean property. Possible values are @t{t} or @t{nil}.
1596 @item :crossed-out
1597 @cindex Face Properties, highlight, @t{crossed-out}
1598 @cindex Themes, faces, properties, highlight, @t{crossed-out}
1599 @cindex Themes, files, keywords, @t{:crossed-out}
1600 Whether to display the face's contents crossed out. This is a Boolean
1601 property. Possible values are @t{t} or @t{nil}.
1602 @item :framed
1603 @cindex Face Properties, highlight, @t{framed}
1604 @cindex Themes, faces, properties, highlight, @t{framed}
1605 @cindex Themes, files, keywords, @t{:framed}
1606 Whether to display the face's contents framed or encircled. This is a
1607 Boolean property. Possible values are @t{t} or @t{nil}.
1608 @item :concealed
1609 @cindex Face Properties, highlight, @t{concealed}
1610 @cindex Themes, faces, properties, highlight, @t{concealed}
1611 @cindex Themes, files, keywords, @t{:concealed}
1612 Whether to conceal the face's contents. This is a Boolean property.
1613 Possible values are @t{t} or @t{nil}. In case it is not obvious,
1614 concealing means that the face's contents is not displayed, but still
1615 occupies its normal space, so this is different from hiding it
1616 (@pxref{Layout Properties}).
1617 @cindex Face Properties, highlight, @t{revealed}
1618 @cindex Themes, faces, properties, highlight, @t{revealed}
1619 @cindex Themes, files, keywords, @t{:revealed}
1620 Alternately, you can also use the opposite Boolean property named
1621 @t{:revealed}.
1622 @end table
1624 @node Highlight Inheritance, , Highlight Properties, Highlight
1625 @subsubsection Highlight Inheritance
1626 @cindex Face Properties, inheritance
1627 @cindex Face Properties, highlight, inheritance
1628 @cindex Themes, faces, properties, inheritance
1629 @cindex Themes, faces, properties, highlight, inheritance
1630 @cindex Themes, built-in, @t{raw}
1631 @cindex Built-in themes, @t{raw}
1632 By default (this is also the case in the @samp{raw} theme), all
1633 highlight properties are turned off: text is output in whatever way is
1634 standard on the current terminal.
1636 When you set a face's highlight property however, it is inherited by all
1637 the sub-faces. This is in fact the most natural behavior. For instance,
1638 if you set the foreground of the @samp{synopsis} face to red, you
1639 probably expect the whole synopsis line to be output in red, including
1640 the header, program @etc{} parts. If not, you need to explicitly
1641 neutralize the unwanted effect, for instance by saying something like
1642 this:
1644 @verbatim
1645 :face (synopsis :foreground red
1646                 :face (program :foreground reset)
1647                 :face (postfix :foreground cyan))
1648 @end verbatim
1650 In other words, you can consider that the way some piece of text is
1651 output is not specified exactly by its associated face, but rather by
1652 the merging of all active properties from the whole corresponding face
1653 tree. This is exactly how Emacs faces work by the way.
1655 @node Layout, Implicit Faces, Highlight, Theme Creation
1656 @subsection Layout
1657 The second category of properties that we are going to describe deals
1658 with @emph{layout}, that is, modifying the placement of text in the
1659 output.
1661 @menu
1662 * Layout Properties::   What is available
1663 * Layout Inheritance::  What happens in a face tree
1664 @end menu
1666 @node Layout Properties, Layout Inheritance, Layout, Layout
1667 @subsubsection Layout Properties
1668 @cindex Layout Properties
1669 @cindex Faces, properties, layout
1670 @cindex Themes, faces, properties, layout
1671 In addition to the 10 highlight properties described in the previous
1672 section, @clon{} defines 6 layout properties. Here are the first 4 of
1673 them, along with their description and default value.
1675 @table @t
1676 @item :visible
1677 @cindex Face Properties, layout, @t{visible}
1678 @cindex Themes, faces, properties, layout, @t{visible}
1679 @cindex Themes, files, keywords, @t{:visible}
1680 @cindex Face Properties, layout, @t{hidden}
1681 @cindex Themes, faces, properties, layout, @t{hidden}
1682 @cindex Themes, files, keywords, @t{:hidden}
1683 @cindex Standard Themes, files, @file{optlist.cth}
1684 @cindex Themes, files, standard, @file{optlist.cth}
1685 @cindex Standard Themes, files, @file{refcard.cth}
1686 @cindex Themes, files, standard, @file{refcard.cth}
1687 Whether the face's contents is visible. Possible values are @t{t} (the
1688 default), or @t{nil}. You can also use the opposite property named
1689 @t{:hidden}. The @samp{optlist} and @samp{refcard} themes make use of
1690 this to avoid printing the options descriptions.
1691 @cindex Face Properties, highlight, @t{display}
1692 @cindex Themes, faces, properties, highlight, @t{display}
1693 @cindex Themes, files, keywords, @t{:display}
1694 Since the notions of hiding, concealing or making text visible are
1695 somewhat intermixed, @clon{} also provides a ``bastard'' property which,
1696 depending on its value, would be considered either a layout, or a
1697 highlight one. This property is named @t{:display}. Possible values are:
1698 @t{visible} (or @t{revealed} or @t{t}), @t{concealed} and @t{hidden} (or
1699 @t{nil}).
1700 @item :padding-top
1701 @cindex Face Properties, layout, @t{padding-top}
1702 @cindex Themes, faces, properties, layout, @t{padding-top}
1703 @cindex Themes, files, keywords, @t{:padding-top}
1704 The face's top padding, that is, the number of lines to skip before
1705 opening it and displaying its contents. This property can take the
1706 following forms.
1707 @table @t
1708 @item nil
1709 This face may be opened anywhere, including on the current line. This is
1710 the default.
1711 @item 0
1712 This face should be opened on the next line.
1713 @item <num> @r{(positive)}
1714 This face should be opened after skipping @t{<num>} empty lines. Note
1715 that the empty lines are displayed in the enclosing face, @emph{not} the
1716 face which specifies the top padding.
1717 @end table
1718 @item :padding-bottom
1719 @cindex Face Properties, layout, @t{padding-bottom}
1720 @cindex Themes, faces, properties, layout, @t{padding-bottom}
1721 @cindex Themes, files, keywords, @t{:padding-bottom}
1722 This face's bottom padding, that is, the number of lines to skip before
1723 opening the next face and displaying its contents. This property can
1724 take the following forms.
1725 @table @t
1726 @item nil
1727 The next face may be opened anywhere, including on the current line.
1728 This is the default.
1729 @item 0
1730 The next face should be opened on the next line.
1731 @item <num> @r{(positive)}
1732 The next face should be opened after skipping @t{<num>} lines. Note that
1733 the empty lines are displayed in the enclosing face, @emph{not} the face
1734 which specifies the bottom padding.
1735 @end table
1736 @item :item-separator
1737 @cindex Face Properties, layout, @t{item-separator}
1738 @cindex Themes, faces, properties, layout, @t{item-separator}
1739 @cindex Themes, files, keywords, @t{:item-separator}
1740 The face's item separator, that is, a piece of text to insert between
1741 every sub-face's contents. The default value is @t{#\space} (a space
1742 character).
1743 @end table
1744 @cindex Themes, built-in, @t{raw}
1745 @cindex Built-in Themes, @t{raw}
1746 The default values above have been chosen because they are convenient
1747 for the majority of the faces, but not necessarily all the time. Let us
1748 now review some examples of non-default settings in the @samp{raw}
1749 theme.
1750 @itemize @bullet
1751 @item
1752 The @samp{synopsis} face has its bottom padding set to 1, which means to
1753 leave an empty line below it. Note that this line does not belong to the
1754 synopsis. It is output in the @samp{toplevel} face.
1755 @item
1756 The @samp{text}, @samp{option} and @samp{group} faces have both their
1757 top and bottom paddings set to 0. This means that all these items should
1758 start and end on lines of their own.
1759 @item
1760 Finally, the @samp{syntax} face has its item separator set to
1761 @w{@t{", "}}, which in this context is used to separate the short and
1762 long name syntax, as in @w{@samp{-h, --help}}.
1763 @end itemize
1765 @cindex Frames
1766 @cindex Layout, frames
1767 In order to describe the last two layout properties, we need to
1768 introduce the notion of @emph{frame} first. A frame is a rectangle in
1769 which @clon{} prints something. When @clon{} opens a face for printing
1770 its contents, it associates a frame with it. Usually, @clon{} doesn't
1771 know the frame's height because it doesn't know in advance how many
1772 lines of output will be necessary to display the face's contents.
1773 However, @clon{} usually knows the frame's width: a frame starts at a
1774 certain column (the left one) and stops at another (the right one).
1776 There is an isomorphic relation between frames and faces: when a face is
1777 a sub-face of a super-face, the corresponding frame is a sub-frame of
1778 the corresponding super-frame. Sub-frames are geometrically enclosed
1779 within their super-frames: a sub-frame can only draw in an equally large
1780 or narrower band than its super-frame. That's how @clon{} handles
1781 vertical alignment of text.
1783 In order to give you control on the starting and ending columns of every
1784 frame (in fact, every face), the following two layout properties are
1785 defined.
1787 @table @t
1788 @item :padding-left
1789 @cindex Face Properties, layout, @t{padding-left}
1790 @cindex Themes, faces, properties, layout, @t{padding-left}
1791 @cindex Themes, files, keywords, @t{:padding-left}
1792 A face's left padding determines its starting column. This property can
1793 take the following forms.
1794 @table @t
1795 @item <num>
1796 Skip @t{<num>} columns relatively to the enclosing face. The default
1797 value is 0, meaning to open this face at the same column number as the
1798 enclosing one.
1799 @item (<num> :relative-to <face>)
1800 As above, but relatively to a @emph{parent} face named @t{<face>}
1801 instead of just the enclosing one. This lets you go more than one level
1802 up in the face tree.
1803 @item (<num> absolute)
1804 Open this face exactly at column @t{<num>}.
1805 @item self
1806 This face may be opened anywhere, and when it is, its left column is set
1807 to the current column number.
1808 @end table
1809 @item :padding-right
1810 @cindex Face Properties, layout, @t{padding-right}
1811 @cindex Themes, faces, properties, layout, @t{padding-right}
1812 @cindex Themes, files, keywords, @t{:padding-right}
1813 A face's right padding, determines its ending column. This property can
1814 take the following forms.
1815 @table @t
1816 @item <num>
1817 Close this face @t{<num>} columns before the enclosing one.
1818 @item (<num> :relative-to <face>)
1819 As above, but relatively to a @emph{parent} face named @t{<face>}
1820 instead of just the enclosing one. This lets you go more than one level
1821 up in the face tree.
1822 @item (<num> absolute)
1823 Close this face exactly at column @t{<num>}.
1824 @item self
1825 This face may be closed anywhere. This is the default.
1826 @end table
1827 @end table
1828 @cindex Themes, built-in, @t{raw}
1829 @cindex Built-in Themes, @t{raw}
1830 The default values above have been chosen because they are convenient
1831 for the majority of the faces, but not necessarily all the time. Let us
1832 now review some examples of non-default settings in the @samp{raw}
1833 theme.
1834 @itemize @bullet
1835 @item
1836 The @samp{option} face has its left padding set to 2. Since all
1837 super-faces default to 0, this essentially mean an indentation of 2
1838 columns.
1839 @item
1840 The @samp{usage} face has its left padding set to @t{(30 absolute)}
1841 which means that the descriptive texts for all options start aligned at
1842 column 30.
1843 @end itemize
1845 @cindex Faces, self-ending
1846 There is one important point to understand about self-ending faces
1847 (which, again, is the default setting). A self-ending face typically
1848 doesn't know at which column it stops until it stops. In fact, this is
1849 not completely true: if the face's contents needs to span across several
1850 lines, then the ending column will be known at the end of the first
1851 line, when the ending column of the enclosing face is reached. However,
1852 for a piece of contents that fits on a single line, the point holds.
1854 Because of that, it is impossible for a face's right padding to be
1855 relative to a self-ending face. This would be like saying ``stop 2
1856 columns before I don't know where''. Here are two examples of such
1857 invalid settings (an error will be thrown if you try that in a theme):
1859 @verbatim
1860 :face (option :face (syntax :padding-right 2))
1861 :face (option
1862         :face (syntax
1863                 :face (short
1864                         :padding-right (2 :relative-to option))))
1865 @end verbatim
1867 @node Layout Inheritance, , Layout Properties, Layout
1868 @subsubsection Layout Inheritance
1869 @cindex Face Properties, inheritance
1870 @cindex Face Properties, layout, inheritance
1871 @cindex Themes, faces, properties, inheritance
1872 @cindex Themes, faces, properties, layout, inheritance
1873 This section is a misnomer. Contrary to highlight properties, there is
1874 @emph{no} inheritance for layout properties across a face tree. In other
1875 words, every missing layout property in a face specification has the
1876 property in question set to its default value.
1878 Again, this design decision has been adopted because it is the most
1879 natural thing to do. If you're not convinced, consider this: when you
1880 specify that the @samp{option} face has a top padding of 0, you mean
1881 that every option should be described on a line of its own. However, you
1882 probably do @emph{not} mean that every individual sub-part of the
1883 option's description (syntax part, usage part @etc{}) should also start
1884 on its own line.
1886 Now that we know all about highlight and layout inheritance, we are able
1887 to explain the face specification shortcut mentioned earlier, when a
1888 face is specified directly by name, without any explicit property
1889 specification:
1891 @verbatim
1892 :face description
1893 @end verbatim
1895 This syntactic shortcut actually lets you specify a face which gets all
1896 default values for layout properties, and inherits all current values
1897 from its super-faces for highlight properties. This is in fact a
1898 shortcut for this:
1900 @verbatim
1901 :face (description)
1902 @end verbatim
1904 This, however, does not explain why you would want to issue such a
1905 specification instead of just not mentioning the face at all. See
1906 @ref{Implicit Faces} for an explanation.
1909 @node Implicit Faces, , Layout, Theme Creation
1910 @subsection Implicit Faces
1911 @cindex Implicit Faces
1912 @cindex Faces, implicit
1913 @cindex Themes, faces, implicit
1914 @cindex Built-in themes, @t{raw}
1915 @cindex Themes, built-in, @t{raw}
1916 In order to fully understand how themes work, we need to tackle one last
1917 aspect of their conception: the case of @emph{implicit faces}. Although
1918 @clon{} itself needs a completely defined face tree to perform output
1919 correctly, a theme file is not required to define all of them (that is
1920 impossible by the way: because of group nesting, a complete theme file
1921 would be infinitely big). In fact, a theme file can be totally empty, in
1922 which case the output will effectively conform to the built-in
1923 @samp{raw} theme. When a face is ``missing'' from a theme, @clon{}
1924 arranges to define it in a sensible way. Such a face is said to be
1925 @emph{implicit}. The exact rules for defining implicit faces is what
1926 this section is all about.
1928 @menu
1929 * Face Tree Reuse::     Substituting previously specified faces
1930 * Sibling Faces::       Substituting built-in faces
1931 @end menu
1933 @node Face Tree Reuse, Sibling Faces, Implicit Faces, Implicit Faces
1934 @subsubsection Face Tree Reuse
1935 @cindex Faces, reuse
1936 @cindex Themes, faces, reuse
1937 Suppose that @clon{} needs to display an option's description, and that
1938 option belongs to a group. The corresponding face in a theme file would
1939 be the following one:
1941 @verbatim
1942 :face (group :face (items :face (option  #| ... |#)))
1943 @end verbatim
1945 This face describes how options belonging to a level 1 group are to be
1946 displayed. As such, it is not applicable to toplevel options. When this
1947 face is missing from the theme file, @clon{} tries to find a @emph{more
1948 general} one. In that particular case, the theme file might define a
1949 ``toplevel'' @samp{option} face like this:
1951 @verbatim
1952 :face (option #| ... |#)
1953 @end verbatim
1955 This face is more general because it lies at the toplevel. As such, it
1956 is considered applicable to toplevel options, but also to options
1957 belonging to groups at any level. In the same vein, specifying an
1958 @samp{option} face within a @samp{group} face implicitly makes it
1959 applicable at any higher group level.
1961 This face reuse mechanism applies to @emph{any} face in a theme; not
1962 only to the ones used in the examples above. For instance, if you decide
1963 that all headers in @clon{}'s output should be displayed in the same
1964 way, you can very well specify a @samp{header} face at the toplevel of a
1965 theme file (although @clon{} never has anything to display in a
1966 @samp{header} face at the toplevel), and this face will be used in
1967 synopsis headers, group headers, fallback headers @etc{}.
1969 @cindex Faces, tree, reuse
1970 @cindex Themes, faces, tree, reuse
1971 Now, I must confess that the face reuse mechanism described above was
1972 over-simplified. What really happens is not exactly face reuse, but
1973 @emph{face tree} reuse. Here is a more complicated example to clarify
1974 things a little.
1976 Suppose @clon{} needs to display the syntax part of an option that
1977 belongs to a level 1 group. The corresponding face in a theme file would
1978 be the following:
1980 @verbatim
1981 :face (group :face (items :face (option :face (syntax #| ... |#))))
1982 @end verbatim
1984 If that face is missing, then @clon{} will in fact attempt to find a
1985 more general one @emph{while preserving as much context as possible}. In
1986 other words, the following specifications will be tried, in that order:
1988 @verbatim
1989 :face (items :face (option :face (syntax #| ... |#)))
1990 :face (option :face (syntax #| ... |#))
1991 :face (syntax #| ... |#)
1992 @end verbatim
1994 I hope this makes sense to you because again, it is the most natural
1995 thing to do. What this roughly means is that when you are looking for a
1996 way to display an option's syntax part, you should reuse a more general
1997 option's syntax face first, and only as a very last resort fall back to
1998 a @samp{syntax} face specification that would be floating around on its
1999 own.
2001 @node Sibling Faces, , Face Tree Reuse, Implicit Faces
2002 @subsubsection Sibling Faces
2003 @cindex Sibling Faces
2004 @cindex Faces, siblings
2005 @cindex Themes, faces, siblings
2006 @cindex Built-in themes, @t{raw}
2007 @cindex Themes, built-in, @t{raw}
2008 Now, what happens when the face you're looking for is not specified
2009 @emph{at all}, not even at a more general level? In such a situation,
2010 @clon{} uses a @emph{sibling}. A sibling face is a face that plays the
2011 same role as the one you're looking for, only it is extracted from the
2012 built-in @samp{raw} theme. The built-in @samp{raw} theme ensures that
2013 every face is defined at least once, so all faces will eventually be
2014 found. When a sibling face is not found in the exact context in which it
2015 is needed (for instance, the @samp{group} face is empty in the
2016 @samp{raw} theme), then the same process of face tree reuse as described
2017 in the previous section occurs on the sibling face tree.
2021 @c ====================================================================
2022 @c Conclusion
2023 @c ====================================================================
2024 @node Conclusion,  Concept Index, Output, Top
2025 @chapter Conclusion
2026 So that's it I guess. Enjoy using clonified applications, don't spend
2027 too much time hacking themes, and please contribute to the @cl{} world
2028 by developing standalone programs with @clon{}. Read @userref{Top} to
2029 learn how to do that.
2031 Hmmm. What kind of conclusion was that@dots{}
2035 @c ====================================================================
2036 @c Concept Index
2037 @c ====================================================================
2038 @node Concept Index, , Conclusion, Top
2039 @unnumbered Concept Index
2041 @printindex cp
2043 @bye
2045 @c  LocalWords:  Clon clon cmdline Clonification tty emph CmdLine clonified SGR
2046 @c  LocalWords:  clonfiscated clonistified clonificated clonificationated samp
2047 @c  LocalWords:  cindex subsubsection pxref Didier Nuker postfix Runtime cth
2048 @c  LocalWords:  cartouche toplevel prepended IEC
2050 @c enduser.texi ends here