Skip to content
Newer
Older
100644 586 lines (505 sloc) 20.3 KB
a16e888 @tavisrudd init import
authored Apr 23, 2010
1 ;;; setting up clojure/slime http://technomancy.us/126
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 17, 2011
2 (require 'dss-slime)
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
3 (require 'clojure-mode)
4 (require 'cljdoc)
a16e888 @tavisrudd init import
authored Apr 23, 2010
5
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
6 (defmacro dss/defface (name color desc &optional others)
7 `(defface ,name '((((class color)) (:foreground ,color ,@others))) ,desc :group 'faces))
8
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
9 (dss/defface dss-clojure-punctuation "#afaf5f" "Clojure punctuation")
10 (dss/defface dss-clojure-braces "#49b2c7" "Clojure braces")
11 (dss/defface dss-clojure-brackets "#49b2c7" "Clojure brackets")
12 (dss/defface dss-clojure-brackets-highlight "#49b2c7"
13 "Clojure brackets highlight" (:background "#333333"))
14 (dss/defface dss-clojure-keyword "khaki" "Clojure keywords")
15 (dss/defface dss-clojure-namespace "#c476f1" "Clojure namespace")
16 (dss/defface dss-clojure-quote "white" "Clojure quote" (:background "#333333"))
17 (dss/defface dss-clojure-backtick "brightwhite" "Clojure backtick"
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
18 (:background "#5f0000"))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
19 (dss/defface dss-clojure-java-call "#5f87ff" "Clojure Java calls")
20 (dss/defface dss-clojure-strf "bright green" "Clojure strf" (:background "#333333"))
21 (dss/defface dss-clojure-number "#b8bb00" "Clojure number")
22 (dss/defface dss-clojure-backslash "magenta" "Clojure backslash")
23
24 (dss/defface dss-clojure-function-arity
25 "khaki" "Clojure function arity"
26 (:background "#262626"))
27
28 (dss/defface dss-clojure-anon-fn-macro "magenta" "Clojure #() fn"
29 (:background "#262626"))
30
31 (dss/defface dss-clojure-regex "magenta" "Clojure regex"
32 (:background "#262626"))
33 (dss/defface dss-clojure-ignore-form "unspecified"
34 "clojure (comment) or #_ macro"
35 (:background "#262626"))
36
37 (defun dss/clojure-match-ignore-form (&optional limit)
38 (interactive)
39 (if (search-forward-regexp "\\(#_\\|(comment\\)" limit 'no-error)
40 (progn
41 (save-match-data
42 (if (looking-back "comment" (- (point) 7))
43 (dss/out-one-sexp)))
44 (set-match-data (list (car (match-data)) (scan-sexps (point) 1)))
45 (add-text-properties (car (match-data))
46 (second (match-data)) '(font-lock-multiline t))
47 t)))
48
49 (defun dss/test-clojure-fontlock ()
50 (interactive)
51 (save-excursion
52 (goto-line 60)
53 (call-interactively 'eval-defun))
54 (save-window-excursion
55 (with-current-buffer "html.clj"
56 (clojure-mode))))
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
57
58 (defun dss/clojure-add-extra-fontlock ()
59 (interactive)
60 (mapcar (lambda (x) (font-lock-add-keywords nil x))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
61 `(
62 ((dss/clojure-match-cond 0 'font-lock-keyword-face append))
63 ((dss/clojure-match-ignore-form
64 0 'dss-clojure-ignore-form append))
65 (("\\\\" . 'dss-clojure-backslash))
66 (("\\(|\\|=\\|,\\|&\\|~\\|@\\|#\\|+\\|_\\|:\\)"
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
67 . 'dss-clojure-punctuation))
68 (("#?\\^?{\\|}" . 'dss-clojure-braces))
69 (("\\[\\|\\]" . 'dss-clojure-brackets))
70 (("'" . 'dss-clojure-quote))
71 (("`\\|@\\|~" . 'dss-clojure-backtick))
72 (("[^\\w+]\\(:\\w+\\)" 1 'dss-clojure-keyword))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
73
74 ((dss/clojure-match-anan-fn-macro
75 (1 'dss-clojure-anon-fn-macro)
76 (2 'dss-clojure-anon-fn-macro)))
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
77 (("%[0-9.]*\\(([a-zA-Z0-9]*)\\)?[fdsfr]*" 0 'dss-clojure-strf prepend))
78 (("(\\(\\.[^ \n)]*\\|[^ \n)]+\\.\\|new\\)\\([ )\n]\\|$\\)"
79 1 'dss-clojure-java-call))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
80 (("\\(^\\|[ \\[({]\\)\\([0-9]+\\)" 2 'dss-clojure-number append))
81 (("#\"" 0 'dss-clojure-regex append))
82
83 ((dss/clojure-match-function-arity
84 1 'dss-clojure-function-arity prepend))
85
86 ((dss/clojure-match-core-match 0 'font-lock-keyword-face append))
87
88 ((dss/clojure-match-for-comps
89 (2 'dss-clojure-brackets-highlight)
90 (3 'dss-clojure-brackets-highlight)
91 ))
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
92 ))
93 (font-lock-fontify-buffer))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
94
767c4eb @tavisrudd rm durendal
authored Sep 18, 2011
95 ;; see https://github.com/purcell/emacs.d/blob/master/init-clojure.el
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
96 (defun dss/add-end-of-sexp-to-match-data (sexp-start-group)
97 (let ((end (scan-sexps (match-beginning sexp-start-group) 1)))
98 (set-match-data (append
99 (list (match-beginning 0))
100 (list end)
101 (cdr (cdr (match-data)))
102 (list (1- end) end)))
103 (add-text-properties (match-beginning 0) end '(font-lock-multiline t))
104 t))
105
106 (defun dss/clojure-match-anan-fn-macro (&optional limit)
107 (interactive)
108 (if (and (search-forward-regexp "\\(\\#(\\|(fn\\)" limit 'no-error)
109 (not (save-match-data (dss/in-string-p))))
110 (dss/add-end-of-sexp-to-match-data 1)))
111
112 (defun dss/clojure-match-for-comps (&optional limit)
113 (interactive)
114 (if (and
115 (search-forward-regexp "\\(for\\|doseq\\) *\\(\\[\\)" limit 'no-error)
116 (not (save-match-data (dss/in-string-p))))
117 (dss/add-end-of-sexp-to-match-data 2)))
118
119 (defun dss/clojure-match-function-arity (&optional limit)
120 (interactive)
121 (if (and
122 (search-forward-regexp " \\((\\)\\[" limit 'no-error)
123 (not (save-match-data (dss/in-string-p))))
124 (save-match-data
125 (save-excursion
126 (goto-char (match-beginning 0))
127 (= (syntax-ppss-depth (syntax-ppss)) 1)))))
128
129 ;; (defun dss/clojure-match-core-match (&optional limit)
130 ;; (interactive)
131 ;; (if (search-forward-regexp "^[ ]+\\(\\[\\)" limit 'no-error)
132 ;; (if (and (save-excursion
133 ;; (save-match-data
134 ;; (backward-char)
135 ;; (backward-up-list))
136 ;; (looking-at-p "(match"))
137 ;; t
138 ;; ;; (not (save-match-data
139 ;; ;; (save-excursion
140 ;; ;; (forward-line -1)
141 ;; ;; (back-to-indentation)
142 ;; ;; (looking-at-p "\\["))))
143 ;; )
144 ;; (dss/add-end-of-sexp-to-match-data 1))))
145
146 (defun dss/clojure-match-core-match (&optional limit)
147 (interactive)
148 (if (and (search-forward-regexp "\\((match \\|(match/match \\)" limit 'no-error)
149 (not (save-match-data (dss/in-string-p))))
150 (let* ((beg (match-beginning 0))
151 (end (scan-sexps beg 1)))
152 (save-excursion
153 (goto-char beg)
154 (dolist (pair (partition (cdr (cdr (dss/lisp-get-child-sexp-markers))) 2))
155 (dss/font-lock-propertize-char (car pair) 'dss-clojure-backtick)
156 (dss/font-lock-propertize-char
157 (1- (scan-sexps (1- (car pair)) 1)) 'dss-clojure-backtick))
158 (add-text-properties beg end '(font-lock-multiline t)))
159 t)))
160 ;;; ;;;;
161 (defun dss/clojure-match-cond (&optional limit)
162 (interactive)
163 (if (and (search-forward-regexp "\\((cond$\\|(cond \\)" limit 'no-error)
164 (not (save-match-data (dss/in-string-p))))
165 (let* ((beg (match-beginning 0))
166 (end (scan-sexps beg 1)))
167 (save-excursion
168 (goto-char beg)
169 (dolist (pair (partition (cdr (dss/lisp-get-child-sexp-markers)) 2))
170 (dss/font-lock-propertize-char (car pair) 'dss-clojure-function-arity)
171 (dss/font-lock-propertize-char
172 (1- (scan-sexps (1- (car pair)) 1)) 'dss-clojure-function-arity))
173 (add-text-properties beg end '(font-lock-multiline t)))
174 t)))
175
176 ;; inlining this function for speed:
177 ;; see: http://www.gnu.org/s/emacs/manual/html_node/elisp/Compilation-Tips.html
178 ;; this will cause problems with debugging. To debug, change defsubst -> defun.
179 (defun dss/font-lock-propertize-char (point face)
180 (with-silent-modifications
181 (add-text-properties point (1+ point)
182 `(font-lock-face ,face rear-nonsticky t))))
183
184 (defun dss/font-lock-unpropertize-char (point)
185 "Remove text properties from char at POINT."
186 (with-silent-modifications
187 (remove-text-properties point (1+ point)
188 '(font-lock-face nil rear-nonsticky nil))))
189
190 (defun dss/font-lock-unpropertize-region (start end)
191 "Remove mode faces from chars in region between START and END."
192 (save-excursion
193 (goto-char start)
194 (while (< (point) end)
195 (progn
196 (dss/font-lock-unpropertize-char (point))
197 (forward-char)))))
198
199 (defun dss/clojure-flash-sexps ()
200 (interactive)
201 (let* ((beg (save-excursion (backward-up-list) (point)))
202 (end (scan-sexps beg 1)))
203 (save-excursion
204 (goto-char beg)
205 (dolist (pair (partition (cdr (dss/lisp-get-child-sexp-markers)) 2))
206 (dss/font-lock-propertize-char (car pair) 'dss-clojure-backtick)))
207 (save-excursion (font-lock-fontify-region beg end))
208 (sit-for 2)
209 (save-excursion
210 (dss/font-lock-unpropertize-region beg end)
211 (font-lock-fontify-region beg end))))
212
213 (defun dss/lisp-get-child-sexp-markers ()
214 (save-excursion
215 (let ((start (1+ (point))))
216 (forward-sexp)
217 (backward-char)
218 (reverse (loop while (> (point) start)
219 do (backward-sexp)
220 collect (point-marker))))))
221
222 ;; (defun dss/clojure-match-core-match (&optional limit)
223 ;; (interactive)
224 ;; (if (search-forward-regexp "^[ ]+\\(\\[\\)" limit 'no-error)
225 ;; (and
226 ;; (save-excursion
227 ;; (save-match-data
228 ;; (backward-char)
229 ;; (backward-up-list))
230 ;; (add-text-properties
231 ;; (point) (match-end 0) '(font-lock-multiline t))
232 ;; (looking-at-p "(match"))
233 ;; (not (save-excursion
234 ;; (previous-line)
235 ;; (back-to-indentation)
236 ;; (looking-at-p "\\["))))))
237
238 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
239 (defun dss/clojure-ignore-form ()
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 27, 2012
240 "Inserts, toggles, or moves Clojure's #_ ignore-next-form reader macro."
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
241 (interactive)
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
242 (flet ((in-string-p () (eq 'string (syntax-ppss-context (syntax-ppss))))
243 (in-comment-p () (eq 'comment (syntax-ppss-context (syntax-ppss)))))
244 (skip-chars-forward " ")
245 (while (in-string-p)
246 (backward-char))
247 (cond
248 ;; switch from a comment to an ignore form, if paredit is enabled
249 ;; This bit might not work if mark-sexp fails inside the comment.
250 ((and (featurep 'paredit)
251 (or (looking-at-p ";") (in-comment-p))
252 (looking-at-p "[ ;]*\("))
253 (progn
254 (back-to-indentation)
255 (mark-sexp)
256 (paredit-comment-dwim)
257 (insert "#_")))
258
259 ;; if the command is repeated, move the ignore macro up a syntax level
260 ((and (equal last-command this-command)
261 (> (syntax-ppss-depth (syntax-ppss)) 0)
262 (looking-back "#_ *" (- (point) 5)))
263 (progn
264 (replace-match "")
265 (backward-up-list)
266 (insert "#_")))
267
268 ;; if the cursor is right on top of the ignore macro, remove it
269 ((looking-at-p "#_")
270 (delete-char 2))
271 ;; ditto, if in the middle of it
272 ((and (looking-at-p "_")
273 (looking-back "#"))
274 (progn (backward-char)
275 (delete-char 2)))
276
277 ;; if an outer form is already ignored, un-ignore (sic) it
278 ((save-excursion
279 (while (and (> (syntax-ppss-depth (syntax-ppss)) 0)
280 (not (looking-back "#_ *" (- (point) 10))))
281 (backward-up-list))
282 (looking-back "#_ *" (- (point) 10)))
283 (save-excursion (replace-match "")))
284 ;; else, just ignore this form
285 (t (insert "#_")))))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
286
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
287 (defun dss/slime-repl-after-pmark-p ()
288 (>= (point) slime-repl-input-start-mark))
289
290 (defmacro dss/def-alternate-key (name pred match no-match)
291 `(defun ,name ()
292 (interactive)
293 (if (,pred)
294 (call-interactively ,match)
295 (call-interactively ,no-match))))
296
297 (dss/def-alternate-key dss/slime-repl-next-input
298 dss/slime-repl-after-pmark-p
299 'slime-repl-next-input 'next-line)
300
301 (dss/def-alternate-key dss/slime-repl-previous-input
302 dss/slime-repl-after-pmark-p
303 'slime-repl-previous-input 'previous-line)
304
305 (dss/def-alternate-key dss/slime-repl-previous-matching-input
306 dss/slime-repl-after-pmark-p
307 'slime-repl-previous-matching-input 'scroll-down-command)
308
309 (dss/def-alternate-key dss/slime-repl-next-matching-input
310 dss/slime-repl-after-pmark-p
311 'slime-repl-next-matching-input 'scroll-up-command)
312
313 (define-skeleton dss/clojure-use-skeleton
314 "use skeleton"
315 nil
316 "(use '" @ - _ ")")
317
318 (dss/def-alternate-key dss/slime-repl-use
319 slime-repl-at-prompt-start-p
320 'dss/clojure-use-skeleton 'self-insert-command)
321
322
323
324 (define-skeleton dss/clojure-defun-skeleton
325 "clojure defun skeleton"
326 nil
327 "(defn " @ - " [" @ "]" \n >
328 @ _
329 ")")
330
331 (define-skeleton dss/clojure-let-skeleton
332 "let skeleton"
333 nil
334 "(let [" @ - "]" \n >
335 @ _ ")")
336
ff51742 @tavisrudd a new skeleton
authored Sep 1, 2012
337
338 (define-skeleton dss/clojure-do-skeleton
339 "A simple e-lisp progn skeleton"
340 nil
341 "(do" @ - \n >
342 @ _ ")"
343 (dss/indent-defun)
344 (back-to-indentation))
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
345 (defun dss/clojure-setup-skeletons ()
346 (interactive)
ff51742 @tavisrudd a new skeleton
authored Sep 1, 2012
347 (set (make-local-variable 'dss-progn-skeleton-func)
348 'dss/clojure-do-skeleton)
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
349 (set (make-local-variable 'dss-defun-skeleton-func)
350 'dss/clojure-defun-skeleton)
351 (set (make-local-variable 'dss-let-skeleton-func)
352 'dss/clojure-let-skeleton))
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
353
354 (defun dss/clojure-mode-hook ()
355 (interactive)
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
356 (define-key clojure-mode-map (kbd "M-'") 'dss/clojure-ignore-form)
357 (define-key clojure-mode-map (kbd "C-M-w") 'dss/indent-sexp)
ff51742 @tavisrudd a new skeleton
authored Sep 1, 2012
358
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
359 ;; (mapc (lambda (k)
360 ;; (define-key clojure-mode-map k 'dss/clojure-load-current-file))
361 ;; (list (kbd "C-x C-s") [(f12)]))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
362 (dss/install-whitespace-cleanup-hook)
363 (turn-on-auto-fill)
364 (dss/load-lineker-mode)
365 (dss/highlight-watchwords)
366 (setq mode-name "clj")
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
367 (dss/clojure-add-extra-fontlock)
368 (dss/clojure-setup-skeletons))
369
370 (add-hook 'clojure-mode-hook 'dss/clojure-mode-hook)
371
150cd7d @tavisrudd indentation tweaks
authored Sep 22, 2012
372
373 (define-clojure-indent
374 (match 1)
375 (match/match 1)
376
377 ;; crux indentation
378 (entity 'defun)
379 (events 'defun)
380 (defdomain 'defun))
381
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
382 ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
383 (setq clojure-test-ns-segment-position 1)
e33c80e @tavisrudd revert clojure-swank-command
authored Jun 1, 2012
384 (setq clojure-swank-command "~/bin/lein jack-in %s")
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
385 (defun dss/clojure-jack-in ()
386 (interactive)
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
387 (clojure-jack-in))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
388
389 (setq slime-auto-connect 'always)
390 (defun slime (&optional command coding-system)
391 "Start a lein swank server and connect to it."
392 (interactive)
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
393 (clojure-jack-in))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
394
7c9a38b @tavisrudd misc tweaks
authored Oct 31, 2011
395 (defun dss/clojure-repl-switch-to-current-ns ()
396 (interactive)
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
397 (save-buffer)
398 (slime-compile-and-load-file)
399 (let ((package (clojure-find-ns)))
400 (with-current-buffer (slime-output-buffer)
401 (let ((previouse-point (- (point) slime-repl-input-start-mark)))
402 (destructuring-bind (name prompt-string)
403 (slime-repl-shortcut-eval `(swank:set-package ,package))
404 (setf (slime-lisp-package) name)
405 (setf (slime-lisp-package-prompt-string) prompt-string)
406 (setf slime-buffer-package name)
407 (slime-repl-insert-prompt)
408 (when (plusp previouse-point)
409 (goto-char (+ previouse-point slime-repl-input-start-mark)))))))
410 ;; (slime-repl-set-package (clojure-find-ns))
411 )
412
413 ;; (import (java.io File)
414 ;; (java.net URL URLClassLoader)
415 ;; (java.lang.reflect Method))
416 ;; (defn add-to-cp [#^String jarpath]
417 ;; (let [#^URL url (.. (File. jarpath) toURI toURL)
418 ;; url-ldr-cls (. (URLClassLoader. (into-array URL [])) getClass)
419 ;; arr-cls (into-array Class [(. url getClass)])
420 ;; arr-obj (into-array Object [url])
421 ;; #^Method mthd (. url-ldr-cls getDeclaredMethod "addURL" arr-cls)]
422 ;; (doto mthd
423 ;; (.setAccessible true)
424 ;; (.invoke (ClassLoader/getSystemClassLoader) arr-obj))
425 ;; (println (format "Added %s to classpath" jarpath))))
426
427 ;; (defun dss/clojure-reset-namespace ()
428 ;; (interactive)
429 ;; (slime-interactive-eval (format
430 ;; "
431 ;; (ns dss-util)
432 ;; (defn ns-clean
433 ;; ([] (ns-clean *ns*))
434 ;; ([ns] (map (fn [v] (ns-unmap ns v)) (keys (ns-interns ns)))))
435
436 ;; (in-ns %s)
437 ;; (require 'dss-util)
438 ;; (dss-util/ns-clean)
439 ;; " (clojure-find-ns))))
440
441 (defun dss/clojure-list-namespace ()
442 (interactive)
443 (slime-interactive-eval "(keys (ns-interns *ns*))"))
444
445 (defun dss/clojure-reset-namespace ()
446 "Reloads the current Clojure namespace by first removing it and
447 then re-evaluating the slime buffer. Use this to remove old
448 symbol definitions and reset the namespace to contain only what
449 is defined in your current Emacs buffer.
450
451 "
452 (interactive)
453 (slime-interactive-eval "(map (fn [v] (ns-unmap *ns* v)) (keys (ns-interns *ns*)))")
454
455 ;; (slime-eval-buffer)
456 )
457
458 (defun dss/clojure-in-tests ()
459 (string-match "test" (clojure-find-ns)))
460
461 (defun dss/clojure-jump-between-tests-and-code ()
462 (interactive)
463 (if (dss/clojure-in-tests)
464 (clojure-test-jump-to-implementation)
465 (clojure-jump-to-test)))
466
467 (defun dss/clojure-run-tests ()
468 (interactive)
469 (save-window-excursion
470 (if (not (dss/clojure-in-tests))
471 (clojure-jump-to-test))
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
472 (clojure-test-run-tests)))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
473
474 (defun dss/clojure-load-current-file ()
475 (interactive)
476 (save-buffer)
24554f4 @tavisrudd misc tweaks (I've pushed some of this upstream to clojure-mode)
authored Jan 28, 2012
477 (if (not (string-match-p
478 "project\\.clj"
479 (buffer-file-name)))
480 (slime-compile-and-load-file)))
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
481
482 (defun dss/clojure-init-debugger ()
483 (interactive)
484 (slime-repl-eval-string "(require 'swank.cdt)"))
485
486 (defun dss/clojure-print-breakpoints ()
487 (interactive)
488 (slime-repl-eval-string "(require 'swank.cdt) (swank.cdt/print-bps)"))
489
490
491 (defun dss/clojure-set-breakpoint ()
492 (interactive)
493 (let ((ns (clojure-find-ns))
494 (func (which-function)))
495 (slime-repl-eval-string
496 (format "(require 'swank.cdt) (swank.cdt/set-bp %s/%s)" ns func))))
497
498 (defun dss/clojure-clear-breakpoints ()
499 (interactive)
500 (slime-repl-eval-string "(require 'swank.cdt) (swank.cdt/delete-all-breakpoints)"))
501
502 (defun dss/slime-repl-clear ()
503 (interactive)
504 (save-window-excursion
505 (slime-switch-to-output-buffer)
506 (slime-repl-clear-buffer)
507 (end-of-buffer)
508 (dss/sync-point-all-windows)))
509
510 (defun dss/clojure-jump-to-project ()
511 "Jump to project.clj"
512 (interactive)
513 (find-file (format "%s/project.clj"
514 (locate-dominating-file buffer-file-name "src/"))))
515
516 (defun dss/slime-repl-go ()
517 (interactive)
518 (if (one-window-p)
519 (progn
520 (split-window-horizontally)
521 (call-interactively 'other-window)
522 (switch-to-buffer (slime-output-buffer))
523 (goto-char (point-max)))
524 (slime-switch-to-output-buffer)))
7c9a38b @tavisrudd misc tweaks
authored Oct 31, 2011
525
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
526 (defun dss/slime-repl-mode-setup-map (&optional mode-map)
527 (interactive)
528 (let ((mode-map (or mode-map slime-repl-mode-map)))
529 (define-key mode-map (kbd "<down>") 'dss/slime-repl-next-input)
530 (define-key mode-map (kbd "<up>") 'dss/slime-repl-previous-input)
531 (define-key mode-map (kbd "<prior>") 'dss/slime-repl-previous-matching-input)
532 (define-key mode-map (kbd "<next>") 'dss/slime-repl-next-matching-input)
533
534 ;; (define-key mode-map (kbd "C-M-r") 'comint-history-isearch-backward)
535 ;; (define-key mode-map (kbd "C-M-s") 'comint-history-isearch-search)
7c9a38b @tavisrudd misc tweaks
authored Oct 31, 2011
536 (define-key mode-map (kbd "M-r") 'paredit-raise-sexp)
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
537
538 (define-key mode-map (kbd "M-p") 'previous-line)
539 (define-key mode-map (kbd "M-n") 'next-line)
540 (define-key mode-map (kbd "C-M-l") 'end-of-buffer)
541 (define-key mode-map "{" 'paredit-open-curly)
542 (define-key mode-map "}" 'paredit-close-curly)
7c9a38b @tavisrudd misc tweaks
authored Oct 31, 2011
543 (define-key mode-map (kbd "DEL") 'dss/paredit-backward-delete)
544
545 ;; (define-key mode-map "u" 'dss/slime-repl-use)
546 ))
a16e888 @tavisrudd init import
authored Apr 23, 2010
547
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
548 ;;; see Clementson's Blog: Clojure SLIME Mods for Java Documentation
549 ;;; http://bc.tech.coop/blog/081120.html
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
550 (setq slime-enable-evaluate-in-emacs t)
551
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 18, 2011
552 (defun dss/slime-repl-hook ()
3cd68af @tavisrudd misc clojure improvements
authored Feb 25, 2011
553 (interactive)
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 18, 2011
554
555 ;; also see
556 ;; https://github.com/technomancy/durendal/blob/master/durendal.el
557 ;; and https://github.com/tcrayford/clojure-refactoring
558 (paredit-mode 1)
559 (dss/load-slime-completion)
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
560 (dss/slime-repl-mode-setup-map)
561 (dss/clojure-setup-skeletons)
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 18, 2011
562
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
563 (when (< emacs-major-version 24)
564 (set (make-local-variable 'forward-sexp-function)
565 'clojure-forward-sexp))
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 18, 2011
566 ;; the rest is semi-copied from
567 ;; http://stackoverflow.com/questions/2474804/is-there-a-colored-repl-for-clojure
568 (set (make-local-variable 'lisp-indent-function)
569 'clojure-indent-function)
570 (set (make-local-variable 'lisp-doc-string-elt-property)
571 'clojure-doc-string-elt)
572 (font-lock-mode nil)
573 (clojure-mode-font-lock-setup)
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
574 (set-syntax-table clojure-mode-syntax-table)
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 18, 2011
575 (font-lock-mode t)
7c9a38b @tavisrudd misc tweaks
authored Oct 31, 2011
576
577 ;; (ad-activate #'slime-repl-emit)
578 ;; (ad-activate #'slime-repl-insert-prompt)
8c2253c @tavisrudd lots of extensions now that I've started using clojure
authored Aug 24, 2011
579 (set (make-local-variable 'comment-start-skip)
580 "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
b9e0680 @tavisrudd a ton of additional stuff
authored Jan 11, 2012
581 (dss/clojure-add-extra-fontlock)
582 (eldoc-mode 1))
16262d3 @tavisrudd slime and durendal config, etc.
authored Mar 18, 2011
583 (add-hook 'slime-repl-mode-hook 'dss/slime-repl-hook)
584
a16e888 @tavisrudd init import
authored Apr 23, 2010
585 (provide 'dss-clojure)
Something went wrong with that request. Please try again.