Start up xrepl when repl is loaded.

This commit is contained in:
Leif Andersen 2016-07-22 14:12:04 -04:00
parent bd1ceb21d6
commit 314485edfb
4 changed files with 61 additions and 5 deletions

View File

@ -12,8 +12,3 @@
(provide (all-from-out racket
racket/enter
racket/help))
;; Set the default replt to XREPL
(when (collection-file-path "main.rkt" "xrepl"
#:fail (lambda _ #f))
(dynamic-require 'xrepl #f))

View File

@ -20,6 +20,7 @@ static void pre_filter_cmdline_arguments(int *argc, char ***argv);
#endif
struct Scheme_Env;
static char *get_gr_config_init_filename(struct Scheme_Env *env);
static char *get_gr_init_filename(struct Scheme_Env *env);
#ifdef wx_xt
@ -36,6 +37,7 @@ static void pre_filter_cmdline_arguments(int *argc, char ***argv);
#define WINDOWS_INIT_FILENAME "%%HOMEDIRVE%%\\%%HOMEPATH%%\\gracketrc.rktl"
#define MACOS9_INIT_FILENAME "PREFERENCES:gracketrc.rktl"
#define GET_INIT_FILENAME get_gr_init_filename
#define GET_CONFIG_INIT_FILENAME get_gr_config_init_filename
#if WIN32
# define NEED_CONSOLE_PRINTF
# define DEFER_EXPLICIT_EXIT
@ -63,6 +65,29 @@ static void pre_filter_cmdline_arguments(int *argc, char ***argv);
# include "../racket/main.c"
static char *get_gr_config_init_filename(Scheme_Env *env)
{
char *s, *s2;
int len, i;
s = get_config_init_filename(env);
if (s) {
len = strlen(s);
for (i = len - 8; i; i--) {
if (!strncmp(s XFORM_OK_PLUS i, "racketrc", 8)) {
s2 = (char *)malloc(len + 2);
memcpy(s2, s, i);
memcpy(s2 + i + 1, s + i, len - i + 1);
s2[i] = 'g';
s = s2;
break;
}
}
}
return s;
}
static char *get_gr_init_filename(Scheme_Env *env)
{
char *s, *s2;

View File

@ -670,6 +670,15 @@ static int finish_cmd_line_run(FinishArgs *fa, Repl_Proc repl)
#ifndef DONT_LOAD_INIT_FILE
if (fa->a->use_repl && !fa->a->no_init_file) {
char *filename;
filename = GET_CONFIG_INIT_FILENAME(fa->global_env);
if (filename) {
filename = scheme_expand_filename(filename, -1, "startup", NULL, SCHEME_GUARD_FILE_EXISTS);
if (scheme_file_exists(filename)) {
scheme_load(filename);
}
}
filename = GET_INIT_FILENAME(fa->global_env);
if (filename) {
filename = scheme_expand_filename(filename, -1, "startup", NULL, SCHEME_GUARD_FILE_EXISTS);

View File

@ -97,6 +97,32 @@ extern BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved);
/*========================================================================*/
#ifndef DONT_LOAD_INIT_FILE
static char * get_config_init_filename(Scheme_Env *env)
{
Scheme_Object *f, *a[2];
Scheme_Thread * volatile p;
mz_jmp_buf * volatile save, newbuf;
p = scheme_get_current_thread();
save = p->error_buf;
p->error_buf = &newbuf;
if(!scheme_setjmp(newbuf)) {
f = scheme_builtin_value("find-main-config");
a[0] = _scheme_apply(f, 0, NULL);
a[1] = scheme_make_path("racketrc");
f = scheme_builtin_value("build-path");
f = _scheme_apply(f, 2, a);
if (SCHEME_PATHP(f)) {
p->error_buf = save;
return SCHEME_PATH_VAL(f);
}
}
p->error_buf = save;
return NULL;
}
static char *get_init_filename(Scheme_Env *env)
{
Scheme_Object *f;
@ -136,6 +162,7 @@ extern Scheme_Object *scheme_initialize(Scheme_Env *env);
# define UNIX_INIT_FILENAME "~/.racketrc"
# define WINDOWS_INIT_FILENAME "%%HOMEDIRVE%%\\%%HOMEPATH%%\\racketrc.rktl"
# define MACOS9_INIT_FILENAME "PREFERENCES:racketrc.rktl"
# define GET_CONFIG_INIT_FILENAME get_config_init_filename
# define GET_INIT_FILENAME get_init_filename
# define PRINTF printf
# define PROGRAM "Racket"