Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/slime/contrib/slime-scratch.el
990 views
1
2
(define-slime-contrib slime-scratch
3
"Imitate Emacs' *scratch* buffer"
4
(:authors "Helmut Eller <[email protected]>")
5
(:license "GPL")
6
(:on-load
7
(def-slime-selector-method ?s "*slime-scratch* buffer."
8
(slime-scratch-buffer))))
9
10
11
;;; Code
12
13
(defvar slime-scratch-mode-map
14
(let ((map (make-sparse-keymap)))
15
(set-keymap-parent map lisp-mode-map)
16
map))
17
18
(defun slime-scratch ()
19
(interactive)
20
(slime-switch-to-scratch-buffer))
21
22
(defun slime-switch-to-scratch-buffer ()
23
(set-buffer (slime-scratch-buffer))
24
(unless (eq (current-buffer) (window-buffer))
25
(pop-to-buffer (current-buffer) t)))
26
27
(defvar slime-scratch-file nil)
28
29
(defun slime-scratch-buffer ()
30
"Return the scratch buffer, create it if necessary."
31
(or (get-buffer (slime-buffer-name :scratch))
32
(with-current-buffer (if slime-scratch-file
33
(find-file slime-scratch-file)
34
(get-buffer-create (slime-buffer-name :scratch)))
35
(rename-buffer (slime-buffer-name :scratch))
36
(lisp-mode)
37
(use-local-map slime-scratch-mode-map)
38
(slime-mode t)
39
(current-buffer))))
40
41
(slime-define-keys slime-scratch-mode-map
42
("\C-j" 'slime-eval-print-last-expression))
43
44
(provide 'slime-scratch)
45
46