~ chicken-core (chicken-5) f331b106bc3fa13d1342cdd66885b61849a7c167
commit f331b106bc3fa13d1342cdd66885b61849a7c167 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Sun Jun 20 02:15:48 2010 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Sun Jun 20 02:15:48 2010 +0200 added ,e command to csi toplevel (suggested by Oivind Binde) diff --git a/csi.import.scm b/csi.import.scm index 34de1609..0d41861e 100644 --- a/csi.import.scm +++ b/csi.import.scm @@ -26,4 +26,4 @@ (##sys#register-primitive-module 'csi - '(toplevel-command set-describer!)) + '(toplevel-command editor-command set-describer!)) diff --git a/csi.scm b/csi.scm index 2ad91162..1a3dab84 100644 --- a/csi.scm +++ b/csi.scm @@ -54,7 +54,7 @@ EOF ##sys#windows-platform) (hide parse-option-string bytevector-data member* canonicalize-args describer-table dirseparator? circular-list? improper-pairs? - findall command-table) ) + findall command-table default-editor) ) ;;; Parameters: @@ -65,6 +65,15 @@ EOF (set! ##sys#features (cons #:csi ##sys#features)) (set! ##sys#notices-enabled #t) +(define editor-command (make-parameter #f)) + +(define default-editor + (or (get-environment-variable "EDITOR") + (get-environment-variable "VISUAL") + (if (get-environment-variable "EMACS") + "emacsclient" + "vi"))) ; shudder + ;;; Print all sorts of information: @@ -317,6 +326,13 @@ EOF (when ##sys#last-exception (history-add (list ##sys#last-exception)) (describe ##sys#last-exception) ) ) + ((e) + (let ((r (system + (string-append + (or (editor-command) default-editor) + " " (read-line))))) + (if (not (zero? r)) + (printf "Editor returned with non-zero exit status ~a" r)))) ((s) (let* ((str (read-line)) (r (system str)) ) @@ -335,6 +351,7 @@ EOF ,l FILENAME ... Load one or more files ,ln FILENAME ... Load one or more files and print result of each top-level expression ,r Show system information + ,e FILENAME Run external editor ,s TEXT ... Execute shell-command ,exn Describe last exception ,t EXP Evaluate form and print elapsed timeTrap