From aefa3702ed66ba8445db5f87b2e8a84bac77cfb3 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Sun, 12 Mar 2017 10:11:36 -0700 Subject: [PATCH] Add a global edit procedure that autoloads Edwin. --- src/edwin/editor.scm | 9 --------- src/edwin/edwin.pkg | 5 +---- src/runtime/global.scm | 26 ++++++++++++++++++++++++++ src/runtime/load.scm | 15 ++------------- src/runtime/runtime.pkg | 3 +++ 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/edwin/editor.scm b/src/edwin/editor.scm index e74655e9c..da0db7036 100644 --- a/src/edwin/editor.scm +++ b/src/edwin/editor.scm @@ -87,15 +87,6 @@ USA. ,@operations)) message)))))))) -(define (edwin . args) (apply edit args)) -(simple-command-line-parser "edit" edit - "Causes Edwin to start immediately after Scheme.") - -(define (spawn-edwin . args) - (let ((thread (create-thread #f (lambda () (apply edwin args))))) - (detach-thread thread) - thread)) - (define edwin-editor #f) (define editor-abort) (define current-editor) diff --git a/src/edwin/edwin.pkg b/src/edwin/edwin.pkg index c67639ac6..acb084f6c 100644 --- a/src/edwin/edwin.pkg +++ b/src/edwin/edwin.pkg @@ -135,13 +135,10 @@ USA. (export () create-editor create-editor-args - edit - edwin inhibit-editor-init-file? reset-editor reset-editor-windows - (save-editor-files debug-save-files) - spawn-edwin) + (save-editor-files debug-save-files)) (export (edwin class-macros) class-instance-transforms)) diff --git a/src/runtime/global.scm b/src/runtime/global.scm index bf8adf72e..e25fc767a 100644 --- a/src/runtime/global.scm +++ b/src/runtime/global.scm @@ -152,6 +152,32 @@ USA. (if (or (default-object? max) (not max)) (with-output-to-string (lambda () (write object))) (with-output-to-truncated-string max (lambda () (write object))))) + +(define (edit . args) + (let ((env (let ((package (name->package '(edwin)))) + (and package (package/environment package))))) + (if env + (apply (environment-lookup end 'edit) args) + (begin + (with-notification + (lambda (port) (display "Loading Edwin" port)) + (lambda () + (parameterize* + (list (cons param:suppress-loading-message? #t)) + (lambda () + (load-option 'EDWIN) + (if (let ((DISPLAY (get-environment-variable "DISPLAY"))) + (and (string? DISPLAY) + (not (string-null? DISPLAY)))) + (ignore-errors (lambda () (load-option 'x11-screen)))))))) + (apply (environment-lookup (->environment '(edwin)) 'edit) args))))) + +(define edwin edit) + +(define (spawn-edwin . args) + (let ((thread (create-thread #f (lambda () (apply edwin args))))) + (detach-thread thread) + thread)) (define (pa procedure) (guarantee procedure? procedure 'PA) diff --git a/src/runtime/load.scm b/src/runtime/load.scm index a06749643..d2475b5c6 100644 --- a/src/runtime/load.scm +++ b/src/runtime/load.scm @@ -714,19 +714,8 @@ ADDITIONAL OPTIONS supported by this band:\n") environment repl))))) "Evaluates the argument expressions as if in the REPL.") - (simple-command-line-parser "edit" - (named-lambda (command-line-edit) - (with-notification (lambda (port) (display "Loading Edwin" port)) - (lambda () - (parameterize* (list (cons param:suppress-loading-message? #t)) - (lambda () - (load-option 'EDWIN) - (if (let ((DISPLAY (get-environment-variable "DISPLAY"))) - (and (string? DISPLAY) - (not (string-null? DISPLAY)))) - (ignore-errors (lambda () (load-option 'x11-screen)))))))) - ((environment-lookup #f 'edit))) - "Causes Edwin to start immediately after Scheme.") + (simple-command-line-parser "edit" edit + "Causes Edwin to start immediately after Scheme.") (simple-command-line-parser "help" show-command-line-options #f) (simple-command-line-parser "version" (lambda () (%exit 0)) #f) (set-command-line-parser! diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg index 0b914f42e..fa194bab4 100644 --- a/src/runtime/runtime.pkg +++ b/src/runtime/runtime.pkg @@ -444,6 +444,8 @@ USA. constant-procedure default/exit default/quit + edit + edwin environment-link-name ephemeron-broken? ephemeron-datum @@ -513,6 +515,7 @@ USA. set-interrupt-enables! show-time simple-top-level-environment + spawn-edwin system-hunk3-cons system-hunk3-cxr0 system-hunk3-cxr1 -- 2.25.1