-
Notifications
You must be signed in to change notification settings - Fork 5
/
shampoo-tools.el
69 lines (59 loc) · 2.08 KB
/
shampoo-tools.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;;; shampoo-tools.el --- Shampoo Worskspace and Transcript
;;
;; Copyright (C) 2010 - 2012 Dmitry Matveev <[email protected]>
;;
;; This software is released under terms of the MIT license,
;; please refer to the LICENSE file for details.
(eval-when-compile (require 'cl))
(require 'shampoo-modes)
(require 'shampoo-state)
(define-derived-mode shampoo-workspace-mode
text-mode "Shampoo workspace mode"
(set (make-local-variable 'font-lock-defaults)
shampoo-smalltalk-font-lock-keywords-list)
(set-syntax-table shampoo-smalltalk-mode-syntax-table))
(defun shampoo-do-it (from to)
(interactive "r")
(shampoo-send-message
(shampoo-make-eval-rq
:id (shampoo-give-id)
:type "DoIt"
:code (buffer-substring from to))))
(defun shampoo-printit-to (buffer)
(lexical-let ((buff buffer))
(lambda (resp)
(when (not (shampoo-response-is-failure resp))
(with-current-buffer buff
(save-excursion
(insert (shampoo-response-enclosed-string resp))))))))
(defun shampoo-print-it (from to)
(interactive "r")
(let ((request-id (shampoo-give-id)))
(shampoo-subscribe
request-id
(shampoo-printit-to (current-buffer)))
(shampoo-send-message
(shampoo-make-eval-rq
:id request-id
:type "PrintIt"
:code (buffer-substring from to)))))
(define-key shampoo-workspace-mode-map "\C-c\C-d" 'shampoo-do-it)
(define-key shampoo-workspace-mode-map "\C-c\C-p" 'shampoo-print-it)
(defun shampoo-open-workspace ()
(interactive)
(let ((frame (make-frame))
(buffer (generate-new-buffer "*shampoo-workspace*")))
(with-~shampoo~
(pushnew buffer (shampoo-current-workspaces ~shampoo~)))
(raise-frame frame)
(set-window-buffer (frame-first-window frame) buffer)
(with-current-buffer buffer
(shampoo-workspace-mode)
(setq header-line-format (shampoo-make-header)))))
(defmacro do-workspaces (evar &rest body)
(destructuring-bind (var) evar
`(with-~shampoo~
(dolist (,var (shampoo-current-workspaces ~shampoo~))
,@body))))
(provide 'shampoo-tools)
;;; shampoo-tools.el ends here.