fixed debug again and added indents prefs

original commit: 61339e5b474214c5275ca1ae1b44f4ef81d10c51
This commit is contained in:
Robby Findler 1996-06-21 16:12:42 +00:00
parent 358990f590
commit f841e99836

View File

@ -24,13 +24,26 @@
(define-struct un/marshall (marshall unmarshall))
(define-struct marshalled (data))
(define get-preference-box
(lambda (p)
(hash-table-get preferences p
(let ([ans (hash-table-get preferences p
(lambda ()
(raise (mred:exn:make-exn:unknown-preference
(format "unknown preference: ~a" p)
((debug-info-handler))))))))
((debug-info-handler))))))])
(if (marshalled? ans)
(let* ([marshalled (marshalled-data ans)]
[unmarshalled
((un/marshall-unmarshall
(hash-table-get marshall-unmarshall p
(lambda () mzlib:function:identity)))
marshalled)]
[boxed (box unmarshalled)])
(hash-table-put! preferences p boxed)
boxed)
ans))))
(define get-preference (mzlib:function:compose unbox get-preference-box))
@ -65,8 +78,8 @@
(for-each (lambda (x) (apply set-preference x))
defaults)))
(define save-user-preferences
(lambda ()
(let ([marshall-pref
(lambda (p boxed-value)
(let* ([value (unbox boxed-value)]
@ -78,28 +91,31 @@
(k value))))
value))])
(list p marshalled)))])
(lambda ()
(call-with-output-file preferences-filename
(lambda (p)
(write (hash-table-map preferences marshall-pref) p))
'replace))))
(write (hash-table-map preferences marshall-pref) p)
'replace)))))
(define read-user-preferences
(lambda ()
(let ([unmarshall-update
(let ([unmarshall-pref
(lambda (input)
(let* ([p (mzlib:function:first input)]
[marshalled (mzlib:function:second input)]
[unmarshalled
(let ([p (mzlib:function:first input)]
[marshalled (mzlib:function:second input)])
(let/ec k
((un/marshall-unmarshall
(hash-table-get marshall-unmarshall p
(lambda () (k marshalled))))
marshalled))])
(set-preference p unmarshalled)))])
(let* ([not-in-table
(lambda ()
(k (hash-table-put! preferences p (make-marshalled marshalled))))]
[ht-pref (hash-table-get preferences p not-in-table)]
[unmarshall (hash-table-get marshall-unmarshall p (lambda () mzlib:function:identity))])
(if (box? ht-pref)
(set-box! ht-pref (unmarshall marshalled))
(set-marshalled-data! marshalled))))))])
(lambda ()
(when (file-exists? preferences-filename)
(let ([input (call-with-input-file preferences-filename read)])
(when (list? input)
(for-each unmarshall-update input)))))))
(for-each unmarshall-pref input)))))))
(define preferences-dialog
(lambda ()