Match special globals in Ruby better
[bpt/emacs.git] / lisp / cmuscheme.el
index 0f64e85..b48b7c9 100644 (file)
@@ -1,18 +1,18 @@
 ;;; cmuscheme.el --- Scheme process in a buffer. Adapted from tea.el
 
 ;;; cmuscheme.el --- Scheme process in a buffer. Adapted from tea.el
 
-;; Copyright (C) 1988, 1994, 1997, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 1997, 2001-2014 Free Software Foundation,
+;; Inc.
 
 ;; Author: Olin Shivers <olin.shivers@cs.cmu.edu>
 
 ;; Author: Olin Shivers <olin.shivers@cs.cmu.edu>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: processes, lisp
 
 ;; This file is part of GNU Emacs.
 
 ;; Keywords: processes, lisp
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, 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
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 ;; 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, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 ;;; Commentary:
 
 ;; invited to port xscheme functionality on top of comint mode...
 
 ;;; CHANGE LOG
 ;; invited to port xscheme functionality on top of comint mode...
 
 ;;; CHANGE LOG
-;;; ===========================================================================
-;;; 8/88 Olin
-;;; Created.
-;;;
-;;; 2/15/89 Olin
-;;; Removed -emacs flag from process invocation. It's only useful for
-;;; cscheme, and makes cscheme assume it's running under xscheme.el,
-;;; which messes things up royally. A bug.
-;;;
-;;; 5/22/90 Olin
-;;; - Upgraded to use comint-send-string and comint-send-region.
-;;; - run-scheme now offers to let you edit the command line if
-;;;   you invoke it with a prefix-arg. M-x scheme is redundant, and
-;;;   has been removed.
-;;; - Explicit references to process "scheme" have been replaced with
-;;;   (scheme-proc). This allows better handling of multiple process bufs.
-;;; - Added scheme-send-last-sexp, bound to C-x C-e. A gnu convention.
-;;; - Have not added process query facility a la cmulisp.el's lisp-show-arglist
-;;;   and friends, but interested hackers might find a useful application
-;;;   of this facility.
-;;;
-;;; 3/12/90 Olin
-;;; - scheme-load-file and scheme-compile-file no longer switch-to-scheme.
-;;;   Tale suggested this.
+;; ===========================================================================
+;; 8/88 Olin
+;; Created.
+;;
+;; 2/15/89 Olin
+;; Removed -emacs flag from process invocation. It's only useful for
+;; cscheme, and makes cscheme assume it's running under xscheme.el,
+;; which messes things up royally. A bug.
+;;
+;; 5/22/90 Olin
+;; - Upgraded to use comint-send-string and comint-send-region.
+;; - run-scheme now offers to let you edit the command line if
+;;   you invoke it with a prefix-arg. M-x scheme is redundant, and
+;;   has been removed.
+;; - Explicit references to process "scheme" have been replaced with
+;;   (scheme-proc). This allows better handling of multiple process bufs.
+;; - Added scheme-send-last-sexp, bound to C-x C-e. A gnu convention.
+;; - Have not added process query facility a la cmulisp.el's lisp-show-arglist
+;;   and friends, but interested hackers might find a useful application
+;;   of this facility.
+;;
+;; 3/12/90 Olin
+;; - scheme-load-file and scheme-compile-file no longer switch-to-scheme.
+;;   Tale suggested this.
 
 ;;; Code:
 
 
 ;;; Code:
 
 ;;;============================================================================
 
 (defcustom inferior-scheme-mode-hook nil
 ;;;============================================================================
 
 (defcustom inferior-scheme-mode-hook nil
-  "*Hook for customizing inferior-scheme mode."
+  "Hook for customizing inferior-scheme mode."
   :type 'hook
   :group 'cmuscheme)
 
   :type 'hook
   :group 'cmuscheme)
 
@@ -172,22 +170,22 @@ The following commands are available:
 
 A Scheme process can be fired up with M-x run-scheme.
 
 
 A Scheme process can be fired up with M-x run-scheme.
 
-Customization: Entry to this mode runs the hooks on comint-mode-hook and
-inferior-scheme-mode-hook (in that order).
+Customization: Entry to this mode runs the hooks on `comint-mode-hook' and
+`inferior-scheme-mode-hook' (in that order).
 
 You can send text to the inferior Scheme process from other buffers containing
 Scheme source.
 
 You can send text to the inferior Scheme process from other buffers containing
 Scheme source.
-    switch-to-scheme switches the current buffer to the Scheme process buffer.
-    scheme-send-definition sends the current definition to the Scheme process.
-    scheme-compile-definition compiles the current definition.
-    scheme-send-region sends the current region to the Scheme process.
-    scheme-compile-region compiles the current region.
-
-    scheme-send-definition-and-go, scheme-compile-definition-and-go,
-        scheme-send-region-and-go, and scheme-compile-region-and-go
+    `switch-to-scheme' switches the current buffer to the Scheme process buffer.
+    `scheme-send-definition' sends the current definition to the Scheme process.
+    `scheme-compile-definition' compiles the current definition.
+    `scheme-send-region' sends the current region to the Scheme process.
+    `scheme-compile-region' compiles the current region.
+
+    `scheme-send-definition-and-go', `scheme-compile-definition-and-go',
+        `scheme-send-region-and-go', and `scheme-compile-region-and-go'
         switch to the Scheme process buffer after sending their text.
 For information on running multiple processes in multiple buffers, see
         switch to the Scheme process buffer after sending their text.
 For information on running multiple processes in multiple buffers, see
-documentation for variable scheme-buffer.
+documentation for variable `scheme-buffer'.
 
 Commands:
 Return after the end of the process' output sends the text from the
 
 Commands:
 Return after the end of the process' output sends the text from the
@@ -209,14 +207,14 @@ to continue it."
   (setq comint-get-old-input (function scheme-get-old-input)))
 
 (defcustom inferior-scheme-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
   (setq comint-get-old-input (function scheme-get-old-input)))
 
 (defcustom inferior-scheme-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
-  "*Input matching this regexp are not saved on the history list.
+  "Input matching this regexp are not saved on the history list.
 Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters."
   :type 'regexp
   :group 'cmuscheme)
 
 (defun scheme-input-filter (str)
   "Don't save anything matching `inferior-scheme-filter-regexp'."
 Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters."
   :type 'regexp
   :group 'cmuscheme)
 
 (defun scheme-input-filter (str)
   "Don't save anything matching `inferior-scheme-filter-regexp'."
-  (not (string-match inferior-scheme-filter-regexp str)))
+  (not (string-match-p inferior-scheme-filter-regexp str)))
 
 (defun scheme-get-old-input ()
   "Snarf the sexp ending at point."
 
 (defun scheme-get-old-input ()
   "Snarf the sexp ending at point."
@@ -225,19 +223,6 @@ Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters."
       (backward-sexp)
       (buffer-substring (point) end))))
 
       (backward-sexp)
       (buffer-substring (point) end))))
 
-(defun scheme-args-to-list (string)
-  (let ((where (string-match "[ \t]" string)))
-    (cond ((null where) (list string))
-         ((not (= where 0))
-          (cons (substring string 0 where)
-                (scheme-args-to-list (substring string (+ 1 where)
-                                                (length string)))))
-         (t (let ((pos (string-match "[^ \t]" string)))
-              (if (null pos)
-                  nil
-                (scheme-args-to-list (substring string pos
-                                                (length string)))))))))
-
 ;;;###autoload
 (defun run-scheme (cmd)
   "Run an inferior Scheme process, input and output via buffer `*scheme*'.
 ;;;###autoload
 (defun run-scheme (cmd)
   "Run an inferior Scheme process, input and output via buffer `*scheme*'.
@@ -248,7 +233,7 @@ If the file `~/.emacs_SCHEMENAME' or `~/.emacs.d/init_SCHEMENAME.scm' exists,
 it is given as initial input.
 Note that this may lose due to a timing error if the Scheme processor
 discards input when it starts up.
 it is given as initial input.
 Note that this may lose due to a timing error if the Scheme processor
 discards input when it starts up.
-Runs the hook `inferior-scheme-mode-hook' \(after the `comint-mode-hook'
+Runs the hook `inferior-scheme-mode-hook' (after the `comint-mode-hook'
 is run).
 \(Type \\[describe-mode] in the process buffer for a list of commands.)"
 
 is run).
 \(Type \\[describe-mode] in the process buffer for a list of commands.)"
 
@@ -256,19 +241,18 @@ is run).
                         (read-string "Run Scheme: " scheme-program-name)
                         scheme-program-name)))
   (if (not (comint-check-proc "*scheme*"))
                         (read-string "Run Scheme: " scheme-program-name)
                         scheme-program-name)))
   (if (not (comint-check-proc "*scheme*"))
-      (let ((cmdlist (scheme-args-to-list cmd)))
+      (let ((cmdlist (split-string-and-unquote cmd)))
        (set-buffer (apply 'make-comint "scheme" (car cmdlist)
                           (scheme-start-file (car cmdlist)) (cdr cmdlist)))
        (inferior-scheme-mode)))
   (setq scheme-program-name cmd)
   (setq scheme-buffer "*scheme*")
        (set-buffer (apply 'make-comint "scheme" (car cmdlist)
                           (scheme-start-file (car cmdlist)) (cdr cmdlist)))
        (inferior-scheme-mode)))
   (setq scheme-program-name cmd)
   (setq scheme-buffer "*scheme*")
-  (pop-to-buffer "*scheme*"))
-;;;###autoload (add-hook 'same-window-buffer-names "*scheme*")
+  (pop-to-buffer-same-window "*scheme*"))
 
 (defun scheme-start-file (prog)
   "Return the name of the start file corresponding to PROG.
 
 (defun scheme-start-file (prog)
   "Return the name of the start file corresponding to PROG.
-Search in the directories \"~\" and \"~/.emacs.d\", in this
-order.  Return nil if no start file found."
+Search in the directories \"~\" and `user-emacs-directory',
+in this order.  Return nil if no start file found."
   (let* ((progname (file-name-nondirectory prog))
         (start-file (concat "~/.emacs_" progname))
         (alt-start-file (concat user-emacs-directory "init_" progname ".scm")))
   (let* ((progname (file-name-nondirectory prog))
         (start-file (concat "~/.emacs_" progname))
         (alt-start-file (concat user-emacs-directory "init_" progname ".scm")))
@@ -297,7 +281,7 @@ order.  Return nil if no start file found."
   (scheme-send-region (save-excursion (backward-sexp) (point)) (point)))
 
 (defcustom scheme-compile-exp-command "(compile '%s)"
   (scheme-send-region (save-excursion (backward-sexp) (point)) (point)))
 
 (defcustom scheme-compile-exp-command "(compile '%s)"
-  "*Template for issuing commands to compile arbitrary Scheme expressions."
+  "Template for issuing commands to compile arbitrary Scheme expressions."
   :type 'string
   :group 'cmuscheme)
 
   :type 'string
   :group 'cmuscheme)
 
@@ -320,7 +304,7 @@ order.  Return nil if no start file found."
      (scheme-compile-region (point) end))))
 
 (defcustom scheme-trace-command "(trace %s)"
      (scheme-compile-region (point) end))))
 
 (defcustom scheme-trace-command "(trace %s)"
-  "*Template for issuing commands to trace a Scheme procedure.
+  "Template for issuing commands to trace a Scheme procedure.
 Some Scheme implementations might require more elaborate commands here.
 For PLT-Scheme, e.g., one should use
 
 Some Scheme implementations might require more elaborate commands here.
 For PLT-Scheme, e.g., one should use
 
@@ -331,7 +315,7 @@ For Scheme 48 and Scsh use \",trace %s\"."
   :group 'cmuscheme)
 
 (defcustom scheme-untrace-command "(untrace %s)"
   :group 'cmuscheme)
 
 (defcustom scheme-untrace-command "(untrace %s)"
-  "*Template for switching off tracing of a Scheme procedure.
+  "Template for switching off tracing of a Scheme procedure.
 Scheme 48 and Scsh users should set this variable to \",untrace %s\"."
 
   :type 'string
 Scheme 48 and Scsh users should set this variable to \",untrace %s\"."
 
   :type 'string
@@ -356,7 +340,7 @@ With a prefix argument switch off tracing of procedure PROC."
   (comint-send-string (scheme-proc) "\n"))
 
 (defcustom scheme-macro-expand-command "(expand %s)"
   (comint-send-string (scheme-proc) "\n"))
 
 (defcustom scheme-macro-expand-command "(expand %s)"
-  "*Template for macro-expanding a Scheme form.
+  "Template for macro-expanding a Scheme form.
 For Scheme 48 and Scsh use \",expand %s\"."
   :type 'string
   :group 'cmuscheme)
 For Scheme 48 and Scsh use \",expand %s\"."
   :type 'string
   :group 'cmuscheme)
@@ -383,12 +367,12 @@ For Scheme 48 and Scsh use \",expand %s\"."
         (scheme-form-at-point)))))
 
 (defun switch-to-scheme (eob-p)
         (scheme-form-at-point)))))
 
 (defun switch-to-scheme (eob-p)
-  "Switch to the scheme process buffer.
+  "Switch to the Scheme process buffer.
 With argument, position cursor at end of buffer."
   (interactive "P")
   (if (or (and scheme-buffer (get-buffer scheme-buffer))
           (scheme-interactively-start-process))
 With argument, position cursor at end of buffer."
   (interactive "P")
   (if (or (and scheme-buffer (get-buffer scheme-buffer))
           (scheme-interactively-start-process))
-      (pop-to-buffer scheme-buffer)
+      (pop-to-buffer-same-window scheme-buffer)
     (error "No current process buffer.  See variable `scheme-buffer'"))
   (when eob-p
     (push-mark)
     (error "No current process buffer.  See variable `scheme-buffer'"))
   (when eob-p
     (push-mark)
@@ -423,7 +407,7 @@ Then switch to the process buffer."
   (switch-to-scheme t))
 
 (defcustom scheme-source-modes '(scheme-mode)
   (switch-to-scheme t))
 
 (defcustom scheme-source-modes '(scheme-mode)
-  "*Used to determine if a buffer contains Scheme source code.
+  "Used to determine if a buffer contains Scheme source code.
 If it's loaded into a buffer that is in one of these major modes, it's
 considered a scheme source file by `scheme-load-file' and `scheme-compile-file'.
 Used by these commands to determine defaults."
 If it's loaded into a buffer that is in one of these major modes, it's
 considered a scheme source file by `scheme-load-file' and `scheme-compile-file'.
 Used by these commands to determine defaults."
@@ -463,7 +447,7 @@ in the next one.")
                                            "\"\)\n")))
 
 \f
                                            "\"\)\n")))
 
 \f
-(defvar scheme-buffer nil "*The current scheme process buffer.
+(defvar scheme-buffer nil "The current scheme process buffer.
 
 MULTIPLE PROCESS SUPPORT
 ===========================================================================
 
 MULTIPLE PROCESS SUPPORT
 ===========================================================================
@@ -494,8 +478,8 @@ This process selection is performed by function `scheme-proc'.
 
 Whenever \\[run-scheme] fires up a new process, it resets `scheme-buffer'
 to be the new process's buffer.  If you only run one process, this will
 
 Whenever \\[run-scheme] fires up a new process, it resets `scheme-buffer'
 to be the new process's buffer.  If you only run one process, this will
-do the right thing.  If you run multiple processes, you can change
-`scheme-buffer' to another process buffer with \\[set-variable].
+do the right thing.  If you run multiple processes, you might need to
+set `scheme-buffer' to whichever process buffer you want to use.
 
 More sophisticated approaches are, of course, possible.  If you find yourself
 needing to switch back and forth between multiple processes frequently,
 
 More sophisticated approaches are, of course, possible.  If you find yourself
 needing to switch back and forth between multiple processes frequently,
@@ -519,7 +503,7 @@ See variable `scheme-buffer'."
                           (current-buffer)
                         scheme-buffer)))
 
                           (current-buffer)
                         scheme-buffer)))
 
-(defun scheme-interactively-start-process (&optional cmd)
+(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."
   "Start an inferior Scheme process.  Return the process started.
 Since this command is run implicitly, always ask the user for the
 command to run."
@@ -538,5 +522,4 @@ This is a good place to put keybindings."
 
 (provide 'cmuscheme)
 
 
 (provide 'cmuscheme)
 
-;; arch-tag: e8795f4a-c496-45a2-97b4-8e0f2a2c57d2
 ;;; cmuscheme.el ends here
 ;;; cmuscheme.el ends here