@@ -74,9 +74,19 @@ Any other non-nil value means to add the form without asking."
74
74
(const :tag " prompt" :prompt )
75
75
(const :tag " false" nil )))
76
76
77
- (defcustom cljr-slash-uses-suggest-libspec nil
77
+ (defcustom cljr-slash-uses-suggest-libspec t
78
78
" If t, `cljr-slash'' magic requires' functionality will use `cljr-suggest-libspec' .
79
- It's a middleware op, newer than the `namespace-aliases' op."
79
+
80
+ The `suggest-libspec' middleware operation replaces the `namespace-aliases'
81
+ operation. It incorporates the requested namespace alias, buffer and scoped
82
+ language context (clj, cljs, cljc, etc), preferred-aliases from the
83
+ `cljr-magic-require-namespaces' , with existing aliases from the project and
84
+ returns a candidate list of suitable libspec entries. This is passed to the
85
+ completion framework along with language context information to add a
86
+ require which will satisfy the alias for a given namespace.
87
+
88
+ Currently testing this flag as the default, remove associated deprecated
89
+ paths once this flag is removed."
80
90
:type 'boolean
81
91
:safe #'booleanp )
82
92
@@ -234,8 +244,7 @@ at `cider-jack-in' time."
234
244
:type 'boolean
235
245
:safe #'booleanp )
236
246
237
- ; ; TODO: remove after `cljr--clj-context-p' is deprecated by enabling
238
- ; ; `cljr-slash-uses-suggest-libspec' .
247
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
239
248
(defcustom cljr-assume-language-context nil
240
249
" If set to `clj' or `cljs' ,
241
250
clj-refactor will use that value in situations where the language context is ambiguous.
@@ -1909,11 +1918,11 @@ but removes # in front of function literals and sets."
1909
1918
1910
1919
; ; ------ magic requires -------
1911
1920
1921
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
1912
1922
(defun cljr--magic-requires-re ()
1913
1923
(regexp-opt (seq-map 'car cljr-magic-require-namespaces)))
1914
1924
1915
- ; ; TODO: remove after `cljr--get-aliases-from-middleware' is deprecated by
1916
- ; ; enabling `cljr-slash-uses-suggest-libspec' .
1925
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
1917
1926
(defun cljr--clj-context-p ()
1918
1927
" Is point in a clj context?"
1919
1928
(or (cljr--clj-file-p)
@@ -1973,12 +1982,14 @@ context. Valid outputs include, but are not limited to `:clj',
1973
1982
(defun cljr--aget (map key )
1974
1983
(cdr (assoc key map)))
1975
1984
1985
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
1976
1986
(defcustom cljr-suggest-namespace-aliases t
1977
1987
" If `t' , `namespace-aliases' and `cljr-slash' will take into account suggested namespace aliases,
1978
1988
following this convention: `https://stuartsierra.com/2015/05/10/clojure-namespace-aliases' ."
1979
1989
:group 'cljr
1980
1990
:type 'boolean )
1981
1991
1992
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
1982
1993
(defun cljr--call-middleware-for-namespace-aliases ()
1983
1994
(thread-first " namespace-aliases"
1984
1995
cljr--ensure-op-supported
@@ -2055,6 +2066,7 @@ is not set to `:prompt'."
2055
2066
; ; this is like seq-first, but compatible with older Emacsen:
2056
2067
(seq-elt candidates 0 ))))
2057
2068
2069
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
2058
2070
(defun cljr--get-aliases-from-middleware ()
2059
2071
(when-let (aliases (cljr--call-middleware-for-namespace-aliases))
2060
2072
(if (cljr--clj-context-p)
@@ -2077,7 +2089,7 @@ is not set to `:prompt'."
2077
2089
'(re-search-forward " [0-9`':#]*" nil t ))
2078
2090
(1- (point ))))
2079
2091
2080
- ; ; TODO: deprecated after enabling `cljr-slash-uses-suggest-libspec'
2092
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
2081
2093
(defun cljr--magic-requires-lookup-alias (short )
2082
2094
" Generate a mapping from alias to candidate namespaces.
2083
2095
@@ -2161,14 +2173,14 @@ to the ns form."
2161
2173
(clojure-find-ns)
2162
2174
(cljr--unresolved-alias-ref (cljr--ns-alias-at-point))))
2163
2175
(if cljr-slash-uses-suggest-libspec
2164
- ; ; New path creates suggestions from `suggest-libspec' middleware op
2176
+ ; ; creates suggestions from `suggest-libspec' middleware op
2165
2177
(when-let (libspec
2166
2178
(thread-first alias-ref
2167
2179
(cljr--call-middleware-suggest-libspec (cljr--language-context-at-point))
2168
2180
cljr--prompt-or-select-libspec))
2169
2181
; ; only insert a require if a candidate exists and was selected
2170
2182
(cljr--insert-require-libspec libspec))
2171
- ; ; Old path creates suggestions from `namespace-aliases' middleware op
2183
+ ; ; Deprecated, creates suggestions from `namespace-aliases' middleware op
2172
2184
(when-let (aliases (cljr--magic-requires-lookup-alias alias-ref))
2173
2185
(let ((short (cl-first aliases))
2174
2186
; ; Ensure it's a list (and not a vector):
@@ -2181,6 +2193,7 @@ to the ns form."
2181
2193
(yes-or-no-p (format " Add %s :as %s to requires? " long short))))
2182
2194
(cljr--insert-require-libspec (format " [%s :as %s ] " long short)))))))))
2183
2195
2196
+ ; ; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
2184
2197
(defun cljr--in-namespace-declaration-p (s )
2185
2198
(save-excursion
2186
2199
(cljr--goto-ns)
0 commit comments