Getting Started
- Copy the color-coded folder to a convenient location.
- Load: load-color-coded.lisp
- Open the preference dialog by choosing the Style Prefs ... menu item under the Edit menu.
Click on the *DEFCLASS-STYLE* entry in the scrolling table on the left, and you will see the
display shown below.
- The preference dialog is used to edit style-item-variables. These variables store
the styling specifications for all stylable forms. The style-item-variable *DEFCLASS-STYLE*,
which you just selected, has it's name and the property list specifying its current value displayed at
the top of the dialog. The scrolling Fred view below the specification displays sample code
using the currently selected style options. There is a descriptive blurp in the documentation
window below the scrolling table.
- Choose a larger font size from the font size radio button group. The sample code will be
restyled reflecting the new size.
- Edit the color by clicking on one of the color buttons in the color palette, or by clicking the
edit color button to the right of the palette. The color buttons in the palette are colors
that are currently being used by the variables. The edit color button will pop the color picker
and add a new color to the color palette, unless the new color matches an existing one. Notice
that the currently selected color is underlined. After you edit a color, if the old color is no
longer used by any other style-item-variable, it will be removed from the palette.
- Experiment with various fonts, sizes, styles, colors and case.
Generic Styling
- Click on some of the other style-item-variables in the scrolling table.
- Notice that some of them do not have a unique specification. Instead they use the styles
defined by *generic-def-style*, *generic-def-symbol-style*, or *generic-text-style*. When an
item is using a generic style, all the font related dialog controls will be disabled. You can assign
a generic style to a style-item-variable by clicking the "use generic" button. Conversely, if a
style-item-variable currently has a generic style, you can assign a unique specification by
clicking the "make spec" button. When you click "make spec" all the font related dialog controls
will be enabled.
- The *generic-def-style* variable applies to the names of the definition macros (defclass,
defun, defvar, etc). The *generic-def-symbol-style* variable applies to the symbols defined by
those macros. The *generic-text-style* variable applies to all otherwise unstyled text.
- The generic style option allows you to give most forms one uniform style. You can then define
unique styles where you think it is appropriate. The scrolling table has entries for *generic-def-style*,
*generic-text-style* and *generic-def-symbol-style*.
Additional Preferences
The dialog also allows you to set the values of six other preferences:
I-beam selection
Fred's I-beam is sometimes difficult to see when you use a colored background, depending on the
color you uses (*background-color*). If this happens, you can choose either the white or the
black I-beam option.
Options
These options let you style exported symbols, keywords and :cl functions.
- To style the :cl package, first click the :cl checkbox. Then select *cl-function-style* in the
scrolling table and define the style. Note that unless you check the :cl checkbox, the font spec
controls will be disabled.
- The keyword checkbox lets you give all the symbols in the keyword package a distinctive
style. First click the keyword checkbox. Then select
*keyword-package-style* in the scrolling table and define the style. Note that unless you check
the keyword checkbox, the font spec controls will be disabled. This option also styles
lambda-list-keywords.
- The exported symbols checkbox lets you give all the exported symbols in a package a
distinctive style. First click the exported symbol checkbox. Then select
*exported-symbol-style* in the scrolling table and define the style. Note that unless you check
the exported symbol checkbox, the font spec controls will be disabled. Also note that for this
to work the files being styled have to be loaded, packages defined and symbols exported.
Modes
- When the indentation checkbox is checked, if you use tab key indentation (ed-indent-for-lisp) , the function
will be styled before the indentation is done. First select the entire function. You can do
this by first clicking anywhere inside and then typing control-meta-h. Then press the tab key.
Typically if you are ready to correct indentation, you are also ready to style, so this makes
sense. With this release styling is also bound to ed-indent-sexp. First move to the beginning or
end of the top-level sexp by typing control-meta-e or control-meta-a. Then type control-meta-q
to style and indent.
- When the incremental checkbox is checked, code will be styled as it is typed.
Menu Commands:
Style File
The Style File menu-item under the Edit menu will style the file in the active Fred
window, using the currently selected style settings. If the active window has a selection
the menu-item title changes to
Style Selection, and, predictably, only the selection will be styled.
Style File Vanilla
The Style Vanilla Vanilla menu item will convert the text of a styled file to the style stored in
*vanilla-styling*. This is typically Monaco 9, plain, black, and lower case, but you can configure
that in the usual way. It does not modify capitalization inside comments and strings. This
command has turned out to be more useful than an undo command, since undo only works for
the previous operation, and you may change your mind further down stream. If the active
window has a selection the menu-item title changes to Style Selection Vanilla, and
only the selection will be styled.
Style Folder ...
Choose the Style Folder ... menu item under the Edit menu. This will pop the choose-directory
dialog and style all the files in the folder you select. It will then recursively style all the
sub-folders.
Style Prefs ...
This pops the preference dialog.
Controls:
doc, save as, save, okay, and cancel buttons
Color-coded maintains a style preference file. The file records a "set" which is a collection of
the values for all the style-item-variables. Once you design a set you like, click the save button
and that set will be written to the preference file and loaded the next time you crank it
up. Alternatively, you can click the okay button and the current settings will be used for
styling during the current session, but the settings will not be saved. The cancel button will
nullify any edits you have made to the variables. Note that the cancel button will not nullify a
save of the preference file. Once you write the preference file, the old information is gone. The save as button
will save the current settings as a style set (see below).
The preference file is written here: ~/Library/Preferences/org.clairvaux/color-coded/cc-prefs.
The doc button opens this document.
Style Sets Popup Menu
The style sets popup menu in the upper right of the dialog lets you select and load a file that
defines a set. Color-coded comes with 7 of these files, but you can add your own and modify the sets supplied.
These files are identical in format to the preference file. To add your own or modify and existing set, click the
save as button.
Style sets are written here: ~/Library/Preferences/org.clairvaux/color-Coded/style-sets/.
When you first start using color-coded you might begin by selecting one of the built-in sets and
then modify some of the individual style-item-variables. You can then save this modified
version of the built-in set to your preference file. The other approach is to design a set
completely from scratch, which is described in the next section.
The style sets popup menu also has an entry for "current prefs." This menu item will reload
your current preference file. This is useful when you want to reset you current preference
selections, after having looked at some of the built-in sets.
Creating New Sets
- First define *background-color*.
- Next define styles for *generic-def-style*, *generic-def-symbol-style*, and
*generic-text-style* as described above.
- Then work through the scrolling table of style-item-variables defining unique styles where
you want them, or setting them to use the generic styles.
Styling MCL Source Code
If you routinely poke around in MCL's source code, you might like to style those files:
Choose the Style Folder... menu item under the Edit menu. Navigate to the MCL folder and
select it. MCL looks good with syntax styling.
Usage
If you choose to use color-coded on a regular basis, you should add this line to your init.lisp.
(load "ccl:projects;color-coded;load-color-coded.lisp")
Changing it, of course, to your own path.
Alternatively, you can save an image with the utility loaded. Color-coded-prefs.lisp includes:
(pushnew 'cc::read-prefs-on-startup ccl:*lisp-startup-functions*)
That will load your preference file, when you crank it up.
Color-Coded does a good job of keeping the styling correct even when you are doing
arbitrary edits on preexisting code. But sometimes the styling will be wrong. This
can happen, for example, when you type in bogus syntax. If this happens, select
the entire form with control-meta-h and press the tab key. This will correct
indentation and restyle (the indentation styling mode check box needs to be
checked). You can also move to the beginning or end of the top-level sexp by
typing control-meta-e or control-meta-a, and then type control-meta-q to
style and indent.
The preference dialog is designed to be used with Terge Norderhaug's
modern-mcl.lisp. It will work okay without modern-mcl,
but will not look as snazzy (Can preference dialogs look snazzy?).
MCL has a preference, *arglist-on-space* which by default is t. Set this to nil when styling incrementally,
otherwise there will be a delay when styling function names. You can still get the
arglist of a function by typing contol-x, control-a.
Well, those are the basics. To extend the utility with your own homegrown macros, read the
next page. For miscellaneous info, see the "details and acknowledgements" page.