|(require framework/preferences)||package: gui-lib|
Added in version 1.18 of package gui-lib.
If weak? is true, the preferences system will only hold on to the callback weakly.
The callbacks will be called in the order in which they were added.
If you are adding a callback for a preference that requires marshalling and unmarshalling, you must set the marshalling and unmarshalling functions by calling preferences:set-un/marshall before adding a callback.
If you use preferences:set-un/marshall, you must call this function before calling it.
This sets the default value of the preference symbol to value. If the user has chosen a different setting, (reflected via a call to preferences:set, possibly in a different run of your program), the user’s setting will take precedence over the default value.
The test argument is used as a safeguard. That function is called to determine if a preference read in from a file is a valid preference. If test returns #t, then the preference is treated as valid. If test returns #f then the default is used.
The aliases and rewrite-aliases arguments aids in renaming preferences. If aliases is present, it is expected to be a list of symbols that correspond to old versions of the preferences. It defaults to '(). If rewrite-aliases is present, it is used to adjust the old values of the preferences when they are present in the saved file.
Changed in version 1.23 of package gui-lib: Allow preferences:set-default to be called even after a snapshot has been grabbed.
(preferences:set-un/marshall symbol marshall unmarshall) → void? symbol : symbol? marshall : (any/c . -> . printable/c) unmarshall : (printable/c . -> . any/c)
If the unmarshalling function returns a value that does not meet the guard passed to preferences:set-default for this preference, the default value is used.
The marshall function might be called with any value returned from read and it must not raise an error (although it can return arbitrary results if it gets bad input). This might happen when the preferences file becomes corrupted, or is edited by hand.
The callback occurs on whichever thread happened to call preferences:set.
Pre- and post-write notifications are not necessarily paired; unregistration may cancel the post-write notification before it occurs.
(exn:make-unknown-preference message continuation-marks) → exn:unknown-preference? message : string? continuation-marks : continuation-mark-set?
See also preferences:restore-prefs-snapshot.