LispWorks User Guide and Reference Manual > 34 The LISPWORKS Package

NextPrevUpTopContentsIndex

user-preference

Function
Summary

Gets or sets a persistent value in the user's registry.

Package

lispworks

Signature

user-preference path value-name &key product => value , valuep

Signature

(setf user-preference) value path value-name &key product => value

Arguments

path

A string or a list of strings.

value-name

A string.

product

A keyword.

Values

value

A Lisp object.

valuep

A boolean.

Description

The function user-preference reads the value of the registry entry value-name under path under the registry path defined for product by (setf product-registry-path ) . If the registry entry was found a second value t is returned. If the registry entry was not found, then value is nil .

The function (setf user-preference) sets the value of that registry entry to value .

If path is a list of strings, then it is interpreted like the directory component of a pathname. If path is a string, then any directory separators should be appropriate for the platform - that is, use backslash on Windows, and forward slash on Unix/Linux/Mac OS X systems.

Note: when value is a string, user-preference stores a print-escaped string in the registry and reads it back with read-from-string . Therefore it may not work with string values stored by other software.

Note: while product can in principle be any Lisp object, values of product are compared by eq , so you should use keywords.

Note: The CAPI provides a way to store window geometry - see the entry for capi:top-level-interface-save-geometry-p in the LispWorks CAPI Reference Manual .

Example

This example is on Microsoft Windows. Note the use of backslashes as directory separators in the path argument:

(setf (user-preference "My Stuff\\FAQ"
                       "Ultimate Answer" 
                       :product :deep-thought) 
      42)
=>
42

This is equivalent to the previous example, and is portable because we avoid the explicit directory separators in the path argument:

(setf (user-preference (list "My Stuff" "FAQ")
                       "Ultimate Answer"
                       :product :deep-thought) 
      42)
=>
42

We can retrieve values on Windows like this:

(user-preference "My Stuff\\FAQ"
                 "Ultimate Answer"
                 :product :deep-thought)
=>
42
t

We can retrieve values on any platform like this:

(user-preference (list "My Stuff" "FAQ")
                 "Ultimate Question"
                 :product :deep-thought)
=>
nil
nil
See also

copy-preferences-from-older-version
product-registry-path


LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex