diff options
author | Robin Templeton <[email protected]> | 2014-08-11 07:01:19 -0400 |
---|---|---|
committer | Robin Templeton <[email protected]> | 2015-04-20 00:29:03 -0400 |
commit | 32a9496d8d7f87bb7695b62340e2602eb9cab615 (patch) | |
tree | e7051a81bf4f59aa7e696c3e27e5bd3d35555ed0 /lisp | |
parent | 147728721aefd0521ced92883aa1ae3e14420d68 (diff) |
scheme interaction mode
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/progmodes/scheme.el | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index c47a3bd6fb..32ee3c2399 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -588,6 +588,67 @@ indentation." (put 'unassigned\?-components 'scheme-indent-function 1) (put 'unbound\?-components 'scheme-indent-function 1) (put 'variable-components 'scheme-indent-function 1))) + +;; Scheme Interaction Mode + +(defun scheme-eval-defun () + (interactive) + (let ((debug-on-error eval-expression-debug-on-error) + (print-length eval-expression-print-length) + (print-level eval-expression-print-level)) + (let* ((value (eval-scheme (thing-at-point 'defun t))) + (str (eval-expression-print-format value))) + (prin1 value t) + (if str (princ str)) + value))) + +(defun scheme-eval-print-last-sexp (arg) + (interactive "P") + (setq arg (or arg t)) + (let ((standard-output (current-buffer))) + (terpri) + (let ((standard-output (if arg (current-buffer) t)) + (form (buffer-substring-no-properties + (save-excursion (backward-sexp) (point)) + (point)))) + (eval-last-sexp-print-value (eval-scheme form) arg)) + (terpri))) + +(defvar scheme-interaction-mode-map + (let ((map (make-sparse-keymap)) + (menu-map (make-sparse-keymap "Scheme-Interaction"))) + (set-keymap-parent map lisp-mode-shared-map) + (define-key map "\e\C-x" 'scheme-eval-defun) + (define-key map "\n" 'scheme-eval-print-last-sexp) + (bindings--define-key map [menu-bar scheme-interaction] + (cons "Scheme-Interaction" menu-map)) + (bindings--define-key menu-map [eval-defun] + '(menu-item "Evaluate Defun" scheme-eval-defun + :help "Evaluate the top-level form containing point, or after point")) + (bindings--define-key menu-map [print-last-sexp] + '(menu-item "Evaluate and Print" scheme-eval-print-last-sexp + :help "Evaluate sexp before point; print value into current buffer")) + (bindings--define-key menu-map [indent-sexp] + '(menu-item "Indent" indent-sexp + :help "Indent each line of the list starting just after point")) + map) + "Keymap for Scheme Interaction mode. +All commands in `lisp-mode-shared-map' are inherited by this map.") + +(define-derived-mode scheme-interaction-mode scheme-mode "Scheme Interaction" + "Major mode for typing and evaluating Scheme forms. +Like Scheme mode except that \\[scheme-eval-print-last-sexp] evals the +Scheme expression before point, and prints its value into the +buffer, advancing point. Note that printing is controlled by +`eval-expression-print-length' and `eval-expression-print-level'. + +Commands: +Delete converts tabs to spaces as it moves back. +Paragraphs are separated only by blank lines. +Semicolons start comments. + +\\{scheme-interaction-mode-map}" + :abbrev-table nil) (provide 'scheme) |