-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkommissar.el
116 lines (100 loc) · 3.19 KB
/
kommissar.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
;; Kommissar Emacs binds
(defun eval-slime (str)
"Eval STR as Common Lisp code."
(unless (slime-current-connection)
(let ((wnd (current-window-configuration)))
(slime)
(while (not (and (slime-current-connection)
(get-buffer-window (slime-output-buffer))))
(sit-for 0.2))
(set-window-configuration wnd)))
(let (deactivate-mark)
(cadr (slime-eval `(swank:eval-and-grab-output ,str)))))
(defun kom-start ()
(interactive)
(slime-load-file "~/projects/kommissar/kommissar.lisp")
)
(defun kom-refresh ()
(interactive)
(eval-slime "(kommissar::refresh)"))
(defun kom-scroll-down ()
(interactive)
(print "scrolling down")
(eval-slime "(kommissar::scroll-down)")
)
(defun kom-scroll-up ()
(interactive)
(eval-slime "(kommissar::scroll-up)"))
(defun kom-forward-tab ()
(interactive)
(eval-slime "(kommissar::forward-tab)"))
(defun kom-backward-tab ()
(interactive)
(eval-slime "(kommissar::backward-tab)"))
(defun kom-open (url)
(eval-slime (concat "(kommissar::open-url \""
url "\" \"kommissarTab\")"))
)
(defun kom-goto-tab (regex)
(eval-slime (concatenate 'string "(kommissar::goto-tab \"" regex "\")")))
(defun kom-open-url ()
(interactive)
(eval-slime
(concat "(kommissar::open-url \""
(read-string "URL: ")"\" \"kommissarTab\")")))
(defun kom-close-tab ()
(interactive)
(eval-slime "(kommissar::close-tab \"\")"))
(defun kom-search ()
(interactive)
(eval-slime
(concat "(kommissar::open-url \"https://www.duckduckgo.com/"
(replace-regexp-in-string " " "+"
(read-from-minibuffer "search engine: "))
"\" \"googleTab\")"
))
)
(defun kom-download-page ()
(interactive)
(eval-slime
(concat "(kommissar::download-page \""
(replace-regexp-in-string " " "+"
(read-from-minibuffer
"downloading current page, target folder : "))
"\")")))
(defun google ()
(interactive) (kom-google))
(set-key "<f4>" 'kom-start)
(set-key "<f5>" 'kom-refresh)
(set-key "<f12>" 'kom-scroll-down)
(set-key "<f11>" 'kom-scroll-up)
(set-key "<f9>" 'kom-backward-tab)
(set-key "<f10>" 'kom-forward-tab)
(set-key "<home>" 'kom-google)
(defun kom-send-line () (interactive)
(beginning-of-line)
(call-interactively 'set-mark-command)
(end-of-line)
(call-interactively 'kom-send-region)
)
(defun kom-send-region (start end)
(interactive "r")
(print (buffer-substring-no-properties start end))
(eval-slime
(concat "(kommissar::ps-eval \""
(buffer-substring-no-properties
start end) "\"))"))
)
;; for interactive ParenScript development
(set-key "<f1>" 'kom-send-region)
(add-hook
'slime-connected-hook
(lambda ()
(kom-start)
))
;; pref("extensions.mozrepl.autoStart", true);
;; ^ put in "pref.js" in firefox profile directory during installer
;; (eshell-command "cp ~/emacs-tools/kommissar.lisp ~/projects/kommissar/kommissar.lisp")
;; (eshell-command "cp ~/emacs-tools/kommissar.el ~/projects/kommissar/kommissar.el")
;; (eshell-command "cp ~/emacs-tools/kommissar-js/kommissar-utils.js ~/projects/kommissar/kommissar-js/kommissar-utils.js")
;; ;; (eshell-command "cp ~/emacs-tools/testworkflow.lisp ~/projects/kommissar/testworkflow.