Styles

Neomacs manages a collection of styles named by symbols. A style is either a mixin defined with defstyle or a style sheet defined with defsheet. A mixin specify a collection of CSS attributes, and a style sheet map CSS selectors to CSS attributes. Styles can inherit from each other. A buffer can include a list of style sheets (via buffer's styles slot), which are compiled to CSS and injected into the renderer. Neomacs automatically updates affected CSS if any style is changed because of redefinition or set-style.

Format of mixin style (defstyle) spec: ({block | :key value}*), where each block has the format (selector {block | :key value}*)

Format of sheet style (defsheet) spec: (block*)

Above :key's are either CSS attribute names, or :inherit, in which case value should name a style which would be expanded in place.

Macro: defstyle (symbol spec &optional doc)
Define a style named by SYMBOL.
This also exports SYMBOL from current package.
Macro: defsheet (symbol spec &optional doc)
Define a style sheet named by SYMBOL.
This also exports SYMBOL from current package.
Variable: *styles*
List of all known styles.
Function: set-style (&rest bindings)
Set styles or style sheets according to BINDINGS.
BINDINGS should be of the form {SYMBOL SPEC}*, and style or style sheet named by each SYMBOL is set to SPEC.
Example: (set-style 'default '(:font-family "sans-serif") 'bold '(:font-weight 900))
SYMBOL is allowed to take some special value:
:native-theme -- SPEC should be one of "system","dark" and "light". This sets the color theme used by the renderer.
Function: css-cell (symbol)
Return the cell that stores the compiled CSS of the style sheet named by SYMBOL.
Can be cell-refed to get the up-to-date CSS string for the style named by SYMBOL.

Mode style sheets

If a style with the same name as a mode is present, enabling this mode will automatically load it into current buffer (therefore it should always be a style sheet rather than a mixin). This style sheet is intended for the mode to define styles for nodes it uses, and is therefore not removed when the mode is disabled, to avoid repeated loading in case the mode is enabled again later.

Sometimes you might want to use mode style sheets to modify appearance of a buffer, in which case you should add a disable-aux method to remove such style sheet when the mode is disabled.

Mounting assets directories

The renderer processes don't have direct access to your file system. To use local assets in the renderer (in HTML, CSS, JavaScript, etc), mount them under the neomacs protocol scheme.

Function: mount-asset (host path)
Mount files under PATH to neomacs://HOST/.
PATH should be an absolute directory pathname (ending with slash).

By default, neomacs://sys/ is mounted to assets that come with Neomacs and neomacs://user/ is mounted to (uiop:xdg-config-home "neomacs/assets/") (usually located at ~/.config/neomacs/assets/ on Unix-like systems). For example, neomacs://user/1.png would access ~/.config/neomacs/assets/1.png. neomacs://contents/ is reserved for internal use (currently, file-mode use it to serve temporarily generated HTML).

Themes

Command: apply-theme (theme)
Apply THEME.
Macro: define-theme (name doc &body bindings)
Define a theme with NAME.
BINDINGS are passed as arguments to set-style to apply the theme, except the following special kinds of bindings:
:inherit PARENT: PARENT is a symbol which names another theme. Styles not defined in this theme are inherited from PARENT.
Variable: *themes*
List of all known themes