Annotation of 43BSD/contrib/emacs/lisp/xscheme.el, revision 1.1

1.1     ! root        1: ;;; -*-Emacs-Lisp-*- Scheme under emacs stuff.
        !             2: ;; Copyright (C) 1985 Bill Rozas & Richard M. Stallman
        !             3: 
        !             4: ;; This file is part of GNU Emacs.
        !             5: 
        !             6: ;; GNU Emacs is distributed in the hope that it will be useful,
        !             7: ;; but WITHOUT ANY WARRANTY.  No author or distributor
        !             8: ;; accepts responsibility to anyone for the consequences of using it
        !             9: ;; or for whether it serves any particular purpose or works at all,
        !            10: ;; unless he says so in writing.  Refer to the GNU Emacs General Public
        !            11: ;; License for full details.
        !            12: 
        !            13: ;; Everyone is granted permission to copy, modify and redistribute
        !            14: ;; GNU Emacs, but only under the conditions described in the
        !            15: ;; GNU Emacs General Public License.   A copy of this license is
        !            16: ;; supposed to have been given to you along with GNU Emacs so you
        !            17: ;; can know your rights and responsibilities.  It should be in a
        !            18: ;; file named COPYING.  Among other things, the copyright notice
        !            19: ;; and this notice must be preserved on all copies.
        !            20: 
        !            21: ;; Adapted from shell.el to scheme.  
        !            22: ;; Note: It only  works with Cscheme release 4 or later.
        !            23: 
        !            24: (require 'scheme)
        !            25: (require 'shell)
        !            26: 
        !            27: (defvar inferior-scheme-mode-map nil)
        !            28: (if inferior-scheme-mode-map
        !            29:     nil
        !            30:   (setq inferior-scheme-mode-map (copy-alist shell-mode-map))
        !            31:   (define-key inferior-scheme-mode-map "\C-c\C-a" 'quit-shell-subjob)
        !            32:   (define-key inferior-scheme-mode-map "\C-c\C-g" 'interrupt-shell-subjob)
        !            33:   (define-key inferior-scheme-mode-map "\e\C-g" 'interrupt-shell-subjob)
        !            34:   (scheme-mode-commands inferior-scheme-mode-map))
        !            35: 
        !            36: (defun inferior-scheme-mode ()
        !            37:   "Major mode for interacting with an inferior Scheme process.
        !            38: 
        !            39: The following commands are available:
        !            40: \\{inferior-scheme-mode-map}
        !            41: 
        !            42: Entry to this mode calls the value of scheme-mode-hook with no arguments,
        !            43: if that value is non-nil.  Likewise with the value of shell-mode-hook.
        !            44: scheme-mode-hook is called after shell-mode-hook.
        !            45: 
        !            46: You can send text to the inferior Scheme from other buffers
        !            47: using the commands send-region, send-string and \\[scheme-send-definition].
        !            48: 
        !            49: Commands:
        !            50: Delete converts tabs to spaces as it moves back.
        !            51: Tab indents for Scheme; with argument, shifts rest
        !            52:  of expression rigidly with the current line.
        !            53: Meta-Control-Q does Tab on each line starting within following expression.
        !            54: Paragraphs are separated only by blank lines.  Semicolons start comments.
        !            55: 
        !            56: Return at end of buffer sends line as input.
        !            57: Return not at end copies rest of line to end and sends it.
        !            58: C-d at end of buffer sends end-of-file as input.
        !            59: C-d not at end or with arg deletes or kills characters.
        !            60: C-u and C-w are kill commands, imitating normal Unix input editing.
        !            61: C-c interrupts the shell or its current subjob if any.
        !            62: C-z stops, likewise.  C-\\ sends quit signal, likewise.
        !            63: 
        !            64: C-x C-k deletes last batch of output from shell.
        !            65: C-x C-v puts top of last batch of output at top of window."
        !            66:   (interactive)
        !            67:   (kill-all-local-variables)
        !            68:   (setq major-mode 'inferior-scheme-mode)
        !            69:   (setq mode-name "Inferior Scheme")
        !            70:   (setq mode-line-format 
        !            71:        "--%1*%1*-Emacs: %17b   %M   %[(%m: %s)%]----%3p--%-")
        !            72:   (scheme-mode-variables)
        !            73:   (use-local-map inferior-scheme-mode-map)
        !            74:   (make-local-variable 'last-input-start)
        !            75:   (setq last-input-start (make-marker))
        !            76:   (make-local-variable 'last-input-end)
        !            77:   (setq last-input-end (make-marker))
        !            78:   (run-hooks 'shell-mode-hook 'scheme-mode-hook))
        !            79: 
        !            80: (defun args-to-list (string)
        !            81:   (let ((where (string-match "[ \t]" string)))
        !            82:     (cond ((null where) (list string))
        !            83:          ((not (= where 0))
        !            84:           (cons (substring string 0 where)
        !            85:                 (args-to-list (substring string (+ 1 where)
        !            86:                                          (length string)))))
        !            87:          (t (let ((pos (string-match "[^ \t]" string)))
        !            88:               (if (null pos)
        !            89:                   nil
        !            90:                 (args-to-list (substring string pos (length string)))))))))
        !            91: 
        !            92: (defconst scheme-program-name "scheme"
        !            93:   "Program invoked by the scheme and run-scheme commands")
        !            94: 
        !            95: (defun scheme (arg)
        !            96:   "Run an inferior Scheme process reading a command line from the terminal."
        !            97:   (interactive "sExtra arguments to scheme: ")
        !            98:   (switch-to-buffer
        !            99:    (apply 'make-shell (append (list "scheme" scheme-program-name nil)
        !           100:                              (args-to-list arg)
        !           101:                              '("-emacs"))))
        !           102:   (inferior-scheme-mode))
        !           103: 
        !           104: (defun run-scheme (arg)
        !           105:   "Run an inferior Scheme process.
        !           106: Input and output via buffer *scheme*.
        !           107: With argument it asks for a command line."
        !           108:   (interactive "P")
        !           109:   (if arg (call-interactively 'scheme)
        !           110:     (switch-to-buffer (make-shell "scheme" scheme-program-name nil "-emacs"))
        !           111:     (inferior-scheme-mode)))
        !           112: 
        !           113: (defun scheme-send-definition ()
        !           114:   "Send the current definition to the Scheme process made by M-x run-scheme."
        !           115:   (interactive)
        !           116:   (save-excursion
        !           117:    (end-of-defun)
        !           118:    (let ((end (point)))
        !           119:      (beginning-of-defun)
        !           120:      (send-region "scheme" (point) end)
        !           121:      (send-string "scheme" "\n"))))
        !           122: 
        !           123: (defun scheme-send-definition-and-go ()
        !           124:   "Send the current definition to the inferior Scheme, and switch to *scheme* buffer."
        !           125:   (interactive)
        !           126:   (scheme-send-definition)
        !           127:   (switch-to-buffer "*scheme*"))
        !           128: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.