(define with-values call-with-values)
(define (write-to-string object #!optional max)
- (if (or (default-object? max) (not max))
- (with-output-to-string (lambda () (write object)))
- (with-output-to-truncated-string max (lambda () (write object)))))
+ ((if (or (default-object? max) (not max))
+ call-with-output-string
+ call-with-truncated-output-string)
+ (lambda (port) (write object port))))
+
+(define (edit . args)
+ (let ((env (let ((package (name->package '(edwin))))
+ (and package (package/environment package)))))
+ (if env
+ (apply (environment-lookup env '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))
\f
(define (pa procedure)
(guarantee procedure? procedure 'PA)