In a Scheme buffer, if the user tries to evaluate an expression and no Scheme process is running, Emacs signals an error. This is not very useful; Emacs can indeed do better.
With the following patch Emacs asks the user in such cases which Scheme program to start, presenting `scheme-program-name' as the default choice. 2005-06-12 Emilio C. Lopes <[EMAIL PROTECTED]> * cmuscheme.el (switch-to-scheme, scheme-proc): call `scheme-interactively-start-process' if no Scheme buffer/process available. (scheme-get-process): new function extracted from `scheme-proc' (scheme-interactively-start-process): new function
--- 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...
_______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel