all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch to cmuscheme: start a new Scheme process if necessary
@ 2005-07-24 11:53 Emilio Lopes
  0 siblings, 0 replies; only message in thread
From: Emilio Lopes @ 2005-07-24 11:53 UTC (permalink / raw


[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

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  <eclig@gmx.net>

        * 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



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cmuscheme.el.patch --]
[-- Type: text/x-patch, Size: 2105 bytes --]

--- 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...
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-24 11:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-24 11:53 Patch to cmuscheme: start a new Scheme process if necessary Emilio Lopes

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.