move pref file to .rtkd extension, and automatically read from the old PLT Scheme path if the new one doesn't exist

This commit is contained in:
Matthew Flatt 2010-04-28 07:24:39 -06:00
parent de863643d5
commit 2c54268228
5 changed files with 46 additions and 18 deletions

View File

@ -149,9 +149,23 @@
;; race condition, but something has gone really wrong
;; if the file disappears.
f
;; Error here bails out through above `with-handlers'
(build-path (collection-path "defaults")
"plt-prefs.ss"))))]
;; Look for old PLT Scheme pref file:
(let ([alt-f (case (system-type)
[(windows)
(build-path (find-system-path 'pref-dir)
'up "PLT Scheme" "plt-prefs.ss")]
[(macosx)
(build-path (find-system-path 'pref-dir)
"org.plt-scheme.prefs.ss")]
[(unix)
(expand-user-path "~/.plt-scheme/plt-prefs.ss")])])
(if (file-exists? alt-f)
alt-f
;; Last chance: check for a "defaults" collection:
;; (error here in case there's no "defaults"
;; bails out through above `with-handlers')
(build-path (collection-path "defaults")
"racket-prefs.rktd"))))))]
[prefs (with-pref-params
(lambda ()
(with-input-from-file pref-file read)))])

View File

@ -49,8 +49,8 @@ by @racket[kind], which must be one of the following:
@item{@indexed-racket['pref-file] --- a file that contains a
symbol-keyed association list of preference values. The file's
directory path always matches the result returned for
@racket['pref-dir]. The file name is @filepath{racket-prefs.rkt} under Unix
and Windows, and it is @filepath{org.racket-lang.prefs.rkt} under Mac OS
@racket['pref-dir]. The file name is @filepath{racket-prefs.rktd} under Unix
and Windows, and it is @filepath{org.racket-lang.prefs.rktd} under Mac OS
X. The file's directory might not exist. See also
@racket[get-preference].}
@ -76,7 +76,7 @@ by @racket[kind], which must be one of the following:
@item{@|AllUnix|: @indexed-file{.racketrc}}
@item{Windows: @indexed-file{racketrc.rkt}}
@item{Windows: @indexed-file{racketrc.rkts}}
]}
@ -845,9 +845,10 @@ Extracts a preference value from the file designated by
@racket[(find-system-path 'pref-file)], or by @racket[filename] if it
is provided and is not @racket[#f]. In the former case, if the
preference file doesn't exist, @racket[get-preferences] attempts to
read a @filepath{racket-prefs.rkt} file in the @filepath{defaults}
collection, instead. If neither file exists, the preference set is
empty.
read an @elemref["old-prefs"]{old preferences file}, and then a
@filepath{racket-prefs.rktd} file in the @filepath{defaults}
collection, instead. If none of those files exists, the preference set
is empty.
The preference file should contain a symbol-keyed association list
(written to the file with the default parameter settings). Keys
@ -869,9 +870,22 @@ same as the last time the file was read. Otherwise, the file is
re-consulted.
See also @racket[put-preferences]. For a more elaborate preference
system, see @racket[preferences:get].}
system, see @racket[preferences:get].
@elemtag["old-prefs"]{@bold{Old preferences files}}: When a
@racket[filename] is not provided and the file indicated by
@racket[(find-system-path 'pref-file)] does not exist, the following
paths are checked for compatibility with old versions of Racket:
@itemlist[
@item{Windows: @racket[(build-path (find-system-path 'pref-dir) 'up "PLT Scheme" "plt-prefs.ss")]}
@item{Mac OS X: @racket[(build-path (find-system-path 'pref-dir) "org.plt-scheme.prefs.ss")]}
@item{Unix: @racket[(expand-user-path "~/.plt-scheme/plt-prefs.ss")]}
]}
@defproc[(put-preferences [names (listof symbol?)]
[vals list?]

View File

@ -101,12 +101,12 @@ extern "C" Scheme_Object *scheme_initialize(Scheme_Env *env);
# define INIT_FILENAME "~/.gracketrc"
#else
# ifdef wx_msw
# define INIT_FILENAME "%%HOMEDIRVE%%\\%%HOMEPATH%%\\gracketrc"
# define INIT_FILENAME "%%HOMEDIRVE%%\\%%HOMEPATH%%\\gracketrc.rkts"
# else
# ifdef OS_X
# define INIT_FILENAME "~/.gracketrc"
# else
# define INIT_FILENAME "PREFERENCES:gracketrc"
# define INIT_FILENAME "PREFERENCES:gracketrc.rkts"
# endif
# endif
#endif

View File

@ -139,9 +139,9 @@ extern Scheme_Object *scheme_initialize(Scheme_Env *env);
# define INIT_FILENAME "~/.racketrc"
#else
# ifdef DOS_FILE_SYSTEM
# define INIT_FILENAME "%%HOMEDRIVE%%\\%%HOMEPATH%%\\racketrc"
# define INIT_FILENAME "%%HOMEDRIVE%%\\%%HOMEPATH%%\\racketrc.rkts"
# else
# define INIT_FILENAME "PREFERENCES:racketrc"
# define INIT_FILENAME "PREFERENCES:racketrc.rkts"
# endif
#endif
#define GET_INIT_FILENAME get_init_filename

View File

@ -5839,9 +5839,9 @@ find_system_path(int argc, Scheme_Object **argv)
return append_path(home, scheme_make_path("/.racketrc" + ends_in_slash));
if (which == id_pref_file) {
#if defined(OS_X) && !defined(XONX)
return append_path(home, scheme_make_path("/org.racket-lang.prefs" + ends_in_slash));
return append_path(home, scheme_make_path("/org.racket-lang.prefs.rktd" + ends_in_slash));
#else
return append_path(home, scheme_make_path("/racket-prefs" + ends_in_slash));
return append_path(home, scheme_make_path("/racket-prefs.rktd" + ends_in_slash));
#endif
}
}
@ -5982,9 +5982,9 @@ find_system_path(int argc, Scheme_Object **argv)
}
if (which == id_init_file)
return append_path(home, scheme_make_path("\\racketrc" + ends_in_slash));
return append_path(home, scheme_make_path("\\racketrc.rkts" + ends_in_slash));
if (which == id_pref_file)
return append_path(home, scheme_make_path("\\racket-prefs" + ends_in_slash));
return append_path(home, scheme_make_path("\\racket-prefs.rktd" + ends_in_slash));
return home;
}
#endif