[slime-cvs] CVS update: slime/slime.el
Luke Gorrie
lgorrie at common-lisp.net
Fri Oct 24 21:11:40 UTC 2003
Update of /project/slime/cvsroot/slime
In directory common-lisp.net:/tmp/cvs-serv1674
Modified Files:
slime.el
Log Message:
(inferior-slime-return): Command bound to RET in inferior-slime-mode:
only send the current input to Lisp if it is a complete expression (or
prefix argument is given). Two reasons: it makes the input history
contain complete expressions, and it lets us nicely indent
multiple-line inputs. (Thanks Raymond Toy for the suggestions.)
Date: Fri Oct 24 17:11:40 2003
Author: lgorrie
Index: slime/slime.el
diff -u slime/slime.el:1.56 slime/slime.el:1.57
--- slime/slime.el:1.56 Thu Oct 23 12:24:59 2003
+++ slime/slime.el Fri Oct 24 17:11:39 2003
@@ -225,6 +225,28 @@
((slime-buffer-package (":" slime-buffer-package) "")
slime-state-name))))
+(defun inferior-slime-return ()
+ "Handle the return key in the inferior-lisp buffer.
+The current input should only be sent if a whole expression has been
+entered, i.e. the parenthesis are matched.
+
+A prefix argument disables this behaviour."
+ (interactive)
+ (if (or current-prefix-arg (inferior-slime-input-complete-p))
+ (comint-send-input)
+ (insert "\n")
+ (lisp-indent-line)))
+
+(defun inferior-slime-input-complete-p ()
+ "Return true if the input is complete in the inferior lisp buffer."
+ (ignore-errors
+ (save-excursion
+ (goto-char (process-mark (get-buffer-process (current-buffer))))
+ (while (not (eobp))
+ (skip-chars-forward " \t\r\n")
+ (unless (eobp) (slime-forward-sexp)))
+ t)))
+
;;;;; Key bindings
@@ -288,7 +310,9 @@
(setq key (concat slime-prefix-key key)))
(define-key slime-mode-map key command)
(when inferior
- (define-key inferior-slime-mode-map key command)))
+ (define-key inferior-slime-mode-map key command))
+ ;; Extras..
+ (define-key inferior-slime-mode-map [return] 'inferior-slime-return))
(defun slime-init-keymaps ()
"(Re)initialize the keymaps for `slime-mode' and `inferior-slime-mode'."
More information about the slime-cvs
mailing list