unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Emilio Lopes <eclig@gmx.net>
Subject: Patch to cmuscheme: start a new Scheme process if necessary
Date: Sun, 24 Jul 2005 13:53:34 +0200	[thread overview]
Message-ID: <smu0ika08x.fsf@tiscali.de> (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

                 reply	other threads:[~2005-07-24 11:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=smu0ika08x.fsf@tiscali.de \
    --to=eclig@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).