27 Preferences, Textual
(require framework/preferences) | package: gui-lib |
procedure
(preferences:get symbol) → any/c
symbol : symbol?
procedure
(preferences:set symbol value) → void?
symbol : symbol? value : any/c
preferences:set immediately writes the preference value to disk. It raises an exception matching exn:unknown-preference? if the preference’s default has not been set.
procedure
(preferences:add-callback p f [weak?]) → (-> void?)
p : symbol? f : (-> symbol? any/c any) weak? : boolean? = #f
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.
procedure
(preferences:set-default symbol value test [ #:aliases aliases #:rewrite-aliases rewrite-aliases]) → void? symbol : symbol? value : any/c test : (any/c . -> . any) aliases : (listof symbol?) = '()
rewrite-aliases : (listof (-> any/c any)) = (map (lambda (x) values) aliases)
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, 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.
procedure
(preferences:default-set? pref) → boolean?
pref : symbol?
procedure
(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.
preferences:set-un/marshall must be called before calling preferences:get,preferences:set.
procedure
procedure
(preferences:register-save-callback callback) → symbol?
callback : (-> boolean? any)
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.
procedure
key : symbol?
procedure
(exn:make-unknown-preference message continuation-marks) → exn:unknown-preference? message : string? continuation-marks : continuation-mark-set?
procedure
(exn:unknown-preference? exn) → boolean?
exn : any/c
parameter
→ ((listof symbol?) (listof any/c) . -> . any) (preferences:low-level-put-preferences put-preferences) → void? put-preferences : ((listof symbol?) (listof any/c) . -> . any)
parameter
→ (->* (symbol?) [(-> any)] any) (preferences:low-level-get-preference get-preference) → void? get-preference : (->* (symbol?) [(-> any)] any)
procedure
(preferences:snapshot? arg) → boolean?
arg : any/c
procedure
(preferences:restore-prefs-snapshot snapshot) → void?
snapshot : preferences:snapshot?
procedure
See also preferences:restore-prefs-snapshot.