From 2c542682289268e31231766ea29d1a22bafa54d4 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 28 Apr 2010 07:24:39 -0600 Subject: [PATCH] move pref file to .rtkd extension, and automatically read from the old PLT Scheme path if the new one doesn't exist --- collects/racket/file.rkt | 20 +++++++++++-- .../scribblings/reference/filesystem.scrbl | 28 ++++++++++++++----- src/gracket/grmain.cxx | 4 +-- src/racket/main.c | 4 +-- src/racket/src/file.c | 8 +++--- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/collects/racket/file.rkt b/collects/racket/file.rkt index 522b93f167..a1430bd8f4 100644 --- a/collects/racket/file.rkt +++ b/collects/racket/file.rkt @@ -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)))]) diff --git a/collects/scribblings/reference/filesystem.scrbl b/collects/scribblings/reference/filesystem.scrbl index 42056c0fc8..9fae770b9a 100644 --- a/collects/scribblings/reference/filesystem.scrbl +++ b/collects/scribblings/reference/filesystem.scrbl @@ -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?] diff --git a/src/gracket/grmain.cxx b/src/gracket/grmain.cxx index 28d07047b2..0fa365d301 100644 --- a/src/gracket/grmain.cxx +++ b/src/gracket/grmain.cxx @@ -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 diff --git a/src/racket/main.c b/src/racket/main.c index f02e098288..3a3213b032 100644 --- a/src/racket/main.c +++ b/src/racket/main.c @@ -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 diff --git a/src/racket/src/file.c b/src/racket/src/file.c index 704897f40c..17ad1760ec 100644 --- a/src/racket/src/file.c +++ b/src/racket/src/file.c @@ -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