--- orig/lisp/cmuscheme.el +++ mod/lisp/cmuscheme.el @@ -300,12 +300,13 @@ "Switch to the scheme process buffer. With argument, position cursor at end of buffer." (interactive "P") - (if (get-buffer scheme-buffer) + (if (or (and scheme-buffer (get-buffer scheme-buffer)) + (scheme-interactively-start-process)) (pop-to-buffer scheme-buffer) - (error "No current process buffer. See variable `scheme-buffer'")) - (cond (eob-p - (push-mark) - (goto-char (point-max))))) + (error "No current process buffer. See variable `scheme-buffer'")) + (when eob-p + (push-mark) + (goto-char (point-max)))) (defun scheme-send-region-and-go (start end) "Send the current region to the inferior Scheme process. @@ -417,13 +418,27 @@ for a minimal, simple implementation. Feel free to extend it.") (defun scheme-proc () - "Return the current scheme process. See variable `scheme-buffer'." - (let ((proc (get-buffer-process (if (eq major-mode 'inferior-scheme-mode) - (current-buffer) - scheme-buffer)))) - (or proc - (error "No current process. See variable `scheme-buffer'")))) - + "Return the current Scheme process, starting one if necessary. +See variable `scheme-buffer'." + (unless (and scheme-buffer + (get-buffer scheme-buffer) + (comint-check-proc scheme-buffer)) + (scheme-interactively-start-process)) + (or (scheme-get-process) + (error "No current process. See variable `scheme-buffer'"))) + +(defun scheme-get-process () + "Return the current Scheme process or nil if none is running." + (get-buffer-process (if (eq major-mode 'inferior-scheme-mode) + (current-buffer) + scheme-buffer))) + +(defun scheme-interactively-start-process (&optional cmd) + "Start an inferior Scheme process. Return the process started. +Since this command is run implicitly, always ask the user for the +command to run." + (save-window-excursion + (run-scheme (read-string "Run Scheme: " scheme-program-name)))) ;;; Do the user's customisation...