Created
October 7, 2013 14:52
-
-
Save rmloveland/6869301 to your computer and use it in GitHub Desktop.
Apply this patch to src/edwin/editor.scm so that you can open Edwin directly on files from a shell script, e.g., `$ edwin cool-file.txt'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/edwin/editor.scm b/src/edwin/editor.scm | |
index 5d23827..933e22d 100644 | |
--- a/src/edwin/editor.scm | |
+++ b/src/edwin/editor.scm | |
@@ -28,13 +28,13 @@ USA. | |
(declare (usual-integrations)) | |
-(define (edit . args) | |
+(define (edit file . args) | |
(call-with-current-continuation | |
(lambda (continuation) | |
(cond (within-editor? | |
(error "edwin: Editor already running")) | |
((not edwin-editor) | |
- (apply create-editor args)) | |
+ (apply create-editor file args)) | |
((not (null? args)) | |
(error "edwin: Arguments ignored when re-entering editor" args)) | |
(edwin-continuation | |
@@ -112,13 +112,16 @@ USA. | |
(define create-editor-args | |
'()) | |
-(define (create-editor . args) | |
+(define (create-editor file . args) | |
(let ((args | |
(if (null? args) | |
create-editor-args | |
(begin | |
(set! create-editor-args args) | |
- args)))) | |
+ args))) | |
+ (filename (if (file-exists? file) | |
+ file | |
+ #f))) | |
(reset-editor) | |
(event-distributor/invoke! editor-initializations) | |
(set! edwin-editor | |
@@ -137,9 +140,11 @@ USA. | |
(set! edwin-initialization | |
(lambda () | |
(set! edwin-initialization #f) | |
- (standard-editor-initialization))) | |
+ (if filename | |
+ (standard-editor-initialization filename) | |
+ (standard-editor-initialization)) | |
(set! edwin-continuation #f) | |
- unspecific)) | |
+ unspecific)))) | |
(define editor-initializations | |
(make-event-distributor)) | |
@@ -165,7 +170,7 @@ USA. | |
(find-preferred preferences)) | |
-(define (standard-editor-initialization) | |
+(define (standard-editor-initialization #!optional filename) | |
(with-editor-interrupts-disabled | |
(lambda () | |
(if (and (not init-file-loaded?) | |
@@ -176,7 +181,10 @@ USA. | |
(load-edwin-file filename '(EDWIN) #t))) | |
(set! init-file-loaded? #t) | |
unspecific)))) | |
- (let ((buffer (find-buffer initial-buffer-name))) | |
+ (let ((buffer (find-buffer initial-buffer-name)) | |
+ (filename (if (not (default-object? filename)) | |
+ ((ref-command find-file) filename) | |
+ #f))) | |
(if (and buffer | |
(not inhibit-initial-inferior-repl?)) | |
(start-inferior-repl! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment