]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/inf-lisp.el
Changed version to 1.2.1.
[gnu-emacs] / lisp / progmodes / inf-lisp.el
index 55f8170048354ee8b89d61d027e675f3cf86be0b..08eddc4786973ce239f568fc46078ac3f5f8dd69 100644 (file)
@@ -1,62 +1,64 @@
 ;;; inf-lisp.el --- an inferior-lisp mode
-;;; Copyright (C) 1988, 1993 Free Software Foundation, Inc.
+
+;; Copyright (C) 1988, 1993, 1994 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
 ;; Keywords: processes, lisp
 
-;;; This file is part of GNU Emacs.
+;; This file is part of GNU Emacs.
 
-;;; GNU Emacs is free software; you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 2, or (at your option)
-;;; any later version.
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
 
-;;; GNU Emacs is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
 
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Emacs; see the file COPYING.  If not, write to
-;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
-;;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
-
-;;; This file defines a a lisp-in-a-buffer package (inferior-lisp
-;;; mode) built on top of comint mode.  This version is more
-;;; featureful, robust, and uniform than the Emacs 18 version.  The
-;;; key bindings are also more compatible with the bindings of Hemlock
-;;; and Zwei (the Lisp Machine emacs).
-
-;;; Since this mode is built on top of the general command-interpreter-in-
-;;; a-buffer mode (comint mode), it shares a common base functionality, 
-;;; and a common set of bindings, with all modes derived from comint mode.
-;;; This makes these modes easier to use.
-
-;;; For documentation on the functionality provided by comint mode, and
-;;; the hooks available for customising it, see the file comint.el.
-;;; For further information on inferior-lisp mode, see the comments below.
-
-;;; Needs fixin:
-;;; The load-file/compile-file default mechanism could be smarter -- it
-;;; doesn't know about the relationship between filename extensions and
-;;; whether the file is source or executable. If you compile foo.lisp
-;;; with compile-file, then the next load-file should use foo.bin for
-;;; the default, not foo.lisp. This is tricky to do right, particularly
-;;; because the extension for executable files varies so much (.o, .bin,
-;;; .lbin, .mo, .vo, .ao, ...).
-;;;
-;;; It would be nice if inferior-lisp (and inferior scheme, T, ...) modes
-;;; had a verbose minor mode wherein sending or compiling defuns, etc.
-;;; would be reflected in the transcript with suitable comments, e.g.
-;;; ";;; redefining fact". Several ways to do this. Which is right?
-;;;
-;;; When sending text from a source file to a subprocess, the process-mark can 
-;;; move off the window, so you can lose sight of the process interactions.
-;;; Maybe I should ensure the process mark is in the window when I send
-;;; text to the process? Switch selectable?
+;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
+
+;; This file defines a a lisp-in-a-buffer package (inferior-lisp
+;; mode) built on top of comint mode.  This version is more
+;; featureful, robust, and uniform than the Emacs 18 version.  The
+;; key bindings are also more compatible with the bindings of Hemlock
+;; and Zwei (the Lisp Machine emacs).
+
+;; Since this mode is built on top of the general command-interpreter-in-
+;; a-buffer mode (comint mode), it shares a common base functionality, 
+;; and a common set of bindings, with all modes derived from comint mode.
+;; This makes these modes easier to use.
+
+;; For documentation on the functionality provided by comint mode, and
+;; the hooks available for customising it, see the file comint.el.
+;; For further information on inferior-lisp mode, see the comments below.
+
+;; Needs fixin:
+;; The load-file/compile-file default mechanism could be smarter -- it
+;; doesn't know about the relationship between filename extensions and
+;; whether the file is source or executable. If you compile foo.lisp
+;; with compile-file, then the next load-file should use foo.bin for
+;; the default, not foo.lisp. This is tricky to do right, particularly
+;; because the extension for executable files varies so much (.o, .bin,
+;; .lbin, .mo, .vo, .ao, ...).
+;;
+;; It would be nice if inferior-lisp (and inferior scheme, T, ...) modes
+;; had a verbose minor mode wherein sending or compiling defuns, etc.
+;; would be reflected in the transcript with suitable comments, e.g.
+;; ";;; redefining fact". Several ways to do this. Which is right?
+;;
+;; When sending text from a source file to a subprocess, the process-mark can 
+;; move off the window, so you can lose sight of the process interactions.
+;; Maybe I should ensure the process mark is in the window when I send
+;; text to the process? Switch selectable?
 
 ;;; Code:
 
@@ -69,7 +71,7 @@
   "*What not to save on inferior Lisp's input history.
 Input matching this regexp is not saved on the input history in Inferior Lisp
 mode.  Default is whitespace followed by 0 or 1 single-letter colon-keyword 
-(as in :a, :c, etc.)")
+\(as in :a, :c, etc.)")
 
 (defvar inferior-lisp-mode-map nil)
 (cond ((not inferior-lisp-mode-map)
@@ -144,7 +146,7 @@ mode.  Default is whitespace followed by 0 or 1 single-letter colon-keyword
 This format string should use `%s' to substitute a file name
 and should result in a Lisp expression that will command the inferior Lisp
 to load that file.  The default works acceptably on most Lisps.
-The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\\n\"
+The string \"(progn (load \\\"%s\\\" :verbose nil :print t) (values))\\n\"
 produces cosmetically superior output for this application,
 but it works only in Common Lisp.")
 
@@ -156,8 +158,8 @@ and franz.  This variable is used to initialize `comint-prompt-regexp' in the
 Inferior Lisp buffer.
 
 More precise choices:
-Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
-franz: \"^\\(->\\|<[0-9]*>:\\) *\"
+Lucid Common Lisp: \"^\\\\(>\\\\|\\\\(->\\\\)+\\\\) *\"
+franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\"
 kcl: \"^>+ *\"
 
 This is a fine thing to set in your .emacs file.")
@@ -201,6 +203,8 @@ buffer with \\[set-variable].")
 (defvar inferior-lisp-mode-hook '()
   "*Hook for customising Inferior Lisp mode.")
 
+(put 'inferior-lisp-mode 'mode-class 'special)
+
 (defun inferior-lisp-mode () 
   "Major mode for interacting with an inferior Lisp process.  
 Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an
@@ -283,7 +287,8 @@ of `inferior-lisp-program').  Runs the hooks from
                           "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
        (inferior-lisp-mode)))
   (setq inferior-lisp-buffer "*inferior-lisp*")
-  (switch-to-buffer "*inferior-lisp*"))
+  (pop-to-buffer "*inferior-lisp*"))
+;;;###autoload (add-hook 'same-window-buffer-names "*inferior-lisp*")
 
 ;;;###autoload
 (defalias 'run-lisp 'inferior-lisp)
@@ -357,12 +362,17 @@ Prefix argument means switch to the Lisp buffer afterwards."
   "Switch to the inferior Lisp process buffer.
 With argument, positions cursor at end of buffer."
   (interactive "P")
-  (if (get-buffer inferior-lisp-buffer)
-      (pop-to-buffer inferior-lisp-buffer)
-    (error "No current inferior Lisp buffer"))
-  (cond (eob-p
+  (if (get-buffer-process inferior-lisp-buffer)
+      (let ((pop-up-frames
+            ;; Be willing to use another frame
+            ;; that already has the window in it.
+            (or pop-up-frames
+                (get-buffer-window inferior-lisp-buffer t))))
+       (pop-to-buffer inferior-lisp-buffer))
+      (run-lisp inferior-lisp-program))
+  (when eob-p
         (push-mark)
-        (goto-char (point-max)))))
+    (goto-char (point-max))))
 
 
 ;;; Now that lisp-compile/eval-defun/region takes an optional prefix arg,