@@ -2183,9 +2183,10 @@ FEATURE is either :clj or :cljs."
2183
2183
(defun cljr--magic-requires-lookup-alias ()
2184
2184
" Return (alias (ns.candidate1 ns.candidate1)) if we recognize
2185
2185
the alias in the project."
2186
- (let ((short (buffer-substring-no-properties
2187
- (cljr--point-after 'paredit-backward )
2188
- (1- (point )))))
2186
+ (let ((short (->> (buffer-substring-no-properties
2187
+ (cljr--point-after 'paredit-backward )
2188
+ (1- (point )))
2189
+ (s-chop-prefix " ::" ))))
2189
2190
(unless (or (cljr--resolve-alias short)
2190
2191
(cljr--is-global-alias short))
2191
2192
(-if-let* ((aliases (ignore-errors (cljr--get-aliases-from-middleware)))
@@ -2198,6 +2199,12 @@ the alias in the project."
2198
2199
(-when-let (long (cljr--aget cljr-magic-require-namespaces short))
2199
2200
(list short (list long))))))))
2200
2201
2202
+ (defun cljr--in-keyword-sans-alias-p ()
2203
+ " Checks if thing at point is keyword without an alias."
2204
+ (let ((sym (cider-symbol-at-point)))
2205
+ (and (cljr--keyword? sym)
2206
+ (not (s-matches-p " ::.+" (cljr--symbol-prefix sym))))))
2207
+
2201
2208
;;;### autoload
2202
2209
(defun cljr-slash ()
2203
2210
" Inserts / as normal, but also checks for common namespace shorthands to require.
@@ -2210,6 +2217,7 @@ form."
2210
2217
(-when-let (aliases (and cljr-magic-requires
2211
2218
(not (cider-in-comment-p))
2212
2219
(not (cider-in-string-p))
2220
+ (not (cljr--in-keyword-sans-alias-p))
2213
2221
(clojure-find-ns)
2214
2222
(cljr--magic-requires-lookup-alias)))
2215
2223
(let ((short (first aliases)))
@@ -3491,7 +3499,7 @@ argument of a `reduce', the defn will take two arguments.
3491
3499
3492
3500
See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-example"
3493
3501
(interactive )
3494
- (while (cljr--is- keyword? (car (cljr--extract-sexp-as-list)))
3502
+ (while (cljr--keyword? (car (cljr--extract-sexp-as-list)))
3495
3503
(paredit-backward-up))
3496
3504
(let* ((sexp-forms* (cljr--extract-sexp-as-list))
3497
3505
(fn-name (car sexp-forms*))
@@ -3572,7 +3580,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
3572
3580
(defun cljr--create-fn-from-update (args path )
3573
3581
(let ((keyfn (cadr args)))
3574
3582
(cljr--insert-example-fn (cider-symbol-at-point)
3575
- (if (cljr--is- keyword? keyfn)
3583
+ (if (cljr--keyword? keyfn)
3576
3584
(list (s-chop-prefix " :" keyfn))
3577
3585
(list 0 ))
3578
3586
path)))
@@ -3582,7 +3590,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
3582
3590
(paredit-backward-down)
3583
3591
(cider-symbol-at-point))))
3584
3592
(cljr--insert-example-fn (cider-symbol-at-point)
3585
- (if (cljr--is- keyword? last-path-entry)
3593
+ (if (cljr--keyword? last-path-entry)
3586
3594
(list (s-chop-prefix " :" last-path-entry))
3587
3595
(list 0 ))
3588
3596
path)))
@@ -3603,7 +3611,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
3603
3611
(making-comparator? (and (string= fn-name (cadr args))
3604
3612
(= 3 (length args))))
3605
3613
(param-name (if making-comparator?
3606
- (when (cljr--is- keyword? (car args))
3614
+ (when (cljr--keyword? (car args))
3607
3615
(s-chop-prefix " :" (car args)))
3608
3616
(-when-let (coll-name (cljr--guess-param-name (-last-item args)))
3609
3617
(singularize-string coll-name)))))
@@ -3642,8 +3650,8 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
3642
3650
(buffer-substring (point-min ) (point-max )))
3643
3651
s))
3644
3652
3645
- (defun cljr--is- keyword? (s )
3646
- (s-matches? " ^:[^0-9:[{(\" ][^[{(\" ]*$"
3653
+ (defun cljr--keyword? (s )
3654
+ (s-matches? " ^::? [^0-9:[{(\" ][^[{(\" ]*$"
3647
3655
(s-replace " \n " " " s)))
3648
3656
3649
3657
(defun cljr--symbol? (s )
@@ -3745,7 +3753,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
3745
3753
(paredit-forward 3 )
3746
3754
(paredit-backward-down)
3747
3755
(cider-symbol-at-point))))
3748
- (when (cljr--is- keyword? last-path-entry)
3756
+ (when (cljr--keyword? last-path-entry)
3749
3757
(s-chop-prefix " :" last-path-entry))))
3750
3758
3751
3759
(defun cljr--find-param-name-from-get (form )
@@ -3754,7 +3762,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
3754
3762
(paredit-forward 2 )
3755
3763
(cljr--skip-past-whitespace-and-comments)
3756
3764
(cljr--extract-sexp))))
3757
- (when (cljr--is- keyword? key)
3765
+ (when (cljr--keyword? key)
3758
3766
(s-chop-prefix " :" key))))
3759
3767
3760
3768
(defun cljr--insert-example-fn (name args path )
0 commit comments