-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshimmers.el
31 lines (26 loc) · 1.2 KB
/
shimmers.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
;; inspired by https://github.com/nextjournal/clerk/blob/main/clerk.el
(require 'cider-client)
(require 'cider-eval)
(require 'cider-mode)
;; Is there a way to switch-to or open tab?
(defun shimmers-visit-tests ()
(interactive)
(shell-command "xdg-open http://localhost:9500/figwheel-extra-main/tests"))
;; TODO: add function to force reload or reset atoms?
;; also consider adding support for reloading with same seed
;; and consider keeping track of last active ns so that binding works from library code?
(defun shimmers-visit-sketch ()
"Direct browser to (re)load the associated sketch for the current namespace."
(interactive)
(let ((ns (cider-current-ns)))
(if (and ns (string-match-p "shimmers\\.sketches\\..*" ns))
(progn
(message (format "Visiting sketch %s" ns))
(cider-interactive-eval
(format "(if-let [page (:parameters (shimmers.core/visit! '%s))]
[(keyword (get-in page [:path :name]))
(get-in page [:query :seed])]
\"Unknown sketch %s!\")" ns ns)))
(error (format "Namespace %s is not a sketch." ns)))))
(define-key cider-mode-map (kbd "<f8>") #'shimmers-visit-sketch)
(provide 'shimmers)