LispWorks Editor User Guide > 6 Advanced Features > 6.3 Programming the editor

NextPrevUpTopContentsIndex

6.3.14 Variables

editor:define-editor-variable

Function

editor:define-editor-variable name value &optional documentation

Defines an editor variable.

name

Symbol naming the variable.

value

The value to assign to the variable.

mode

A string naming a mode.

documentation

A documentation string.

The macro editor:define-editor-variable defines a global editor variable. There is only one global value, so repeated uses of editor:define-editor-variable overwrite each other.

editor:define-editor-variable gives a readable value of defining a variable, and is recognized by the LispWorks source code location system. However variables can also be defined dynamically by calling (setf editor:variable-value) . Variable values may be accessed by editor:variable-value.

A variable has only one string of documentation associated with it. editor:variable-value overwrites the existing documentation string, if there is any. You can see the documentation by the command Describe Editor Variable. It can can be accessed programmatically by editor:editor-variable-documentation.

Note: for backwards compatibility name can also be a string, which is converted to a symbol by uppercasing, replacing #\Space by #\- , and interning in the EDITOR package. This may lead to clashes and so you should use a symbol for name , not a string.

editor:define-editor-mode-variable

Function

editor:define-editor-mode-variable name mode value &optional documentation

Defines an editor variable in the specified mode.

mode

A string naming a mode.

name, value

As for editor:define-editor-variable.

documentation

As for editor:define-editor-variable, except that editor:define-editor-mode-variable installs the documentation only if the editor variable does not already have any documentation.

editor:define-editor-mode-variable defines a variable in the specified mode. There is one value per variable per mode.

editor:define-editor-mode-variable gives a readable value of defining a variable in a mode, and is recognized by the LispWorks source code location system. However mode variables can also be defined dynamically by calling (setf editor:variable-value) . Mode variable values may be accessed by editor:variable-value.

editor:editor-variable-documentation

Function

editor:editor-variable-documentation editor-variable-name

editor-variable-name

A symbol naming an editor variable.

Returns the documentation associated with the editor variable, if any.

Note: For backwards compatibility a string editor-variable-name is also accepted, as described for editor:define-editor-variable.

editor:variable-value

Function

editor:variable-value name &optional kind where

Returns the value of the editor variable name , where name is a symbol. An error is signalled if the variable is undefined. The argument kind can take the value :current , :buffer , :global or :mode . The default value of kind is :current .

When kind is :current the argument where should be nil (the default, meaning the current buffer) or an editor buffer object or the name of a buffer. The variable value for the specified buffer is returned or (if there is no current buffer) then the global variable value is returned.

kind can also be :buffer , and then buffer should be an editor buffer object.

For example, the code given below will, by default, return the value :ask-user .

(editor:variable-value 
  'editor:add-newline-at-eof-on-writing-file)

The value of variables may also be altered using this function. For example, the code given below will allow buffers to be saved to file without any prompt for a missing newline.

(setf
   (editor:variable-value 
      'editor:add-newline-at-eof-on-writing-file)
    nil)

editor:variable-value-if-bound

Function

editor:variable-value-if-bound name &optional kind where

Returns the value of the variable name . If the variable is not bound, nil is returned. The arguments are as for editor:variable-value.

editor:buffer-value

Function

editor:buffer-value buffer name &optional errorp

Accesses the value of the editor variable name in the buffer specified by buffer .

name should be a symbol and buffer should be a point object or a buffer object.

If the editor variable is undefined and errorp is true, an error is signalled. If the variable is undefined and errorp is false, nil is returned. The default value of errorp is nil .


LispWorks Editor User Guide (Macintosh version) - 22 Dec 2009

NextPrevUpTopContentsIndex