Skip to content

Commit 05e90bd

Browse files
dgtizedvemv
authored andcommitted
Enable cljr-slash-uses-suggest-libspec by default
Also mark functions that will be deprecated once suggest-libspec is the only path.
1 parent b476345 commit 05e90bd

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
* [#554](https://github.com/clojure-emacs/clj-refactor.el/pull/554): Enable `cljr-slash-uses-suggest-libspec` by default
6+
57
## 3.10.0
68

79
* [#552](https://github.com/clojure-emacs/clj-refactor.el/issues/552): support TRAMP connections.

clj-refactor.el

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,19 @@ Any other non-nil value means to add the form without asking."
7474
(const :tag "prompt" :prompt)
7575
(const :tag "false" nil)))
7676

77-
(defcustom cljr-slash-uses-suggest-libspec nil
77+
(defcustom cljr-slash-uses-suggest-libspec t
7878
"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."
8090
:type 'boolean
8191
:safe #'booleanp)
8292

@@ -234,8 +244,7 @@ at `cider-jack-in' time."
234244
:type 'boolean
235245
:safe #'booleanp)
236246

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'
239248
(defcustom cljr-assume-language-context nil
240249
"If set to `clj' or `cljs',
241250
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."
19091918

19101919
;; ------ magic requires -------
19111920

1921+
;; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
19121922
(defun cljr--magic-requires-re ()
19131923
(regexp-opt (seq-map 'car cljr-magic-require-namespaces)))
19141924

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'
19171926
(defun cljr--clj-context-p ()
19181927
"Is point in a clj context?"
19191928
(or (cljr--clj-file-p)
@@ -1973,12 +1982,14 @@ context. Valid outputs include, but are not limited to `:clj',
19731982
(defun cljr--aget (map key)
19741983
(cdr (assoc key map)))
19751984

1985+
;; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
19761986
(defcustom cljr-suggest-namespace-aliases t
19771987
"If `t', `namespace-aliases' and `cljr-slash' will take into account suggested namespace aliases,
19781988
following this convention: `https://stuartsierra.com/2015/05/10/clojure-namespace-aliases'."
19791989
:group 'cljr
19801990
:type 'boolean)
19811991

1992+
;; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
19821993
(defun cljr--call-middleware-for-namespace-aliases ()
19831994
(thread-first "namespace-aliases"
19841995
cljr--ensure-op-supported
@@ -2055,6 +2066,7 @@ is not set to `:prompt'."
20552066
;; this is like seq-first, but compatible with older Emacsen:
20562067
(seq-elt candidates 0))))
20572068

2069+
;; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
20582070
(defun cljr--get-aliases-from-middleware ()
20592071
(when-let (aliases (cljr--call-middleware-for-namespace-aliases))
20602072
(if (cljr--clj-context-p)
@@ -2077,7 +2089,7 @@ is not set to `:prompt'."
20772089
'(re-search-forward "[0-9`':#]*" nil t))
20782090
(1- (point))))
20792091

2080-
;; TODO: deprecated after enabling `cljr-slash-uses-suggest-libspec'
2092+
;; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
20812093
(defun cljr--magic-requires-lookup-alias (short)
20822094
"Generate a mapping from alias to candidate namespaces.
20832095
@@ -2161,14 +2173,14 @@ to the ns form."
21612173
(clojure-find-ns)
21622174
(cljr--unresolved-alias-ref (cljr--ns-alias-at-point))))
21632175
(if cljr-slash-uses-suggest-libspec
2164-
;; New path creates suggestions from `suggest-libspec' middleware op
2176+
;; creates suggestions from `suggest-libspec' middleware op
21652177
(when-let (libspec
21662178
(thread-first alias-ref
21672179
(cljr--call-middleware-suggest-libspec (cljr--language-context-at-point))
21682180
cljr--prompt-or-select-libspec))
21692181
;; only insert a require if a candidate exists and was selected
21702182
(cljr--insert-require-libspec libspec))
2171-
;; Old path creates suggestions from `namespace-aliases' middleware op
2183+
;; Deprecated, creates suggestions from `namespace-aliases' middleware op
21722184
(when-let (aliases (cljr--magic-requires-lookup-alias alias-ref))
21732185
(let ((short (cl-first aliases))
21742186
;; Ensure it's a list (and not a vector):
@@ -2181,6 +2193,7 @@ to the ns form."
21812193
(yes-or-no-p (format "Add %s :as %s to requires?" long short))))
21822194
(cljr--insert-require-libspec (format "[%s :as %s]" long short)))))))))
21832195

2196+
;; TODO: deprecated by `cljr-slash-uses-suggest-libspec'
21842197
(defun cljr--in-namespace-declaration-p (s)
21852198
(save-excursion
21862199
(cljr--goto-ns)

0 commit comments

Comments
 (0)