Skip to content

Commit 7a0005e

Browse files
committed
1 parent 9f3ec9f commit 7a0005e

5 files changed

+39
-38
lines changed

doc/clojure.org

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ Secondly, the namespace isn't actully polluted. These "shadow" bindings are stor
6464
single dictionary variable in the current namespace called =shadows=. And when you call ~e~ on
6565
the third expression =(partition 2 x2)=, this is what =lispy.el= passes to the middleware:
6666
#+begin_src clojure
67-
(lispy-clojure/reval
67+
(lispy.clojure/reval
6868
"(partition 2 x2)"
6969
"[x1 (range 10)\n x2 (map #(* %) x1)\n x3 (partition 2 x2)]"
7070
"test.clj" 1)
7171
#+end_src
7272

7373
which expands to (I used ~xj~ and ~2e~ to eval and insert all those comments in place):
7474
#+begin_src clojure
75-
(ns lispy-clojure)
75+
(ns lispy.clojure)
7676

7777
(let [x1 (range 10)
7878
x2 (map #(* % %) x1)
@@ -111,7 +111,7 @@ which expands to (I used ~xj~ and ~2e~ to eval and insert all those comments in
111111
;; =>
112112
;; (clojure.core/let
113113
;; [x3 (partition 2 x2)]
114-
;; (lispy-clojure/shadow-def 'x3 x3)
114+
;; (lispy.clojure/shadow-def 'x3 x3)
115115
;; {:x3 x3})
116116
]
117117
(eval `(with-shadows
@@ -120,28 +120,28 @@ which expands to (I used ~xj~ and ~2e~ to eval and insert all those comments in
120120
(catch Exception ~'e
121121
(clojure.core/str "error: " ~ 'e))))
122122
;; =>
123-
;; (lispy-clojure/with-shadows
123+
;; (lispy.clojure/with-shadows
124124
;; (try
125125
;; (do
126126
;; (clojure.core/let
127127
;; [x3 (partition 2 x2)]
128-
;; (lispy-clojure/shadow-def 'x3 x3)
128+
;; (lispy.clojure/shadow-def 'x3 x3)
129129
;; {:x3 x3}))
130130
;; (catch java.lang.Exception e (clojure.core/str "error: " e))))
131131
)
132132
;; => {:x3 ((0 1) (4 9) (16 25) (36 49) (64 81))}
133133
))
134134
#+end_src
135135

136-
And finally, the expansion =lispy-clojure/with-shadows= is passed to =eval=:
136+
And finally, the expansion =lispy.clojure/with-shadows= is passed to =eval=:
137137
#+begin_src clojure
138-
(let* [x1 ((lispy-clojure/shadow-map) "x1")
139-
x2 ((lispy-clojure/shadow-map) "x2")]
138+
(let* [x1 ((lispy.clojure/shadow-map) "x1")
139+
x2 ((lispy.clojure/shadow-map) "x2")]
140140
(try
141141
(do
142142
(clojure.core/let
143143
[x3 (partition 2 x2)]
144-
(lispy-clojure/shadow-def
144+
(lispy.clojure/shadow-def
145145
(quote x3)
146146
x3)
147147
{:x3 x3}))
@@ -153,5 +153,5 @@ And finally, the expansion =lispy-clojure/with-shadows= is passed to =eval=:
153153

154154
Here's a quick way to clean up all shadow variables:
155155
#+begin_src clojure
156-
(lispy-clojure/shadow-unmap *ns*)
156+
(lispy.clojure/shadow-unmap *ns*)
157157
#+end_src

le-clojure.el

+21-20
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
((lispy--clojure-middleware-loaded-p)
8484
(format (if (memq this-command '(special-lispy-eval
8585
special-lispy-eval-and-insert))
86-
"(lispy-clojure/pp (lispy-clojure/reval %S %S :file %S :line %S))"
87-
"(lispy-clojure/reval %S %S :file %S :line %S)")
86+
"(lispy.clojure/pp (lispy.clojure/reval %S %S :file %S :line %S))"
87+
"(lispy.clojure/reval %S %S :file %S :line %S)")
8888
e-str
8989
(condition-case nil
9090
(let ((deactivate-mark nil))
@@ -167,7 +167,7 @@ Add the standard output to the result."
167167
(kill-new f-str))
168168
((and (eq current-prefix-arg 0)
169169
(lispy--eval-clojure-cider
170-
"(lispy-clojure/shadow-unmap *ns*)")
170+
"(lispy.clojure/shadow-unmap *ns*)")
171171
nil))
172172
(t
173173
(unless (lispy--clojure-middleware-loaded-p)
@@ -182,7 +182,7 @@ Add the standard output to the result."
182182
(and (stringp add-output)
183183
(lispy--eval-clojure-handle-ns add-output))
184184
(let* (pp
185-
(stra (if (setq pp (string-match "\\`(lispy-clojure/\\(pp\\|reval\\)" str))
185+
(stra (if (setq pp (string-match "\\`(lispy.clojure/\\(pp\\|reval\\)" str))
186186
str
187187
(format "(do %s)" str)))
188188
(res (lispy--eval-nrepl-clojure stra lispy--clojure-ns))
@@ -283,7 +283,7 @@ Add the standard output to the result."
283283
(str (format "(do %s)"
284284
(mapconcat
285285
(lambda (x)
286-
(format "(lispy-clojure/shadow-def '%s %s)" (car x) (cadr x)))
286+
(format "(lispy.clojure/shadow-def '%s %s)" (car x) (cadr x)))
287287
(nrepl-dict-get cider--debug-mode-response "locals")
288288
"\n"))))
289289
(catch 'exit
@@ -300,7 +300,7 @@ Return 'special or 'keyword appropriately.
300300
Otherwise try to resolve in current namespace first.
301301
If it doesn't work, try to resolve in all available namespaces."
302302
(let ((str (lispy--eval-clojure-cider
303-
(format "(lispy-clojure/resolve-sym '%s)" symbol))))
303+
(format "(lispy.clojure/resolve-sym '%s)" symbol))))
304304
(cond
305305
(lispy--clojure-errorp
306306
(user-error str))
@@ -330,7 +330,7 @@ If it doesn't work, try to resolve in all available namespaces."
330330
((eq sym 'special)
331331
(read
332332
(lispy--eval-clojure-cider
333-
(format "(lispy-clojure/arglist '%s)" symbol))))
333+
(format "(lispy.clojure/arglist '%s)" symbol))))
334334
((eq sym 'keyword)
335335
(list "[map]"))
336336
((eq sym 'undefined)
@@ -340,7 +340,7 @@ If it doesn't work, try to resolve in all available namespaces."
340340
(t
341341
(read
342342
(lispy--eval-clojure-cider
343-
(format "(lispy-clojure/arglist '%s)" symbol)))))))))
343+
(format "(lispy.clojure/arglist '%s)" symbol)))))))))
344344

345345
(defun lispy--clojure-args (symbol)
346346
"Return a pretty string with arguments for SYMBOL.
@@ -389,7 +389,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
389389
(defvar cider-jdk-src-paths)
390390

391391
(defun lispy-cider-load-file (filename)
392-
(let ((ns-form (cider-ns-form)))
392+
(let ((ns-form (cider-ns-form)))
393393
(cider-map-repls :auto
394394
(lambda (connection)
395395
(when ns-form
@@ -431,7 +431,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
431431
(lispy--eval-clojure-cider sources-expr)))
432432
(when lispy-clojure-middleware-tests
433433
(lispy-message
434-
(lispy--eval-clojure-cider "(lispy-clojure/run-lispy-tests)")))))))
434+
(lispy--eval-clojure-cider "(lispy.clojure/run-lispy-tests)")))))))
435435

436436
(defun lispy-flatten--clojure (_arg)
437437
"Inline a Clojure function at the point of its call."
@@ -450,7 +450,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
450450
(lispy--eval-clojure-cider
451451
(format "(macroexpand '%s)" str))
452452
(lispy--eval-clojure-cider
453-
(format "(lispy-clojure/flatten-expr '%s)" str)))))
453+
(format "(lispy.clojure/flatten-expr '%s)" str)))))
454454
(goto-char (car bnd))
455455
(delete-region (car bnd) (cdr bnd))
456456
(insert result)
@@ -461,7 +461,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
461461
(defun lispy--clojure-debug-step-in ()
462462
"Inline a Clojure function at the point of its call."
463463
(lispy--clojure-detect-ns)
464-
(let* ((e-str (format "(lispy-clojure/debug-step-in\n'%s)"
464+
(let* ((e-str (format "(lispy.clojure/debug-step-in\n'%s)"
465465
(lispy--string-dwim)))
466466
(str (substring-no-properties
467467
(lispy--eval-clojure-cider e-str))))
@@ -495,7 +495,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
495495
"Goto SYMBOL."
496496
(lispy--clojure-detect-ns)
497497
(let* ((r (read (lispy--eval-clojure-cider
498-
(format "(lispy-clojure/location '%s)" symbol))))
498+
(format "(lispy.clojure/location '%s)" symbol))))
499499
(url (car r))
500500
(line (cadr r))
501501
archive)
@@ -518,7 +518,8 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
518518

519519
(defun lispy-clojure-complete-at-point ()
520520
(cond ((lispy-complete-fname-at-point))
521-
((and (memq major-mode lispy-clojure-modes) (lispy--clojure-process-buffer))
521+
((and (memq major-mode lispy-clojure-modes)
522+
(lispy--clojure-middleware-loaded-p))
522523
(ignore-errors
523524
(lispy--clojure-detect-ns)
524525
(let* ((bnd (or (bounds-of-thing-at-point 'symbol)
@@ -540,7 +541,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
540541
res)
541542
(cond ((and obj
542543
(setq res (lispy--eval-clojure-cider
543-
(format "(lispy-clojure/object-members %s)" obj)))
544+
(format "(lispy.clojure/object-members %s)" obj)))
544545
(null lispy--clojure-errorp))
545546
(let ((cands (read res)))
546547
(when (> (cdr bnd) (car bnd))
@@ -555,7 +556,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
555556
(thing-at-point 'symbol t)))
556557
(cands (read (lispy--eval-clojure-cider
557558
(format
558-
"(lispy-clojure/complete %S)"
559+
"(lispy.clojure/complete %S)"
559560
prefix))))
560561
(len (1+ (length prefix)))
561562
(candsa (mapcar (lambda (s) (substring s len)) cands)))
@@ -566,7 +567,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
566567
(let* ((prefix (lispy--string-dwim bnd))
567568
(res (lispy--eval-clojure-cider
568569
(format
569-
"(lispy-clojure/complete %S)"
570+
"(lispy.clojure/complete %S)"
570571
prefix)))
571572
(cands (and (null lispy--clojure-errorp) (read res))))
572573
(list (car bnd) (cdr bnd) cands)))))))))
@@ -582,7 +583,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
582583
(lispy--string-dwim)))
583584
(sig (read
584585
(lispy--eval-clojure-cider
585-
(format "(lispy-clojure/method-signature (lispy-clojure/reval \"%s\" nil) \"%s\")" object method)))))
586+
(format "(lispy.clojure/method-signature (lispy.clojure/reval \"%s\" nil) \"%s\")" object method)))))
586587
(when (> (length sig) 0)
587588
(if (string-match "\\`public \\(.*\\)(\\(.*\\))\\'" sig)
588589
(let ((name (match-string 1 sig))
@@ -596,7 +597,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
596597

597598
(defun lispy--clojure-constructor-args (symbol)
598599
(read (lispy--eval-clojure-cider
599-
(format "(lispy-clojure/ctor-args %s)" symbol))))
600+
(format "(lispy.clojure/ctor-args %s)" symbol))))
600601

601602
(defun lispy--clojure-pretty-string (str)
602603
"Return STR fontified in `clojure-mode'."
@@ -624,7 +625,7 @@ Besides functions, handles specials, keywords, maps, vectors and sets."
624625
(interactive)
625626
(let ((cands
626627
(split-string (lispy--eval-clojure-cider
627-
"(lispy-clojure/all-docs 'clojure.core)")
628+
"(lispy.clojure/all-docs 'clojure.core)")
628629
"::")))
629630
(ivy-read "var: " cands
630631
:action #'lispy-clojure-apropos-action)))

lispy-clojure-test.clj

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
(ns lispy-clojure-test
2121
(:use [clojure.test :only [is deftest]]
22-
[lispy-clojure :only [add-location-to-defn
22+
[lispy.clojure :only [add-location-to-defn
2323
add-location-to-def
2424
debug-step-in
2525
dest
@@ -82,7 +82,7 @@
8282
(=
8383
((juxt :file :line)
8484
(debug-step-in
85-
'(lispy-clojure/add-location-to-def '(def x 1) "/foo/bar.clj" 42)))
85+
'(lispy.clojure/add-location-to-def '(def x 1) "/foo/bar.clj" 42)))
8686
["/foo/bar.clj" 42])))
8787

8888
(deftest reader=-test
@@ -145,7 +145,7 @@
145145
["/foo/bar.clj" 42]))))
146146

147147
(deftest guess-intent-test
148-
(is (= (guess-intent '(defproject) nil) '(lispy-clojure/fetch-packages)))
148+
(is (= (guess-intent '(defproject) nil) '(lispy.clojure/fetch-packages)))
149149
(is (= (guess-intent 'x '[x y]) 'x))
150150
(is (= (guess-intent '*ns* '*ns*) '*ns*))
151151
(is (= (guess-intent '(+ 1 2) '[(+ 1 2) (+ 3 4) (+ 5 6)])
@@ -176,10 +176,10 @@
176176
(is (= (reval "(def x1 1)\n(+ x1 x1)" nil) 2)))
177177

178178
(deftest format-ctor-test
179-
(is (= (lispy-clojure/format-ctor "protected java.awt.Graphics2D()") "java.awt.Graphics2D.")))
179+
(is (= (lispy.clojure/format-ctor "protected java.awt.Graphics2D()") "java.awt.Graphics2D.")))
180180

181181
(deftest read-string-all-test
182-
(is (= (lispy-clojure/read-string-all "(foo) (bar) \"baz\"")
182+
(is (= (lispy.clojure/read-string-all "(foo) (bar) \"baz\"")
183183
'[(foo) (bar) "baz"])))
184184

185185
(clojure.test/run-tests 'lispy-clojure-test)

lispy-clojure.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
;; For a full copy of the GNU General Public License
1818
;; see <http://www.gnu.org/licenses/>.
1919

20-
(ns lispy-clojure
20+
(ns lispy.clojure
2121
(:require [clojure.repl :as repl]
2222
[clojure.pprint]
2323
[clojure.java.io :as io]

lispy-clojure.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;;; lispy-clojure.clj --- lispy support for ClojureScript.
1+
;;; lispy-clojure.cljs --- lispy support for ClojureScript.
22

33
;; Copyright (C) 2020 Oleh Krehel
44

@@ -17,7 +17,7 @@
1717
;; For a full copy of the GNU General Public License
1818
;; see <http://www.gnu.org/licenses/>.
1919

20-
(ns lispy-clojure
20+
(ns lispy.clojure
2121
(:require [clojure.repl :as repl]
2222
[clojure.pprint]
2323
[clojure.string :as str]))

0 commit comments

Comments
 (0)