diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-02-27 22:57:53 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-02-27 22:57:53 +0100 |
commit | b87e894c6d68a6c2b24bc75b65a76e1a12b3791b (patch) | |
tree | fb353e721211028726fe961909f52a952bf85d2b /elisp | |
parent | 070b159aa6db39cd220e76b25d6ad58b2a0e3362 (diff) | |
download | geiser-chez-b87e894c6d68a6c2b24bc75b65a76e1a12b3791b.tar.gz geiser-chez-b87e894c6d68a6c2b24bc75b65a76e1a12b3791b.tar.bz2 |
Better handling of multi-line input in the REPL
- We don't send incomplete sexps to the underlying REPL
- Automatic indentation of multi-line sexps
- Syntax highlighting of scheme keywords
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-repl.el | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 9bff115..e19d7b7 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -20,6 +20,7 @@ (require 'comint) (require 'compile) +(require 'scheme) ;;; Customization: @@ -287,10 +288,11 @@ If no REPL is running, execute `run-geiser' to start a fresh one." (when (= (point) (comint-bol)) (beginning-of-line))) (defun geiser-repl--beginning-of-defun () - (let ((p (point))) - (comint-bol) - (when (not (eq (char-after (point)) ?\()) - (skip-syntax-forward "^(" p)))) + (save-restriction + (when comint-last-prompt-overlay + (narrow-to-region (overlay-end comint-last-prompt-overlay) (point))) + (let ((beginning-of-defun-function nil)) + (beginning-of-defun)))) (defun geiser-repl--module-function (&optional ignore) :f) @@ -300,24 +302,45 @@ If no REPL is running, execute `run-geiser' to start a fresh one." (geiser-impl--method 'find-module geiser-impl--implementation))) (geiser-doc-module))) +(defun geiser-repl--newline-and-indent () + (interactive) + (save-restriction + (narrow-to-region comint-last-input-start (point-max)) + (insert "\n") + (lisp-indent-line))) + +(defun geiser-repl--send-input () + (interactive) + (let ((p (point))) + (end-of-line) + (if (zerop (geiser-syntax--nesting-level)) + (comint-send-input) + (goto-char p) + (geiser-repl--newline-and-indent)))) + (define-derived-mode geiser-repl-mode comint-mode "REPL" "Major mode for interacting with an inferior scheme repl process. \\{geiser-repl-mode-map}" + (scheme-mode-variables) (set (make-local-variable 'mode-line-process) nil) (set (make-local-variable 'comint-use-prompt-regexp) t) (set (make-local-variable 'comint-prompt-read-only) geiser-repl-read-only-prompt-p) (set (make-local-variable 'beginning-of-defun-function) 'geiser-repl--beginning-of-defun) - (set-syntax-table scheme-mode-syntax-table) (setq geiser-eval--get-module-function 'geiser-repl--module-function) (when geiser-repl-autodoc-p (geiser-autodoc-mode 1)) (setq geiser-autodoc--inhibit-function 'geiser-con--is-debugging) (geiser-company--setup geiser-repl-company-p) + (setq geiser-smart-tab-mode-string "") + (geiser-smart-tab-mode 1) ;; enabling compilation-shell-minor-mode without the annoying highlighter (compilation-setup t)) (define-key geiser-repl-mode-map "\C-d" 'delete-char) +(define-key geiser-repl-mode-map "\C-m" 'geiser-repl--send-input) +(define-key geiser-repl-mode-map [return] 'geiser-repl--send-input) +(define-key geiser-repl-mode-map "\C-j" 'geiser-repl--newline-and-indent) (define-key geiser-repl-mode-map "\C-ck" 'geiser-repl-nuke) (define-key geiser-repl-mode-map "\C-c\C-k" 'geiser-repl-nuke) @@ -331,15 +354,21 @@ If no REPL is running, execute `run-geiser' to start a fresh one." (define-key geiser-repl-mode-map "\C-cm" 'geiser-repl--doc-module) (define-key geiser-repl-mode-map "\C-cl" 'geiser-load-file) -(define-key geiser-repl-mode-map "\M-p" 'comint-previous-matching-input-from-input) -(define-key geiser-repl-mode-map "\M-n" 'comint-next-matching-input-from-input) +(define-key geiser-repl-mode-map "\M-p" + 'comint-previous-matching-input-from-input) +(define-key geiser-repl-mode-map "\M-n" + 'comint-next-matching-input-from-input) (define-key geiser-repl-mode-map "\C-c\M-p" 'comint-previous-input) (define-key geiser-repl-mode-map "\C-c\M-n" 'comint-next-input) -(define-key geiser-repl-mode-map (kbd "TAB") 'geiser-completion--complete-symbol) -(define-key geiser-repl-mode-map (kbd "M-TAB") 'geiser-completion--complete-symbol) -(define-key geiser-repl-mode-map (kbd "M-`") 'geiser-completion--complete-module) -(define-key geiser-repl-mode-map (kbd "C-.") 'geiser-completion--complete-module) +(define-key geiser-repl-mode-map (kbd "TAB") + 'geiser-completion--complete-symbol) +(define-key geiser-repl-mode-map (kbd "M-TAB") + 'geiser-completion--complete-symbol) +(define-key geiser-repl-mode-map (kbd "M-`") + 'geiser-completion--complete-module) +(define-key geiser-repl-mode-map (kbd "C-.") + 'geiser-completion--complete-module) (define-key geiser-repl-mode-map "\M-." 'geiser-edit-symbol-at-point) (define-key geiser-repl-mode-map "\M-," 'geiser-edit-pop-edit-symbol-stack) |