1
;;; inferior-slime.el --- Minor mode with Slime keys for comint buffers
3
;; Author: Luke Gorrie <luke@synap.se>
4
;; License: GNU GPL (same license as Emacs)
8
;; Add something like this to your .emacs:
10
;; (add-to-list 'load-path "<directory-of-this-file>")
11
;; (add-hook 'slime-load-hook (lambda () (require 'inferior-slime)))
12
;; (add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode 1)))
14
(define-minor-mode inferior-slime-mode
16
Inferior SLIME mode: The Inferior Superior Lisp Mode for Emacs.
18
This mode is intended for use with `inferior-lisp-mode'. It provides a
19
subset of the bindings from `slime-mode'.
21
\\{inferior-slime-mode-map}"
24
;; Fake binding to coax `define-minor-mode' to create the keymap
27
(add-to-list 'minor-mode-alist
29
(" Inf-Slime" slime-state-name)))
31
(defun inferior-slime-return ()
32
"Handle the return key in the inferior-lisp buffer.
33
The current input should only be sent if a whole expression has been
34
entered, i.e. the parenthesis are matched.
36
A prefix argument disables this behaviour."
38
(if (or current-prefix-arg (inferior-slime-input-complete-p))
41
(inferior-slime-indent-line)))
43
(defun inferior-slime-indent-line ()
44
"Indent the current line, ignoring everything before the prompt."
49
(goto-char (process-mark (get-buffer-process (current-buffer))))
50
(let ((inhibit-field-text-motion t))
51
(beginning-of-line 1))
53
(narrow-to-region indent-start (point-max)))
56
(defun inferior-slime-input-complete-p ()
57
"Return true if the input is complete in the inferior lisp buffer."
58
(slime-input-complete-p (process-mark (get-buffer-process (current-buffer)))
61
(defun inferior-slime-closing-return ()
62
"Send the current expression to Lisp after closing any open lists."
64
(goto-char (point-max))
66
(narrow-to-region (process-mark (get-buffer-process (current-buffer)))
68
(while (ignore-errors (save-excursion (backward-up-list 1) t))
72
(defun inferior-slime-init-keymap ()
73
(let ((map inferior-slime-mode-map))
74
(define-key map [return] 'inferior-slime-return)
75
(define-key map [(control return)] 'inferior-slime-closing-return)
76
(define-key map [(meta control ?m)] 'inferior-slime-closing-return)
77
(define-key map "\C-c\C-d" slime-doc-map)
78
(define-key map "\C-c\C-w" slime-who-map)
79
(loop for (key command . keys) in slime-keys do
80
(destructuring-bind (&key prefixed inferior &allow-other-keys) keys
82
(setq key (concat slime-prefix-key key)))
84
(define-key map key command))))))
86
(inferior-slime-init-keymap)
88
(provide 'inferior-slime)