From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emilio Lopes Newsgroups: gmane.emacs.devel Subject: Patch to cmuscheme: start a new Scheme process if necessary Date: Sun, 24 Jul 2005 13:53:34 +0200 Organization: private Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1122215596 17679 80.91.229.2 (24 Jul 2005 14:33:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Jul 2005 14:33:16 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 24 16:33:15 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DwhXT-0007T2-K8 for ged-emacs-devel@m.gmane.org; Sun, 24 Jul 2005 16:33:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DwhZh-0006B4-P1 for ged-emacs-devel@m.gmane.org; Sun, 24 Jul 2005 10:35:29 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DwhWP-0005UM-HB for emacs-devel@gnu.org; Sun, 24 Jul 2005 10:32:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DwhWB-0005Py-FG for emacs-devel@gnu.org; Sun, 24 Jul 2005 10:31:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DwhWB-0005Fe-2b for emacs-devel@gnu.org; Sun, 24 Jul 2005 10:31:51 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1DwhMU-0007oK-Jx for emacs-devel@gnu.org; Sun, 24 Jul 2005 10:21:50 -0400 Original-Received: (qmail invoked by alias); 24 Jul 2005 14:11:09 -0000 Original-Received: from p62.246.22.81.tisdip.tiscali.de (EHLO jumeirah.tiscali.de) [62.246.22.81] by mail.gmx.net (mp034) with SMTP; 24 Jul 2005 16:11:09 +0200 X-Authenticated: #3737989 Original-To: emacs-devel@gnu.org User-Agent: Emacs Gnus X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:41180 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:41180 --=-=-= 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 * 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=cmuscheme.el.patch --- 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... --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--