Protect against error in user home directory computation
[clon.git] / doc / enduser.texi
blob6063961b43e4d52c4837548ea2ff20e56abc5d81
1 \input texinfo
3 @c enduser.texi --- End-user manual
5 @c Copyright (C) 2010, 2011, 2012 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 23 "Michael Brecker"
45 @set COPYRIGHT_DATE 2010, 2011, 2012
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}.
353 @item lisp-information
354 Finally, this option displays some information about the underlying Lisp
355 implementation that was used to create this executable.
356 @end table
360 @c ====================================================================
361 @c The Command Line
362 @c ====================================================================
363 @node The Command Line, Output, Clonification, Top
364 @chapter The Command Line
365 @cindex Command-Line
367 @clon{} provides applications with usual @cmdline{} features such as
368 option names coming in short (@eg{} @samp{-h}) or long (@eg{}
369 @samp{--help}) form. @clon{} also comes with a set of more specific
370 features, such as @emph{packs} or abbreviated forms, that you might want
371 to become familiar with in order to use an application's @cmdline{} to
372 its full extent.
374 @menu
375 * Option Calls::        Different ways to specify options
376 * Option Packs::        Grouping option calls together
377 * Option Separator::    Telling @clon{} to mind it's own business
378 * Option Retrieval::    How @clon{} computes the value of an option
379 @end menu
382 @c -------------
383 @c Option Calls
384 @c -------------
385 @node Option Calls, Option Packs, The Command Line, The Command Line
386 @section Option Calls
387 @cindex Command-Line, options
388 @cindex Options, command-line
390 @clon{} offers a set of precise syntactic rules that every clonified
391 application follows implicitly, making them work in a homogeneous way.
392 Although application programmers have the ability to extend @clon{} by
393 defining their own option @emph{types}, even those new options obey the
394 same syntactic rules as the built-in ones.
396 @menu
397 * Option Names::        Long, short or abbreviated
398 * Option Arguments::    None, mandatory or optional
399 @end menu
401 @node Option Names, Option Arguments, Option Calls, Option Calls
402 @subsection Option Names
403 @cindex Options, names
404 An option can come with either a short name, a long name, or both. It is
405 also possible to abbreviate long names.
407 @menu
408 * Full Names::          Long or short
409 * Abbreviations::       Shorter long names
410 @end menu
412 @node Full Names, Abbreviations, Option Names, Option Names
413 @subsubsection Full Names
414 @cindex Long Form
415 @cindex Short Form
416 @cindex Command-Line, options, long form
417 @cindex Command-Line, options, short form
418 @cindex Options, names, full
419 @cindex Options, names, long
420 @cindex Options, names, short
421 @cindex Options, command-line, long form
422 @cindex Options, command-line, short form
423 To provide an option by short name, use a @emph{short form}: a single
424 dash followed by the option's short name (@eg{} @samp{-h}). To provide
425 an option by long name, use a @emph{long form}: two dashes followed by
426 the option's long name (@eg{} @samp{--help}).
428 Short names typically consist of a single character. They are concise
429 but more difficult to remember. Long names can be whole words, or even
430 word sequences (usually separated by dashes). They are easier to
431 remember but longer to type on the @cmdline{}.
433 You should be aware of the fact that in a clonified application, neither
434 short names nor long ones are restricted in length. In fact, it would
435 be perfectly possible to have an option's short name longer than the
436 corresponding long one, although that would make little sense. The only
437 real difference is whether you use one or two dashes. Some other
438 differences also come into play when an option expects an argument
439 (@pxref{Option Arguments}) though (it would be no fun otherwise).
441 @node Abbreviations, , Full Names, Option Names
442 @subsubsection Abbreviations
443 @cindex Abbreviated Form
444 @cindex Abbreviated Long Form
445 @cindex Long Form, abbreviated
446 @cindex Options, names, abbreviated
447 @cindex Options, names, long, abbreviated
448 @cindex Command-Line, options, abbreviated form
449 @cindex Command-Line, options, abbreviated long form
450 @cindex Command-Line, options, long form, abbreviated
451 @cindex Options, command-line, abbreviated form
452 @cindex Options, command-line, abbreviated long form
453 @cindex Options, command-line, long form, abbreviated
454 When calling an option by long form, it is possible to abbreviate its
455 name, at the risk of being ambiguous. An abbreviation is simply the
456 beginning of the option's name (for instance, @samp{--he} can stand for
457 @samp{--help}). In case of ambiguity, @clon{} always chooses the option
458 which is ``closest'' to the abbreviation (here, the ``distance'' between
459 an abbreviation and an option's name is the number of missing
460 characters).
462 @node Option Arguments, , Option Names, Option Calls
463 @subsection Option Arguments
464 @cindex Arguments
465 @cindex Options, arguments
466 In @clon{}, there are different kinds of options: in addition to having
467 a short and/or long name, an option may or may not take an argument. For
468 those taking one, the argument may be either mandatory or optional.
469 Then, there is also an additional, extended call syntax for some of
470 them. But then again, that is not the whole story about getting an
471 option's value (@pxref{Option Retrieval}). If everything goes well, you
472 are now wondering whether you really want to use a @cmdline{} at all.
474 @menu
475 * Flags::                       Options with no argument
476 * Valued Options::              Options with arguments
477 * Switches::                    Options with Boolean arguments
478 @end menu
480 @node Flags, Valued Options, Option Arguments, Option Arguments
481 @subsubsection Flags
482 @cindex Flags
483 @cindex Options, types, flags
484 First of all, some options don't take an argument at all. In the @clon{}
485 jargon, these options are called @emph{flags}. Flags just stand for
486 themselves: either they are present on the @cmdline{}, or they are not
487 (as a matter of fact, this is a lie, @pxref{Option Retrieval}). A
488 typical example of a flag would be displayed like this in a standard
489 help string (but @pxref{Output}):
491 @example
492   -h, --help        Print this help and exit.
493 @end example
495 @node Valued Options, Switches, Flags, Option Arguments
496 @subsubsection Valued Options
497 @cindex Valued Options
498 @cindex Options, types, valued
499 @cindex Values
500 @cindex Options, values
501 Options taking an argument are said to be @emph{valued}. We need a bit
502 of terminology here: and option's @emph{argument} is typically what you
503 provide on the @cmdline{} (or elsewhere, @pxref{Option Retrieval}). An
504 option's argument is thus a string. An option's @emph{value} is what
505 results from the conversion of the option's argument to the proper type
506 (the same string, a number, whatever).
508 @cindex Sticky Arguments
509 @cindex Arguments, sticky
510 @cindex Options, arguments, sticky
511 @cindex Mandatory Arguments
512 @cindex Arguments, mandatory
513 @cindex Options, arguments, mandatory
514 @cindex Optional Arguments
515 @cindex Arguments, optional
516 @cindex Options, arguments, optional
517 In @clon{}, a valued option's argument can be either mandatory or
518 optional. We know that valued options, just like flags, may be provided
519 in short or long form. When using the long form, the proper way of
520 providing an argument is to append it after an @samp{=} sign, like this:
521 @samp{--phone=01020304}. When using the short form, the proper way of
522 providing an argument is to stick it right behind the option's name,
523 like this: @samp{-p01020304}. In both long and short form, we call these
524 arguments ``sticky''. All this should look familiar.
526 @cindex Separated Arguments
527 @cindex Arguments, separated
528 @cindex Options, arguments, separated
529 When the option's argument is mandatory, you also have the ability to
530 provide it in the next @cmdline{} item instead of sticking it to the
531 option's name. These arguments are said to be ``separated''. Back to the
532 previous example, this means that you can also say @samp{--phone
533 01020304} or @samp{-p 01020304}. Keep in mind that this is not possible
534 when the argument is optional (in the general case, it is not possible
535 to decide whether the next @cmdline{} item is an option's argument, a
536 new option or something else).
538 @cindex Arguments, looking like options
539 @cindex Options, as argument to other options
540 @cindex Options, arguments, looking like options
541 There is also another case where you can't use this alternate syntax,
542 even when the argument is mandatory: that is when the argument itself
543 looks like an option. @clon{} will think it is, and consequently will
544 also think that the previous one lacks its mandatory argument.
546 The phone example above would look like this in a standard help string
547 (but @pxref{Output}):
549 @example
550   -p, --phone=NUM    Set phone number to NUM.
551 @end example
553 And here is an example illustrating a typical output when the argument
554 is optional:
556 @example
557   -f, --fax[=NUM]    Set fax number to NUM, or same as phone.
558 @end example
560 @node Switches, , Valued Options, Option Arguments
561 @subsubsection Switches
562 @cindex Switches
563 @cindex Options, types, switches
564 For those of you who are not satisfied with short and long forms,
565 @clon{} provides a specific option type for Boolean values, along with
566 an additional call syntax. These options are called @emph{switches}.
568 Just like any other kind of valued option, a switch can have a short
569 and/or a long name, and its argument may be mandatory or optional.
570 However, the possible arguments for a switch are restricted to true or
571 false. In fact, you can freely use @samp{yes}, @samp{on}, @samp{true},
572 @samp{yup}, @samp{yeah} and @samp{no}, @samp{off}, @samp{false},
573 @samp{nope}, @samp{nah} respectively.@footnote{If you want more, a very
574 modest additional fee will be charged.}
576 @cindex Negated Form
577 @cindex Negated Short Form
578 @cindex Short Form, negated
579 @cindex Options, command-line, negated form
580 @cindex Options, command-line, negated short form
581 @cindex Options, command-line, short form, negated
582 @cindex Command-Line, options, negated form
583 @cindex Command-Line, options, negated short form
584 @cindex Command-Line, options, short form, negated
585 In addition to the standard short and long forms, a switch can be
586 provided in @emph{negated form}, that is, by appending its short name
587 behind a @samp{+} character. This form never takes any argument and
588 always means false (turn the switch off, if you prefer).
590 Although an application might do something different, the intended usage
591 for switches is to take an optional argument that defaults to true. A
592 typical example would look like this in a standard help string (but
593 @pxref{Output}):
595 @example
596   -(+)d, --debug[=yes/no]    Whether to enable debugging.
597 @end example
599 Given such an option, you can turn debugging on by saying just @samp{-d}
600 or @samp{--debug} (but you can also provide an explicit argument like
601 this: @samp{-dyes} or that: @samp{--debug=yes}). Similarly, to turn
602 debugging off, use @samp{+d} or @samp{--debug=no}.
604 One last word about switches: @clon{} lets application developers create
605 new options based on (but not limited to) switches. These options
606 typically accept Boolean arguments as well as some other value(s). As
607 soon as an option is switch-based (and has a short name), the negated
608 form becomes automatically available, and this should be advertised in
609 the application's help string.
612 @c ------------
613 @c Option Packs
614 @c ------------
615 @node Option Packs,  Option Separator, Option Calls, The Command Line
616 @section Option Packs
617 @cindex Packs
618 @cindex Command-Line, packs
619 @cindex Options, command-line, packed
621 In addition to using options individually (@pxref{Option Calls}),
622 @clon{} offers the possibility to group option calls together under some
623 circumstances. This feature is know as option @emph{packs}. @clon{}
624 offers two kinds of packs.
626 @menu
627 * Short Packs::         Grouping short forms together
628 * Negated Packs::       Grouping negated forms together
629 @end menu
631 @node Short Packs, Negated Packs, Option Packs, Option Packs
632 @subsection Short Packs
633 @cindex Short packs
634 @cindex Packs, short
635 @cindex Command-Line, short packs
636 @cindex Command-Line, packs, short
637 A short pack allows you to group multiple short forms in a single
638 @cmdline{} item. For instance, instead of calling your program like
639 this: @samp{program -c -u -p}, you can directly use: @samp{program
640 -cup}.
642 @cindex Options, names, short, one character
643 A short pack can only contain options the short names of which are
644 exactly one character long. Also, it should be obvious that you cannot
645 provide an argument to an option in a pack. As a consequence, only flags
646 and options with optional (and not provided) arguments may appear in a
647 short pack.
649 There is one exception however: it @emph{is} possible to provide an
650 argument to the @emph{last} option in the pack. If provided, this
651 argument must be located in the next @cmdline{} item. It cannot be
652 sticked to the option, so this means in particular that this option's
653 argument is mandatory (@pxref{Valued Options}).
655 Beware that using short packs comes at the risk of ambiguity. When
656 @clon{} parses a @cmdline{} item beginning with only one dash, it tries
657 to detect options first, options with a sticky argument next, and then
658 short packs. For that reason, you cannot possibly start a pack with a
659 valued option. Indeed, suppose that the option @samp{-c} takes an
660 argument. What you @emph{think} is a short pack (@samp{-cup}) will in
661 fact be interpreted as the option @samp{-c} with a sticky (and maybe
662 invalid) argument @samp{up}. On the other hand, if the option @samp{-u}
663 is only a flag (@pxref{Flags}), then you can safely pack your options in
664 a different order, like this: @samp{-ucp}.
666 A single @cmdline{} may contain as many short packs as you like, and
667 they can also be intermixed with regular option calls.
669 @node Negated Packs, , Short Packs, Option Packs
670 @subsection Negated Packs
671 @cindex Negated packs
672 @cindex Negated Short Packs
673 @cindex Negated packs, short
674 @cindex Packs, negated
675 @cindex Packs, short, negated
676 @cindex Command-Line, negated packs
677 @cindex Command-Line, negated short packs
678 @cindex Command-Line, short packs, negated
679 @cindex Command-Line, packs, negated
680 @cindex Command-Line, packs, short, negated
681 In a very similar way, a negated pack allows you to group multiple
682 negated forms in a single @cmdline{} item. As such, this feature only
683 applies to switches or switch-based options (@pxref{Switches}). For
684 instance, instead of calling your program like this: @samp{program +c +u
685 +p}, you can directly use: @samp{program +cup}.
687 @cindex Options, names, short, one character
688 A negated pack can only contain options the short names of which are
689 exactly one character long. Also, remember that negated forms never take
690 any argument.
692 Beware that using negated packs comes at the risk of ambiguity (although
693 much less than with short packs). When @clon{} parses a @cmdline{} item
694 beginning with a @samp{+}, it tries to detect options first, and then
695 negated packs. For that reason, the order in which you specify the
696 options in the pack is important. Indeed, suppose that your application
697 has a @samp{+cup} switch (this would be a very bad idea, but
698 still@dots{}). If you want to provide the same pack as above, then you
699 need to modify the options order, like this: @samp{+ucp}.
701 A single @cmdline{} may contain as many negated packs as you like, and
702 they can also be intermixed with regular option calls or short packs.
705 @c ----------------
706 @c Option Separator
707 @c ----------------
708 @node Option Separator, Option Retrieval, Option Packs, The Command Line
709 @section Option Separator
710 @cindex Separator
711 @cindex Command-Line, separator
712 @cindex Postfix
713 @cindex Command-Line, postfix
715 @clon{} separates the @cmdline{} in two parts. The left part contains
716 option calls and packs while the right part contains the rest. The right
717 part is also called the @emph{postfix}).
719 @cindex Explicit separator
720 @cindex Separator, explicit
721 @cindex Command-Line, explicit separator
722 @cindex Command-Line, separator, explicit
723 You can force this distinction by using the special construct @samp{--}
724 on the @cmdline{}. Everything that follows it will be completely ignored
725 by @clon{} (not necessarily by the application itself though).
727 @cindex Implicit separator
728 @cindex Separator, implicit
729 @cindex Command-Line, implicit separator
730 @cindex Command-Line, separator, implicit
731 In the case you don't split your @cmdline{} explicitly, @clon{} does
732 this for you automatically by noticing where the last option (or its
733 potential argument) stands. The behavior is different from that of
734 explicit splitting in one regard however: if the application is not
735 expecting any postfix and there's an implicit one, then @clon{} will
736 throw an error at your face.
738 @cindex Postfix, options in
739 @cindex Options, in postfix
740 @cindex Command-Line, postfix, options in
741 @cindex Command-Line, options, in postfix
742 One final note on @cmdline{} separation: in the case an application's
743 postfix is supposed to contain something looking like an option (perhaps
744 real options to pass on to another program), you @strong{need} an
745 explicit separator. Otherwise, @clon{} will be confused: it could for
746 instance wrongly detect unknown options, junk on the @cmdline{} @etc{}
748 You don't want to confuse @clon{}. @clon{} is nasty when it is scared.
752 @c ----------------
753 @c Option Retrieval
754 @c ----------------
755 @node Option Retrieval, , Option Separator, The Command Line
756 @section Option Retrieval
758 @cindex Retrieval
759 @cindex Options, retrieval
760 The process of getting a value for a specific option is called
761 @dfn{retrieval}. This section explains how it works.
763 @menu
764 * Value Sources::       The command-line, and more
765 * Error Management::    What to do when something goes wrong
766 @end menu
768 @node Value Sources, Error Management, Option Retrieval, Option Retrieval
769 @subsection Value Sources
770 The @cmdline{} is not the only place where @clon{} looks for option
771 @emph{values}. Other sources for option values are: @emph{fallback}
772 values, @emph{environment} variables and @emph{default} values. The
773 existence of a fallback value, environment variable or default value
774 should be advertised in the application's help string (@pxref{Output}).
776 @itemize @bullet
777 @item
778 @cindex Fallback values
779 @cindex Values, fallback
780 @cindex Retrieval, from fallback value
781 @cindex Options, retrieval, from fallback value
782 Fallback values are used when an option exists on the @cmdline{} without
783 a corresponding argument (so this applies only to options taking
784 @emph{optional} arguments only).
785 @item
786 @cindex Environment
787 @cindex Retrieval, from environment
788 @cindex Options, retrieval, from environment
789 Applications may also associate an option with a specific environment
790 variable which contains a value for it.
791 @item
792 @cindex Default values
793 @cindex Values, default
794 @cindex Retrieval, from default value
795 @cindex Options, retrieval, from default value
796 Finally, default values are used when every other source has failed.
797 @end itemize
799 When @clon{} attempts to retrieve a value for a particular option, it
800 always does so in a specific order: first, the @cmdline{} is searched.
801 If an argument is present, it is used. Otherwise, a fallback or default
802 value is used in that order (note that when an option's argument is
803 optional, the option is required to provide at least a fallback or a
804 default value). Next, an environment variable is tried (when
805 appropriate). Finally, when everything else fails, the option's default
806 value is used (if any).
808 @cindex Retrieval, from command-line
809 @cindex Command-Line, retrieval
810 @cindex Options, retrieval, from command-line
811 @clon{} always scans the @cmdline{} from left to right, and stops at the
812 first match. Please note that the match in question may be a regular
813 option call or a pack, depending on what appears first on the
814 @cmdline{}. There is no concept of priority amongst option forms.
816 @cindex Options, multiple calls
817 Also, note that it is possible to provide several calls to the same
818 option on a single @cmdline{}. Some applications may take advantage of
819 this: every consecutive request for an option will use the next match on
820 the @cmdline{} until there is none left.
822 @cindex Flags
823 @cindex Options, types, flags
824 @cindex Environment
825 @cindex Retrieval, from environment
826 @cindex Options, retrieval, from environment
827 Finally, note that fallback or default values don't make any sense for
828 flags, but flags can still be associated with environment variables. In
829 such a case, the very @emph{existence} of the variable in the
830 environment, regardless of its value, stands for the presence of the
831 corresponding option on the @cmdline{}.
833 @node Error Management, , Value Sources, Option Retrieval
834 @subsection Error Management
835 @cindex Error Management
836 @cindex Retrieval, errors
837 @cindex Options, retrieval, errors
838 OK, now you're completely overwhelmed by the power and flexibility of
839 @clon{}, to the point that the fact that you didn't write it (because
840 @emph{I} did) even starts to upset you. So I know what you're thinking:
841 ``there's gotta be a way to break it''. I don't know, like, giving a
842 value to a flag, using an unknown option, providing an invalid value for
843 an option, using an equal sign in a negated call @etc{}
845 Unfortunately for you, @clon{} is like a pitbull. Whatever you do to
846 beat it, it @emph{will} fight back. The behavior of @clon{} with respect
847 to error management during option retrieval is well defined, but
848 contrary to the traditional approach, @emph{you}, the end-user have
849 control over it. Not the application. Error handling may occur when the
850 @cmdline{} is parsed, but also when environment variables are used.
852 @bioindex{error-handler}
853 @bievindex{ERROR_HANDLER}
854 The error management behavior of @clon{} is controlled by a built-in
855 option named @bioption{error-handler}, and its accompanying environment
856 variable @code{CLON_ERROR_HANDLER}. Possibles values for it are
857 currently the following.
859 @table @t
860 @item quit
861 @cindex Error Management, quitting
862 This is the default. It means that when @clon{} encounters an error
863 related to option retrieval, it prints an informative message about the
864 error and terminates the application immediately (with an exit status of
865 1). This is the behavior of most programs out there I guess.
866 @item interactive
867 When interactive error handling is selected and an error is signaled,
868 you are presented with a list of possible options to ``fix'' the
869 problem. Such options include notably the ability to modify an option's
870 name or value (handy in case of @cmdline{} typo), discard the call
871 altogether and many others, depending on the exact error.
873 When the error implies a bad value for a particular option, you will
874 notice that some of the choices that @clon{} proposes in order to fix
875 the problem involve providing another @emph{value} or another
876 @emph{argument}. Again, you need to remember the terminology here
877 (@pxref{Valued Options}). The argument is what you provide on the
878 @cmdline{}, and the value is the conversion of the argument to the
879 proper type. This means that most of the time, you will want to use the
880 ``argument'' choice. If you know the @cl{} language (see below), you can
881 also provide a value directly, in which case what you type in is in fact
882 @cl{} code.
883 @item none
884 @cindex Debugger
885 @cindex Error Management, interactive debugging
886 @i{Using this option is not encouraged, unless you are the author of the
887 application and you are debugging it.} A value of @code{none} literally
888 means no particular error handler. Here, I must apologize because I need
889 to go into some technical details about @cl{}, the language in which
890 applications using @clon{} are written. @cl{} mandates the existence of
891 a @dfn{debugger} in which you are dropped in when an unhandled error
892 condition is thrown. However some @cl{} implementations may disable the
893 debugger when creating standalone programs. So the situation when the
894 @clon{} error handler is set to @code{none} depends on the application.
895 @end table
897 One last note about the @bioption{error-handler} option: we have a
898 chicken-and-egg problem with it. The error handler must be known for
899 parsing the @cmdline{}, but in order to get it, we need to retrieve the
900 option which implies parsing the @cmdline{}@dots{} Whoops. Because of
901 this problem, the option is treated in a very special way.
903 @enumerate
904 @item
905 First of all, a built-in default value of @code{quit} is used initially.
906 @item
907 However, if the @code{CLON_ERROR_HANDLER} environment variable is set,
908 its value will be used immediately, even before trying to get the option
909 on the @cmdline{} (if an error happens when trying the environment
910 variable, the @code{quit} handler is used).
911 @item
912 Finally, if the option is found on the @cmdline{} during the parsing of
913 it, its value is updated immediately (so it also applies for parsing the
914 rest of the @cmdline{}).
915 @end enumerate
917 Now you need to get some rest.
921 @c ====================================================================
922 @c Output
923 @c ====================================================================
924 @node Output, Conclusion, The Command Line, Top
925 @chapter Output
927 In the previous chapter, we have seen how to make the best usage of a
928 clonified application's command-line. The second aspect we need to look
929 at is @clon{}'s output, typically what you get when you type
930 @command{program --help}. From an end-user perspective, one key feature
931 of @clon{} is that control on the formatting of the help strings is
932 given to @emph{you} instead of being the programmer's responsibility.
933 What this means is that @emph{you} get to choose the way you want help
934 strings to be formatted, and all of a sudden, every clonified
935 application you use will conform to your specifications.
937 @ref{Output Elements} surveys the different items composing a @clon{}
938 help string by looking at examples in a default setting. @ref{Theme
939 Mechanism} explains how to switch between predefined layouts.
940 @ref{Global Control} describe two built-in options that give you some
941 control over the layout on a global scale. Finally, @ref{Theme Creation}
942 describes how to build your own layouts.
944 @menu
945 * Output Elements::     What appears in help strings
946 * Theme Mechanism::     Switching between available layouts
947 * Global Control::      Line width and highlighting
948 * Theme Creation::      Building your own layouts
949 @end menu
951 @c ---------------
952 @c Output Elements
953 @c ---------------
954 @node Output Elements, Theme Mechanism, Output, Output
955 @section Output Elements
956 Let's look at the output of @command{program --help} in a default
957 setting first:
959 @cartouche
960 @verbatim
961 Usage: program [-hdF] [+d] [OPTIONS] FILES...
963 A clonified program.
965   -h, --help                  Print this help and exit.
966 Runtime options:
967   -(+)d, --debug[=yes/no]     Turn debugging on or off.
968                               Fallback: yes
969                               Environment: DEBUG
970                               Default: no
971   --simulate=yes/no           Simulate only. Nothing will happen for real,
972                               except for log messages.
973 User identification:
974   -f, --first-name=STR        Set the user's first name to STR.
975   -F, --family-name[=NAME]    Set the user's family name to NAME.
976                               Fallback: unknown
977 @end verbatim
978 @end cartouche
980 @cindex Synopsis
981 @cindex Output, synopsis
982 @cindex Postfix
983 @cindex Short packs
984 @cindex Packs, short
985 @cindex Negated packs
986 @cindex Negated Short Packs
987 @cindex Negated packs, short
988 @cindex Packs, negated
989 @cindex Packs, short, negated
990 The first line of output is what's called the @emph{synopsis}. This
991 synopsis indicates that the program accepts a number of options and also
992 a postfix consisting of file names. The set of available options is not
993 detailed in the synopsis but for convenience, @clon{} shows the
994 available short and negated packs explicitly.
996 @cindex Text
997 @cindex Arbitrary Text
998 @cindex Text, arbitrary
999 The next non-empty line is just text. A clonified application is free to
1000 put arbitrary text anywhere in its help string. This can be used to
1001 describe what the application is about for instance.
1003 @cindex Groups
1004 @cindex Arbitrary Text, in groups
1005 @cindex Text, in groups
1006 @cindex Options, in groups
1007 @cindex Groups, in groups
1008 @cindex Groups, titles
1009 Two other lines in the help string look like arbitrary text, but in fact
1010 are not: ``Runtime options:'' and ``User identification:''. These are
1011 not arbitrary text, but @emph{group titles}. A group is a way of putting
1012 help string items together, for instance because they are related to the
1013 same topic. A group has an optional title, and may contain options,
1014 arbitrary text or even sub-groups.
1016 @cindex Groups
1017 @cindex Groups, built-in
1018 @bioindex{help}
1019 In addition to displaying the full help string, a clonified application
1020 may display a group's help string only (in such a case, you don't get to
1021 see the synopsis). This is what happens when you type @command{program
1022 --clon-help} for instance. @clon{}'s built-in options belong to a
1023 reserved built-in group.
1025 @cindex Flags
1026 @cindex Options, types, flags
1027 @cindex Valued Options
1028 @cindex Options, types, valued
1029 @cindex Switches
1030 @cindex Options, types, switches
1031 @cindex Long Form
1032 @cindex Short Form
1033 @cindex Command-Line, options, long form
1034 @cindex Command-Line, options, short form
1035 @cindex Negated Form
1036 @cindex Negated Short Form
1037 @cindex Short Form, negated
1038 @cindex Options, command-line, negated form
1039 @cindex Options, command-line, negated short form
1040 @cindex Options, command-line, short form, negated
1041 @cindex Command-Line, options, negated form
1042 @cindex Command-Line, options, negated short form
1043 @cindex Command-Line, options, short form, negated
1044 Let's have a look at the options now. In the first column, you can see
1045 that depending on the option, the long, short and negated forms are
1046 advertised. Valued options also advertise their argument, enclosed in
1047 square brackets when it is optional. In this example, @samp{-h} is a
1048 flag, @samp{-d} and @samp{--simulate} are switches with different
1049 settings, while @samp{-f} and @samp{-F} are standard valued options.
1051 @cindex Options, description
1052 The second column of the help string provides each option's
1053 @emph{description}. Descriptions can span across several lines, as in
1054 the case of @samp{--simulate}. @clon{} takes care of properly aligning
1055 all the material that needs to be displayed.
1057 @cindex Fallback values
1058 @cindex Values, fallback
1059 @cindex Environment
1060 @cindex Default values
1061 @cindex Values, default
1062 Finally, you can see that potential fallback values, environment
1063 variables and default values are also advertised in that order, when
1064 appropriate.
1068 @c ---------------
1069 @c Theme Mechanism
1070 @c ---------------
1071 @node Theme Mechanism, Global Control, Output Elements, Output
1072 @section Theme Mechanism
1073 @cindex Theme Mechanism
1075 @cindex Themes
1076 @cindex Themes, built-in
1077 @cindex Themes, built-in, @t{raw}
1078 @cindex Built-in themes
1079 @cindex Built-in themes, @t{raw}
1080 The output of @command{program --help} that we have seen in the previous
1081 section corresponds to a default setting, but is really just one
1082 possibility. As the user of a clonified application, you have the
1083 ability to customize the appearance of @clon{}'s output. The way things
1084 look is specified by so-called @emph{themes}. @clon{} has a theme named
1085 @t{raw} which every clonified application has built-in.
1087 @cindex Themes, files
1088 @cindex Themes, files, @t{cth} extension
1089 @cindex @t{cth} extension
1090 @cindex File Extension
1091 @cindex File Extension, @t{cth}
1092 Other themes are stored in files the standard extension of which is
1093 @samp{cth} (as in @b{C}lon @b{TH}eme). In fact, theme files can be named
1094 as you like; this is just a convention.
1096 @menu
1097 * Standard Themes::     Some example themes are provided
1098 * Search Path::         Where to find theme files
1099 * Theme Selection::     How to select a theme
1100 @end menu
1102 @node Standard Themes, Search Path, Theme Mechanism, Theme Mechanism
1103 @subsection Standard Themes
1104 @cindex Themes, files, standard
1105 @cindex Standard Themes
1106 @cindex Standard Themes, files
1107 @clon{} comes with several standard themes in files that can be used
1108 as-is or serve as the basis for creating new ones (@pxref{Theme
1109 Creation}). The list is given below.
1111 @table @t
1112 @item raw
1113 @cindex Standard Themes, files, @file{raw.cth}
1114 @cindex Themes, files, standard, @file{raw.cth}
1115 Exactly the same as the built-in one, only copied into a theme file.
1116 @item optlist
1117 @cindex Standard Themes, files, @file{optlist.cth}
1118 @cindex Themes, files, standard, @file{optlist.cth}
1119 Displays only a list of available options, one per line, without any
1120 description, group indication or arbitrary text. This can be used to
1121 quickly remember the name or the syntax of an option.
1122 @item refcard
1123 @cindex Standard Themes, files, @file{refcard.cth}
1124 @cindex Themes, files, standard, @file{refcard.cth}
1125 Displays a very compact help string. The synopsis is there, so are the
1126 group titles and arbitrary texts, but the options are displayed without
1127 any description, and the lines are filled as much as possible. The
1128 intent of this theme is to produce some sort of ``reference card'' that
1129 could be printed.
1130 @item roomy
1131 @cindex Standard Themes, files, @file{roomy.cth}
1132 @cindex Themes, files, standard, @file{roomy.cth}
1133 Displays a full help string occupying more space than the @t{raw} theme.
1134 Option descriptions don't start @emph{after} the option's name, but
1135 @emph{under} it. As a result, they occupy more horizontal space. Also,
1136 sub-groups are indented to the right.
1137 @item dvl
1138 @cindex Standard Themes, files, @file{dvl.cth}
1139 @cindex Themes, files, standard, @file{dvl.cth}
1140 This is my personal theme that I personally use myself in person.
1141 @item christmas
1142 @cindex Standard Themes, files, @file{christmas.cth}
1143 @cindex Themes, files, standard, @file{christmas.cth}
1144 This one is full of bells and whistles, which makes it essentially
1145 unusable. It exists only to provide a concrete example of all the
1146 available formatting and highlighting features of @clon{}. The
1147 @t{christmas} theme is only available once a year, at exactly 23:59:59
1148 on December the 24th.
1149 @end table
1151 @node Search Path, Theme Selection, Standard Themes, Theme Mechanism
1152 @subsection Search Path
1153 @cindex Search Path
1154 @cindex Search Path, themes
1155 @cindex Themes, search path
1156 @clon{} maintains a search path for looking up files. Theme files are
1157 supposed to be located in a @file{themes} directory of every
1158 directory in the search path. By default, the search path is as follows:
1159 @itemize @w{}
1160 @item
1161 @t{~/.clon/}
1162 @item
1163 @t{~/Library/Application Support/Clon/} (MacOS only)
1164 @item
1165 @t{~/share/clon/}
1166 @item
1167 @t{/Library/Application Support/Clon/} (MacOS only)
1168 @item
1169 @t{/usr/local/share/clon/}
1170 @item
1171 @t{/usr/share/clon/}
1172 @end itemize
1174 @bioindex{search-path}
1175 @bievindex{SEARCH_PATH}
1176 The search path can be modified with the @bioption{search-path} built-in
1177 option or its accompanying @env{CLON_SEARCH_PATH} environment variable.
1178 It takes a list of colon-separated directories as argument. This
1179 argument is in fact optional. Not providing an argument is equivalent to
1180 providing an empty one, which basically reduces the search path to the
1181 application's current directory.
1184 @node Theme Selection, , Search Path, Theme Mechanism
1185 @subsection Theme Selection
1186 @bioindex{theme}
1187 @bievindex{THEME}
1188 In order to select a theme, you can use the built-in option
1189 @bioption{theme} or its accompanying environment variable
1190 @env{CLON_THEME}. Just provide it with the theme name, and the
1191 corresponding theme file will be looked up in the search path
1192 (@pxref{Search Path}), stopping at the first match.
1194 @cindex File Extension, @t{cth}
1195 @cindex @t{cth} extension
1196 @cindex Themes, files, @t{cth} extension
1197 You can omit the @samp{cth} extension: @clon{} looks for a file named
1198 exactly as you said first and attempts to add the theme extension next.
1199 Note that searching with or without extension has priority over the
1200 search path. For instance, suppose that the following files exist:
1201 @itemize @w{}
1202 @item
1203 @t{/usr/local/share/clon/themes/foobar}
1204 @item
1205 @t{/usr/share/clon/themes/foobar.cth}
1206 @end itemize
1207 Using @bioption{theme=foobar} will match the first one while
1208 @bioption{theme=foobar.cth} will match the second.
1210 Now suppose that the following files exist:
1211 @itemize @w{}
1212 @item
1213 @t{/usr/local/share/clon/themes/foobar.cth}
1214 @item
1215 @t{/usr/share/clon/themes/foobar}
1216 @end itemize
1217 Using either @bioption{theme=foobar} or @bioption{theme=foobar.cth} will
1218 always match the first file. Which brings us to the next point (how
1219 clever).
1221 It is possible to bypass the search path when looking for a theme: just
1222 provide @bioption{theme} with a theme name starting with a path
1223 component (@ie{} @samp{/}, @samp{./} or @samp{../}). Even in that case,
1224 you can still omit the @samp{cth} extension.
1226 @cindex Built-in themes, @t{raw}
1227 @cindex Themes, built-in, @t{raw}
1228 @cindex Standard Themes, files, @file{raw.cth}
1229 @cindex Themes, files, standard, @file{raw.cth}
1230 Finally, here is an important precision about @bioption{theme}. This
1231 option has a fallback of @t{nil} and a default of @t{raw}. This means
1232 that if you don't use the option at all, a theme named @t{raw} will be
1233 looked up in the search path. This theme exists in the standard
1234 distribution and you are free to modify it. On the other hand, since
1235 this option has a fallback, it means that its argument is optional. If
1236 you don't provide any argument (that is, if you just use
1237 @bioption{theme}), then the @emph{built-in} raw theme will be used. This
1238 theme is originally identical to the one provided in the file
1239 @file{raw.cth} but since it is built in every clonified application, you
1240 cannot change it.
1243 @c --------------
1244 @c Global Control
1245 @c --------------
1246 @node Global Control, Theme Creation, Theme Mechanism, Output
1247 @section Global Control
1249 In addition to selecting the appropriate theme, @clon{} provides two
1250 built-in options that give you additional control on the output. These
1251 options are orthogonal to themes: all themes implicitly honor them.
1252 Since their description is pretty self-explanatory, they are given
1253 below.
1255 The first one allows you to control the output's line width:
1256 @bioindex{line-width}
1257 @bievindex{LINE_WIDTH}
1258 @evindex{COLUMNS}
1259 @verbatim
1260   --clon-line-width=WIDTH     Set Clon's output line width.
1261                               If not given, the value of the COLUMNS
1262                               environment variable, the terminal size,
1263                               or a default of 80 columns will be used.
1264                               Environment: CLON_LINE_WIDTH
1265 @end verbatim
1267 The second one deals with @emph{highlighting} (@pxref{Highlight}).
1268 @clon{} has the ability to highlight the output through ISO/IEC 6429 SGR
1269 escape sequences. The built-in raw theme doesn't do highlighting but
1270 other do.
1271 @bioindex{highlight}
1272 @bievindex{HIGHLIGHT}
1274 @verbatim
1275   --clon-highlight[=ARG]      Set Clon's output highlighting to on/off/auto.
1276                               Auto (the default) means on for tty output and
1277                               off otherwise.
1278                               Fallback: yes
1279                               Default: auto
1280                               Environment: CLON_HIGHLIGHT
1281 @end verbatim
1283 A word of caution is in order here. For technical reasons (in fact, the
1284 potential inability to detect a terminal properly), it is possible that
1285 the @code{auto} setting for @bioption{highlight}, which happens to be
1286 the default, doesn't work. In such a case, highlight is switched off,
1287 and you need to use @bioption{highlight=yes} explicitely to force it.
1289 For the same technical reason, it may be impossible to detect a terminal
1290 line width from time to time, in which case it would fall back to 80
1291 columns. This particular problem is much less likely to bite you because
1292 the @code{COLUMNS} environment variable should be set all the time.
1294 Both of these problems may or may not occur for specific applications,
1295 depending on their underlying implementation.
1298 @c ---------------
1299 @c Theme Creation
1300 @c ---------------
1301 @node Theme Creation, , Global Control, Output
1302 @section Theme Creation
1303 Perhaps the most exciting thing in Computer Science is to spend more
1304 time hacking a tool than actually using it. After reading this section,
1305 you will find yourselves spending days customizing theme files instead
1306 of using clonified applications.
1308 @menu
1309 * Theme Elements::      Faces, properties, comments
1310 * Faces::               Boy, you look just like your mother
1311 * Highlight::           Text Appearance
1312 * Layout::              Text geometry
1313 * Implicit Faces::      Missing definitions and siblings
1314 @end menu
1316 @node Theme Elements, Faces, Theme Creation, Theme Creation
1317 @subsection Theme Elements
1318 @cindex Faces
1319 @cindex Face Properties
1320 @cindex Themes, faces
1321 @cindex Themes, faces, properties
1322 Hear hear! If you understand what @command{M-x all-hail-[x]emacs} means,
1323 you're going to get quite comfy here. @clon{} themes are articulated
1324 around two basic concepts: @emph{faces} and (face) @emph{properties}. A
1325 property describes some visual attribute for some piece of text, for
1326 instance bold, red, indented by 2 columns to the right. A face is more
1327 or less a set of properties (but there's more to it than that; please
1328 hold your post). Every piece of text in @clon{}'s output is associated
1329 with a face, which in turn defines specific values for specific
1330 properties.
1332 @cindex Layout Properties
1333 @cindex Faces, properties, layout
1334 @cindex Themes, faces, properties, layout
1335 @cindex Highlight Properties
1336 @cindex Faces, properties, highlight
1337 @cindex Themes, faces, properties, highlight
1338 There are two property types in @clon{}: @emph{highlight properties},
1339 which describe the visual appearance of characters (color, font @etc{}),
1340 and @emph{layout properties}, which describe the text geometry (line
1341 width, indentation @etc{}). Please see @ref{Highlight Properties} and
1342 @ref{Layout Properties} for an exhaustive list of them.
1344 Let's have a look at a very simple theme file now.
1346 @cartouche
1347 @verbatim
1348 ;; A very simple theme file.
1350 :background black
1351 ;; ...
1353 :face (synopsis :foreground red
1354                 ;; ...
1355                 :face (header :bold t #| ...|#)
1356                 #| ... |#)
1357 ;; ...
1358 @end verbatim
1359 @end cartouche
1361 @cindex Themes, files, comments
1362 The first line is a comment. Comments begin with a semi-colon and extend
1363 to the end of the line. There is another syntax for comments, as show
1364 later in the file: a comment can be opened with @samp{#|} and closed
1365 with @samp{|#}. This form allows you to create comments that span across
1366 several lines, or just part of a single line.@footnote{By now, you have
1367 realized that a theme file is just a piece of @cl{} code@dots{} No,
1368 wait! Don't go!}
1370 @cindex Face Properties
1371 @cindex Themes, faces, properties
1372 @cindex Themes, files, keywords
1373 @cindex Themes, files, keywords, @t{:background}
1374 @cindex Faces, @t{toplevel}
1375 @cindex Themes, faces, @t{toplevel}
1376 The next line sets the @samp{background} property to @samp{black}. It
1377 means that @clon{}'s output will be displayed over a black background
1378 (no kidding). Every property in @clon{} has a name, which you specify by
1379 using a @emph{keyword} (@ie{} the name prepended with a colon). But
1380 wait, properties are supposed to belong to faces, right? So what is that
1381 property doing, floating around like that in the file? That's right,
1382 clever. In fact, the whole output of @clon{} is wrapped in a global face
1383 called @samp{toplevel}. You will never need to mention this face
1384 explicitly, though, because the contents of theme files is always
1385 enclosed in that face.
1387 @cindex Themes, files, keywords
1388 @cindex Themes, files, keywords, @t{:face}
1389 @cindex Themes, files, keywords, @t{:foreground}
1390 @cindex Themes, files, keywords, @t{:bold}
1391 @cindex Faces, @t{synopsis}
1392 @cindex Themes, faces, @t{synopsis}
1393 @cindex Faces, @t{header}
1394 @cindex Themes, faces, @t{header}
1395 Later in the file, you find yourself contemplating a face specification.
1396 Faces are specified by using the keyword @samp{:face}. What follows is a
1397 list beginning with the face name, and continuing with property
1398 specifications. In this particular example, we're specifying that the
1399 synopsis line (the one that says ``Usage: blah blah'') should appear in
1400 red, although as you can see, the story does not stop there.
1402 @cindex Faces, nesting
1403 @cindex Themes, faces, nesting
1404 @cindex Face properties, inheritance
1405 Indeed, there is also a @samp{header} face specification @emph{within}
1406 the @samp{synopsis} one. What it says it that the header part (the
1407 ``Usage:'' portion of the synopsis line) should additionally be
1408 displayed in bold font. So it turns out that face specifications can be
1409 nested. In fact, @emph{all} the faces you specify are sub-faces of the
1410 @samp{toplevel} face at some level. In this example, the @samp{header}
1411 face is a sub-face of the @samp{synopsis} one. This is important for two
1412 reasons:
1413 @enumerate
1414 @item
1415 face nesting leads to the notion of property inheritance
1416 (@pxref{Highlight Inheritance}),
1417 @item
1418 @clon{} makes use of faces with the same name in different (nesting)
1419 contexts. For instance, there are many places where the @samp{header}
1420 face is used (@pxref{Faces}), but this face can have very different
1421 specifications according to where it appears in a face tree.
1422 @end enumerate
1424 @node Faces, Highlight, Theme Elements, Theme Creation
1425 @subsection Faces
1426 @cindex Faces
1427 @cindex Themes, faces
1429 @cindex Built-in themes, @t{raw}
1430 @cindex Themes, built-in, @t{raw}
1431 @cindex Standard Themes, files, @file{raw.cth}
1432 @cindex Themes, files, standard, @file{raw.cth}
1433 @cindex Faces, @t{synopsis}
1434 @cindex Faces, @t{header}
1435 @cindex Faces, @t{program}
1436 @cindex Faces, @t{short-pack}
1437 @cindex Faces, @t{negated-pack}
1438 @cindex Faces, @t{options}
1439 @cindex Faces, @t{postfix}
1440 @cindex Faces, @t{text}
1441 @cindex Faces, @t{option}
1442 @cindex Faces, @t{syntax}
1443 @cindex Faces, @t{short}
1444 @cindex Faces, @t{name}
1445 @cindex Faces, @t{argument}
1446 @cindex Faces, @t{long}
1447 @cindex Faces, @t{usage}
1448 @cindex Faces, @t{description}
1449 @cindex Faces, @t{fallback}
1450 @cindex Faces, @t{value}
1451 @cindex Faces, @t{default}
1452 @cindex Faces, @t{environment}
1453 @cindex Faces, @t{variable}
1454 @cindex Themes, faces, @t{synopsis}
1455 @cindex Themes, faces, @t{header}
1456 @cindex Themes, faces, @t{program}
1457 @cindex Themes, faces, @t{short-pack}
1458 @cindex Themes, faces, @t{negated-pack}
1459 @cindex Themes, faces, @t{options}
1460 @cindex Themes, faces, @t{postfix}
1461 @cindex Themes, faces, @t{text}
1462 @cindex Themes, faces, @t{option}
1463 @cindex Themes, faces, @t{syntax}
1464 @cindex Themes, faces, @t{short}
1465 @cindex Themes, faces, @t{name}
1466 @cindex Themes, faces, @t{argument}
1467 @cindex Themes, faces, @t{long}
1468 @cindex Themes, faces, @t{usage}
1469 @cindex Themes, faces, @t{description}
1470 @cindex Themes, faces, @t{fallback}
1471 @cindex Themes, faces, @t{value}
1472 @cindex Themes, faces, @t{default}
1473 @cindex Themes, faces, @t{environment}
1474 @cindex Themes, faces, @t{variable}
1475 The following figure shows the full face tree defined by @clon{}. In
1476 fact, it is extracted from the theme file @file{raw.cth} (property
1477 specifications have been removed). By the way, that is why it is a good
1478 idea to start from this one when you want to create a new theme: all the
1479 faces are in there. It should be pretty easy to figure out what portion
1480 of text each face applies to.
1482 @cartouche
1483 @verbatim
1484 ;; Remember that everything in here belongs to the toplevel face.
1485 :face (synopsis :face header
1486                 :face program
1487                 :face short-pack
1488                 :face negated-pack
1489                 :face options
1490                 :face postfix)
1491 :face text
1492 :face (option :face (syntax :face (short :face name
1493                                          :face argument)
1494                             :face (long  :face name
1495                                          :face argument))
1496               :face (usage :face description
1497                            :face (fallback :face header
1498                                            :face value)
1499                            :face (default :face header
1500                                           :face value)
1501                            :face (environment :face header
1502                                               :face variable)))
1503 :face (group :face header
1504              :face (items #| :face text :face option :face group |#))
1505 @end verbatim
1506 @end cartouche
1508 As mentioned earlier, you can see that faces of the same name may appear
1509 at different places in the tree (@eg{} the @samp{header} one) and hence
1510 may have different specifications, depending on the context (their
1511 branch in the tree).
1513 Pushing this idea one step further, note the peculiarity of the
1514 @samp{group} face: since group items may be arbitrary text, options or
1515 even sub-groups, you can specify as many levels of group nesting as you
1516 want. In fact, you can spend your whole life specifying sub-groups,
1517 although it is very unlikely that a clonified application provides more
1518 than two or three levels of group imbrication.
1520 One last point to note: you might be surprised to find @emph{empty} face
1521 specifications like this one: @samp{:face description}. This @emph{is} a
1522 valid specification, and this @emph{is} different from not mentioning
1523 the face at all, or specifying some properties explicitly. See
1524 @ref{Layout Inheritance} for an explanation.
1527 @node Highlight, Layout, Faces, Theme Creation
1528 @subsection Highlight
1529 The first category of properties that we are going to describe deals
1530 with @emph{highlighting}, that is, modifying the visual aspect of
1531 characters in the output.
1533 @menu
1534 * Highlight Properties::        What is available
1535 * Highlight Inheritance::       What happens in a face tree
1536 @end menu
1538 @node Highlight Properties, Highlight Inheritance, Highlight, Highlight
1539 @subsubsection Highlight Properties
1540 @cindex Highlight Properties
1541 @cindex Faces, properties, highlight
1542 @cindex Themes, faces, properties, highlight
1543 @clon{} supports 10 highlight properties defined by the ISO/IEC 6429 SGR
1544 standard (under the assumption that your favorite terminal program
1545 supports them). Their description is given below.
1547 @table @t
1548 @item :foreground
1549 @cindex Face Properties, highlight, @t{foreground}
1550 @cindex Themes, faces, properties, highlight, @t{foreground}
1551 @cindex Themes, files, keywords, @t{:foreground}
1552 @item :background
1553 @cindex Face Properties, highlight, @t{background}
1554 @cindex Themes, faces, properties, highlight, @t{background}
1555 @cindex Themes, files, keywords, @t{:background}
1556 The face's foreground and background colors. Possible values are
1557 @t{black}, @t{red}, @t{green}, @t{yellow}, @t{blue}, @t{magenta},
1558 @t{cyan} and @t{white}. It is also possible to use the special values
1559 @t{nil} or @t{reset} to reset the color to the terminal's default value.
1560 @item :intensity
1561 @cindex Face Properties, highlight, @t{intensity}
1562 @cindex Themes, faces, properties, highlight, @t{intensity}
1563 @cindex Themes, files, keywords, @t{:intensity}
1564 The face's intensity. Possible values are @t{bold}, @t{normal} (or
1565 @t{nil}) and @t{faint}. Please note that @t{faint} is usually not very
1566 well supported.
1567 @cindex Face Properties, highlight, @t{bold}
1568 @cindex Themes, faces, properties, highlight, @t{bold}
1569 @cindex Themes, files, keywords, @t{:bold}
1570 For convenience, a @t{:bold} Boolean property is also provided which
1571 will set the face's intensity to @t{bold} if true (@t{t}) and @t{normal}
1572 if false (@t{nil}).
1573 @item :italic
1574 @cindex Face Properties, highlight, @t{italic}
1575 @cindex Themes, faces, properties, highlight, @t{italic}
1576 @cindex Themes, files, keywords, @t{:italic}
1577 Whether to display the face's contents in italics. This is a Boolean
1578 property. Possible values are @t{t} or @t{nil}. The effect of this
1579 property depends a lot on the font you use in your terminal application.
1580 @item :underline
1581 @cindex Face Properties, highlight, @t{underline}
1582 @cindex Themes, faces, properties, highlight, @t{underline}
1583 @cindex Themes, files, keywords, @t{:underline}
1584 Whether to underline the face's contents. Possible values are @t{single}
1585 (or @t{on} or @t{t}), @t{double} and @t{none} (or @t{off} or @t{nil}).
1586 Please note that @t{double} is usually not very well supported.
1587 @item :blink
1588 @cindex Face Properties, highlight, @t{blink}
1589 @cindex Themes, faces, properties, highlight, @t{blink}
1590 @cindex Themes, files, keywords, @t{:blink}
1591 The face's blink speed. Possible values are @t{slow} (or @t{on} or
1592 @t{t}), @t{rapid} and @t{off} (or @t{nil}). Please note that @t{rapid}
1593 is usually not very well supported.
1594 @item :inverse
1595 @cindex Face Properties, highlight, @t{inverse}
1596 @cindex Themes, faces, properties, highlight, @t{inverse}
1597 @cindex Themes, files, keywords, @t{:inverse}
1598 Whether to display the face's contents in inverse video. This is a
1599 Boolean property. Possible values are @t{t} or @t{nil}.
1600 @item :crossed-out
1601 @cindex Face Properties, highlight, @t{crossed-out}
1602 @cindex Themes, faces, properties, highlight, @t{crossed-out}
1603 @cindex Themes, files, keywords, @t{:crossed-out}
1604 Whether to display the face's contents crossed out. This is a Boolean
1605 property. Possible values are @t{t} or @t{nil}.
1606 @item :framed
1607 @cindex Face Properties, highlight, @t{framed}
1608 @cindex Themes, faces, properties, highlight, @t{framed}
1609 @cindex Themes, files, keywords, @t{:framed}
1610 Whether to display the face's contents framed or encircled. This is a
1611 Boolean property. Possible values are @t{t} or @t{nil}.
1612 @item :concealed
1613 @cindex Face Properties, highlight, @t{concealed}
1614 @cindex Themes, faces, properties, highlight, @t{concealed}
1615 @cindex Themes, files, keywords, @t{:concealed}
1616 Whether to conceal the face's contents. This is a Boolean property.
1617 Possible values are @t{t} or @t{nil}. In case it is not obvious,
1618 concealing means that the face's contents is not displayed, but still
1619 occupies its normal space, so this is different from hiding it
1620 (@pxref{Layout Properties}).
1621 @cindex Face Properties, highlight, @t{revealed}
1622 @cindex Themes, faces, properties, highlight, @t{revealed}
1623 @cindex Themes, files, keywords, @t{:revealed}
1624 Alternately, you can also use the opposite Boolean property named
1625 @t{:revealed}.
1626 @end table
1628 @node Highlight Inheritance, , Highlight Properties, Highlight
1629 @subsubsection Highlight Inheritance
1630 @cindex Face Properties, inheritance
1631 @cindex Face Properties, highlight, inheritance
1632 @cindex Themes, faces, properties, inheritance
1633 @cindex Themes, faces, properties, highlight, inheritance
1634 @cindex Themes, built-in, @t{raw}
1635 @cindex Built-in themes, @t{raw}
1636 By default (this is also the case in the @samp{raw} theme), all
1637 highlight properties are turned off: text is output in whatever way is
1638 standard on the current terminal.
1640 When you set a face's highlight property however, it is inherited by all
1641 the sub-faces. This is in fact the most natural behavior. For instance,
1642 if you set the foreground of the @samp{synopsis} face to red, you
1643 probably expect the whole synopsis line to be output in red, including
1644 the header, program @etc{} parts. If not, you need to explicitly
1645 neutralize the unwanted effect, for instance by saying something like
1646 this:
1648 @verbatim
1649 :face (synopsis :foreground red
1650                 :face (program :foreground reset)
1651                 :face (postfix :foreground cyan))
1652 @end verbatim
1654 In other words, you can consider that the way some piece of text is
1655 output is not specified exactly by its associated face, but rather by
1656 the merging of all active properties from the whole corresponding face
1657 tree. This is exactly how Emacs faces work by the way.
1659 @node Layout, Implicit Faces, Highlight, Theme Creation
1660 @subsection Layout
1661 The second category of properties that we are going to describe deals
1662 with @emph{layout}, that is, modifying the placement of text in the
1663 output.
1665 @menu
1666 * Layout Properties::   What is available
1667 * Layout Inheritance::  What happens in a face tree
1668 @end menu
1670 @node Layout Properties, Layout Inheritance, Layout, Layout
1671 @subsubsection Layout Properties
1672 @cindex Layout Properties
1673 @cindex Faces, properties, layout
1674 @cindex Themes, faces, properties, layout
1675 In addition to the 10 highlight properties described in the previous
1676 section, @clon{} defines 6 layout properties. Here are the first 4 of
1677 them, along with their description and default value.
1679 @table @t
1680 @item :visible
1681 @cindex Face Properties, layout, @t{visible}
1682 @cindex Themes, faces, properties, layout, @t{visible}
1683 @cindex Themes, files, keywords, @t{:visible}
1684 @cindex Face Properties, layout, @t{hidden}
1685 @cindex Themes, faces, properties, layout, @t{hidden}
1686 @cindex Themes, files, keywords, @t{:hidden}
1687 @cindex Standard Themes, files, @file{optlist.cth}
1688 @cindex Themes, files, standard, @file{optlist.cth}
1689 @cindex Standard Themes, files, @file{refcard.cth}
1690 @cindex Themes, files, standard, @file{refcard.cth}
1691 Whether the face's contents is visible. Possible values are @t{t} (the
1692 default), or @t{nil}. You can also use the opposite property named
1693 @t{:hidden}. The @samp{optlist} and @samp{refcard} themes make use of
1694 this to avoid printing the options descriptions.
1695 @cindex Face Properties, highlight, @t{display}
1696 @cindex Themes, faces, properties, highlight, @t{display}
1697 @cindex Themes, files, keywords, @t{:display}
1698 Since the notions of hiding, concealing or making text visible are
1699 somewhat intermixed, @clon{} also provides a ``bastard'' property which,
1700 depending on its value, would be considered either a layout, or a
1701 highlight one. This property is named @t{:display}. Possible values are:
1702 @t{visible} (or @t{revealed} or @t{t}), @t{concealed} and @t{hidden} (or
1703 @t{nil}).
1704 @item :padding-top
1705 @cindex Face Properties, layout, @t{padding-top}
1706 @cindex Themes, faces, properties, layout, @t{padding-top}
1707 @cindex Themes, files, keywords, @t{:padding-top}
1708 The face's top padding, that is, the number of lines to skip before
1709 opening it and displaying its contents. This property can take the
1710 following forms.
1711 @table @t
1712 @item nil
1713 This face may be opened anywhere, including on the current line. This is
1714 the default.
1715 @item 0
1716 This face should be opened on the next line.
1717 @item <num> @r{(positive)}
1718 This face should be opened after skipping @t{<num>} empty lines. Note
1719 that the empty lines are displayed in the enclosing face, @emph{not} the
1720 face which specifies the top padding.
1721 @end table
1722 @item :padding-bottom
1723 @cindex Face Properties, layout, @t{padding-bottom}
1724 @cindex Themes, faces, properties, layout, @t{padding-bottom}
1725 @cindex Themes, files, keywords, @t{:padding-bottom}
1726 This face's bottom padding, that is, the number of lines to skip before
1727 opening the next face and displaying its contents. This property can
1728 take the following forms.
1729 @table @t
1730 @item nil
1731 The next face may be opened anywhere, including on the current line.
1732 This is the default.
1733 @item 0
1734 The next face should be opened on the next line.
1735 @item <num> @r{(positive)}
1736 The next face should be opened after skipping @t{<num>} lines. Note that
1737 the empty lines are displayed in the enclosing face, @emph{not} the face
1738 which specifies the bottom padding.
1739 @end table
1740 @item :item-separator
1741 @cindex Face Properties, layout, @t{item-separator}
1742 @cindex Themes, faces, properties, layout, @t{item-separator}
1743 @cindex Themes, files, keywords, @t{:item-separator}
1744 The face's item separator, that is, a piece of text to insert between
1745 every sub-face's contents. The default value is @t{#\space} (a space
1746 character).
1747 @end table
1748 @cindex Themes, built-in, @t{raw}
1749 @cindex Built-in Themes, @t{raw}
1750 The default values above have been chosen because they are convenient
1751 for the majority of the faces, but not necessarily all the time. Let us
1752 now review some examples of non-default settings in the @samp{raw}
1753 theme.
1754 @itemize @bullet
1755 @item
1756 The @samp{synopsis} face has its bottom padding set to 1, which means to
1757 leave an empty line below it. Note that this line does not belong to the
1758 synopsis. It is output in the @samp{toplevel} face.
1759 @item
1760 The @samp{text}, @samp{option} and @samp{group} faces have both their
1761 top and bottom paddings set to 0. This means that all these items should
1762 start and end on lines of their own.
1763 @item
1764 Finally, the @samp{syntax} face has its item separator set to
1765 @w{@t{", "}}, which in this context is used to separate the short and
1766 long name syntax, as in @w{@samp{-h, --help}}.
1767 @end itemize
1769 @cindex Frames
1770 @cindex Layout, frames
1771 In order to describe the last two layout properties, we need to
1772 introduce the notion of @emph{frame} first. A frame is a rectangle in
1773 which @clon{} prints something. When @clon{} opens a face for printing
1774 its contents, it associates a frame with it. Usually, @clon{} doesn't
1775 know the frame's height because it doesn't know in advance how many
1776 lines of output will be necessary to display the face's contents.
1777 However, @clon{} usually knows the frame's width: a frame starts at a
1778 certain column (the left one) and stops at another (the right one).
1780 There is an isomorphic relation between frames and faces: when a face is
1781 a sub-face of a super-face, the corresponding frame is a sub-frame of
1782 the corresponding super-frame. Sub-frames are geometrically enclosed
1783 within their super-frames: a sub-frame can only draw in an equally large
1784 or narrower band than its super-frame. That's how @clon{} handles
1785 vertical alignment of text.
1787 In order to give you control on the starting and ending columns of every
1788 frame (in fact, every face), the following two layout properties are
1789 defined.
1791 @table @t
1792 @item :padding-left
1793 @cindex Face Properties, layout, @t{padding-left}
1794 @cindex Themes, faces, properties, layout, @t{padding-left}
1795 @cindex Themes, files, keywords, @t{:padding-left}
1796 A face's left padding determines its starting column. This property can
1797 take the following forms.
1798 @table @t
1799 @item <num>
1800 Skip @t{<num>} columns relatively to the enclosing face. The default
1801 value is 0, meaning to open this face at the same column number as the
1802 enclosing one.
1803 @item (<num> :relative-to <face>)
1804 As above, but relatively to a @emph{parent} face named @t{<face>}
1805 instead of just the enclosing one. This lets you go more than one level
1806 up in the face tree.
1807 @item (<num> absolute)
1808 Open this face exactly at column @t{<num>}.
1809 @item self
1810 This face may be opened anywhere, and when it is, its left column is set
1811 to the current column number.
1812 @end table
1813 @item :padding-right
1814 @cindex Face Properties, layout, @t{padding-right}
1815 @cindex Themes, faces, properties, layout, @t{padding-right}
1816 @cindex Themes, files, keywords, @t{:padding-right}
1817 A face's right padding, determines its ending column. This property can
1818 take the following forms.
1819 @table @t
1820 @item <num>
1821 Close this face @t{<num>} columns before the enclosing one.
1822 @item (<num> :relative-to <face>)
1823 As above, but relatively to a @emph{parent} face named @t{<face>}
1824 instead of just the enclosing one. This lets you go more than one level
1825 up in the face tree.
1826 @item (<num> absolute)
1827 Close this face exactly at column @t{<num>}.
1828 @item self
1829 This face may be closed anywhere. This is the default.
1830 @end table
1831 @end table
1832 @cindex Themes, built-in, @t{raw}
1833 @cindex Built-in Themes, @t{raw}
1834 The default values above have been chosen because they are convenient
1835 for the majority of the faces, but not necessarily all the time. Let us
1836 now review some examples of non-default settings in the @samp{raw}
1837 theme.
1838 @itemize @bullet
1839 @item
1840 The @samp{option} face has its left padding set to 2. Since all
1841 super-faces default to 0, this essentially mean an indentation of 2
1842 columns.
1843 @item
1844 The @samp{usage} face has its left padding set to @t{(30 absolute)}
1845 which means that the descriptive texts for all options start aligned at
1846 column 30.
1847 @end itemize
1849 @cindex Faces, self-ending
1850 There is one important point to understand about self-ending faces
1851 (which, again, is the default setting). A self-ending face typically
1852 doesn't know at which column it stops until it stops. In fact, this is
1853 not completely true: if the face's contents needs to span across several
1854 lines, then the ending column will be known at the end of the first
1855 line, when the ending column of the enclosing face is reached. However,
1856 for a piece of contents that fits on a single line, the point holds.
1858 Because of that, it is impossible for a face's right padding to be
1859 relative to a self-ending face. This would be like saying ``stop 2
1860 columns before I don't know where''. Here are two examples of such
1861 invalid settings (an error will be thrown if you try that in a theme):
1863 @verbatim
1864 :face (option :face (syntax :padding-right 2))
1865 :face (option
1866         :face (syntax
1867                 :face (short
1868                         :padding-right (2 :relative-to option))))
1869 @end verbatim
1871 @node Layout Inheritance, , Layout Properties, Layout
1872 @subsubsection Layout Inheritance
1873 @cindex Face Properties, inheritance
1874 @cindex Face Properties, layout, inheritance
1875 @cindex Themes, faces, properties, inheritance
1876 @cindex Themes, faces, properties, layout, inheritance
1877 This section is a misnomer. Contrary to highlight properties, there is
1878 @emph{no} inheritance for layout properties across a face tree. In other
1879 words, every missing layout property in a face specification has the
1880 property in question set to its default value.
1882 Again, this design decision has been adopted because it is the most
1883 natural thing to do. If you're not convinced, consider this: when you
1884 specify that the @samp{option} face has a top padding of 0, you mean
1885 that every option should be described on a line of its own. However, you
1886 probably do @emph{not} mean that every individual sub-part of the
1887 option's description (syntax part, usage part @etc{}) should also start
1888 on its own line.
1890 Now that we know all about highlight and layout inheritance, we are able
1891 to explain the face specification shortcut mentioned earlier, when a
1892 face is specified directly by name, without any explicit property
1893 specification:
1895 @verbatim
1896 :face description
1897 @end verbatim
1899 This syntactic shortcut actually lets you specify a face which gets all
1900 default values for layout properties, and inherits all current values
1901 from its super-faces for highlight properties. This is in fact a
1902 shortcut for this:
1904 @verbatim
1905 :face (description)
1906 @end verbatim
1908 This, however, does not explain why you would want to issue such a
1909 specification instead of just not mentioning the face at all. See
1910 @ref{Implicit Faces} for an explanation.
1913 @node Implicit Faces, , Layout, Theme Creation
1914 @subsection Implicit Faces
1915 @cindex Implicit Faces
1916 @cindex Faces, implicit
1917 @cindex Themes, faces, implicit
1918 @cindex Built-in themes, @t{raw}
1919 @cindex Themes, built-in, @t{raw}
1920 In order to fully understand how themes work, we need to tackle one last
1921 aspect of their conception: the case of @emph{implicit faces}. Although
1922 @clon{} itself needs a completely defined face tree to perform output
1923 correctly, a theme file is not required to define all of them (that is
1924 impossible by the way: because of group nesting, a complete theme file
1925 would be infinitely big). In fact, a theme file can be totally empty, in
1926 which case the output will effectively conform to the built-in
1927 @samp{raw} theme. When a face is ``missing'' from a theme, @clon{}
1928 arranges to define it in a sensible way. Such a face is said to be
1929 @emph{implicit}. The exact rules for defining implicit faces is what
1930 this section is all about.
1932 @menu
1933 * Face Tree Reuse::     Substituting previously specified faces
1934 * Sibling Faces::       Substituting built-in faces
1935 @end menu
1937 @node Face Tree Reuse, Sibling Faces, Implicit Faces, Implicit Faces
1938 @subsubsection Face Tree Reuse
1939 @cindex Faces, reuse
1940 @cindex Themes, faces, reuse
1941 Suppose that @clon{} needs to display an option's description, and that
1942 option belongs to a group. The corresponding face in a theme file would
1943 be the following one:
1945 @verbatim
1946 :face (group :face (items :face (option  #| ... |#)))
1947 @end verbatim
1949 This face describes how options belonging to a level 1 group are to be
1950 displayed. As such, it is not applicable to toplevel options. When this
1951 face is missing from the theme file, @clon{} tries to find a @emph{more
1952 general} one. In that particular case, the theme file might define a
1953 ``toplevel'' @samp{option} face like this:
1955 @verbatim
1956 :face (option #| ... |#)
1957 @end verbatim
1959 This face is more general because it lies at the toplevel. As such, it
1960 is considered applicable to toplevel options, but also to options
1961 belonging to groups at any level. In the same vein, specifying an
1962 @samp{option} face within a @samp{group} face implicitly makes it
1963 applicable at any higher group level.
1965 This face reuse mechanism applies to @emph{any} face in a theme; not
1966 only to the ones used in the examples above. For instance, if you decide
1967 that all headers in @clon{}'s output should be displayed in the same
1968 way, you can very well specify a @samp{header} face at the toplevel of a
1969 theme file (although @clon{} never has anything to display in a
1970 @samp{header} face at the toplevel), and this face will be used in
1971 synopsis headers, group headers, fallback headers @etc{}.
1973 @cindex Faces, tree, reuse
1974 @cindex Themes, faces, tree, reuse
1975 Now, I must confess that the face reuse mechanism described above was
1976 over-simplified. What really happens is not exactly face reuse, but
1977 @emph{face tree} reuse. Here is a more complicated example to clarify
1978 things a little.
1980 Suppose @clon{} needs to display the syntax part of an option that
1981 belongs to a level 1 group. The corresponding face in a theme file would
1982 be the following:
1984 @verbatim
1985 :face (group :face (items :face (option :face (syntax #| ... |#))))
1986 @end verbatim
1988 If that face is missing, then @clon{} will in fact attempt to find a
1989 more general one @emph{while preserving as much context as possible}. In
1990 other words, the following specifications will be tried, in that order:
1992 @verbatim
1993 :face (items :face (option :face (syntax #| ... |#)))
1994 :face (option :face (syntax #| ... |#))
1995 :face (syntax #| ... |#)
1996 @end verbatim
1998 I hope this makes sense to you because again, it is the most natural
1999 thing to do. What this roughly means is that when you are looking for a
2000 way to display an option's syntax part, you should reuse a more general
2001 option's syntax face first, and only as a very last resort fall back to
2002 a @samp{syntax} face specification that would be floating around on its
2003 own.
2005 @node Sibling Faces, , Face Tree Reuse, Implicit Faces
2006 @subsubsection Sibling Faces
2007 @cindex Sibling Faces
2008 @cindex Faces, siblings
2009 @cindex Themes, faces, siblings
2010 @cindex Built-in themes, @t{raw}
2011 @cindex Themes, built-in, @t{raw}
2012 Now, what happens when the face you're looking for is not specified
2013 @emph{at all}, not even at a more general level? In such a situation,
2014 @clon{} uses a @emph{sibling}. A sibling face is a face that plays the
2015 same role as the one you're looking for, only it is extracted from the
2016 built-in @samp{raw} theme. The built-in @samp{raw} theme ensures that
2017 every face is defined at least once, so all faces will eventually be
2018 found. When a sibling face is not found in the exact context in which it
2019 is needed (for instance, the @samp{group} face is empty in the
2020 @samp{raw} theme), then the same process of face tree reuse as described
2021 in the previous section occurs on the sibling face tree.
2025 @c ====================================================================
2026 @c Conclusion
2027 @c ====================================================================
2028 @node Conclusion,  Concept Index, Output, Top
2029 @chapter Conclusion
2030 So that's it I guess. Enjoy using clonified applications, don't spend
2031 too much time hacking themes, and please contribute to the @cl{} world
2032 by developing standalone programs with @clon{}. Read @userref{Top} to
2033 learn how to do that.
2035 Hmmm. What kind of conclusion was that@dots{}
2039 @c ====================================================================
2040 @c Concept Index
2041 @c ====================================================================
2042 @node Concept Index, , Conclusion, Top
2043 @unnumbered Concept Index
2045 @printindex cp
2047 @bye
2049 @c  LocalWords:  Clon clon cmdline Clonification tty emph CmdLine clonified SGR
2050 @c  LocalWords:  clonfiscated clonistified clonificated clonificationated samp
2051 @c  LocalWords:  cindex subsubsection pxref Didier Nuker postfix Runtime cth
2052 @c  LocalWords:  cartouche toplevel prepended IEC
2054 @c enduser.texi ends here