All Manuals > LispWorks® User Guide and Reference Manual > 38 The LISPWORKS Package

user-preference Accessor

Summary

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

Package

lispworks

Signatures

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

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

Arguments
path
A string or a list of strings.
value-name
A string.
product
A keyword.
value
A Lisp object.
Values
value
A Lisp object.
valuep
A boolean.
Description

The accessor 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 non-Windows systems.

Notes
  1. 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.
  2. While product can in principle be any Lisp object, values of product are compared by eq, so you should use keywords.
  3. The CAPI provides a way to store window geometry - see the reference entry for capi:top-level-interface-save-geometry-p in the CAPI User Guide and Reference Manual.
Examples

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

(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 path:

(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 - 01 Dec 2021 19:30:41