Next: , Previous: , Up: Hemlock Variables   [Contents][Index]


6.2 Variable Functions

In the following descriptions name is the symbol name of the variable.

Function: defhvar string-name documentation &key :mode :buffer :hooks :value

This function defines a Hemlock variable. Functions that take a variable name signal an error when the variable is undefined.

string-name

The string name of the variable to define.

documentation

The documentation string for the variable.

:mode
:buffer

If buffer is supplied, the variable is local to that buffer. If mode is supplied, it is local to that mode. If neither is supplied, it is global.

:value

This is the initial value for the variable, which defaults to nil.

:hooks

This is the initial list of functions to call when someone sets the variable’s value. These functions execute before Hemlock establishes the new value. See variable-value for the arguments passed to the hook functions.

If a variable with the same name already exists in the same place, then defhvar sets its hooks and value from hooks and value if the user supplies these keywords.

Function: variable-value name &optional kind where

This function returns the value of a Hemlock variable in some place. The following values for kind are defined:

:current

Return the value present in the current environment, taking into consideration any mode or buffer local variables. This is the default.

:global

Return the global value.

:mode

Return the value in the mode named where.

:buffer

Return the value in the buffer where.

When set with setf, Hemlock sets the value of the specified variable and invokes the functions in its hook list with name, kind, where, and the new value.

Function: variable-documentation name &optional kind where
Function: variable-hooks name &optional kind where
Function: variable-name name &optional kind where

These function return the documentation, hooks and string name of a Hemlock variable. The kind and where arguments are the same as for variable-value. The documentation and hook list may be set using setf.

Function: string-to-variable string

This function converts a string into the corresponding variable symbol name. String need not be the name of an actual Hemlock variable.

Macro: Macro value name
Macro: Macro setv name new-value

These macros get and set the current value of the Hemlock variable name. Name is not evaluated. There is a setf form for value.

Macro: hlet ({(var value)}*) {form}*

This macro is very similar to let in effect; within its scope each of the Hemlock variables var have the respective values, but after the scope is exited by any means the binding is removed. This does not cause any hooks to be invoked. The value of the last form is returned.

Function: hemlock-bound-p name &optional kind where

Returns t if name is defined as a Hemlock variable in the place specified by kind and where, or nil otherwise.

Hemlock Variable: Delete Variable Hook
Function: delete-variable name &optional kind where

delete-variable makes the Hemlock variable name no longer defined in the specified place. Kind and where have the same meanings as they do for variable-value, except that :current is not available, and the default for kind is :global

An error will be signaled if no such variable exists. The hook, Delete Variable Hook is invoked with the same arguments before the variable is deleted.


Next: Hooks, Previous: Variable Names, Up: Hemlock Variables   [Contents][Index]