Skip to content

Commit 408ab1f

Browse files
eggsyntaxexpez
authored andcommitted
[Fix #394] Let user specify default language context
When the user enters an apparent namespace like `somelib/`, and the language context is ambiguous, clj-refactor creates a popup asking the user to specify whether the context is "clj" or "cljs". This change allows the user to specify a language context which should be assumed, so that clj-refactor will choose that context in ambiguous cases rather than creating a popup. Default behavior is still to create the popup; this change only creates a variable that lets the user override that behavior.
1 parent f5295df commit 408ab1f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- [#394](https://github.com/clojure-emacs/clj-refactor.el/issues/394) New config option `cljr-assume-language-context`: by default, when clj-refactor encounters an ambiguous context (clj vs cljs) it creates a popup asking user which context is meant. If this option is changed to "clj" or "cljs", clj-refactor will use that as the assumed context in such ambigous cases.
6+
37
## 2.3.1
48

59
- [#363](https://github.com/clojure-emacs/clj-refactor.el/issues/363) cljr-favor-prefix-notation by default is set to false

clj-refactor.el

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ won't run if there is a broken namespace in the project."
221221
:group 'cljr
222222
:type 'boolean)
223223

224+
(defcustom cljr-assume-language-context nil
225+
"If set to 'clj' or 'cljs', clj-refactor will use that value in situations
226+
where the language context is ambiguous. If set to nil, a popup will be
227+
created in each ambiguous case asking user to choose language context."
228+
:group 'cljr
229+
:type 'string)
230+
224231
(defcustom cljr-libspec-whitelist
225232
'("^cljsns" "^slingshot.test" "^monger.joda-time" "^monger.json")
226233
"List of regexes to match against libspec names which shouldn't be pruned.
@@ -1828,11 +1835,15 @@ FEATURE is either :clj or :cljs."
18281835
"Is point in a clj context?"
18291836
(or (cljr--clj-file-p)
18301837
(when (cljr--cljc-file-p)
1831-
(if (cljr--point-in-reader-conditional-p)
1832-
(cljr--point-in-reader-conditional-branch-p :clj)
1833-
(string-equal (cljr--prompt-user-for "Language context at point? "
1834-
(list "clj" "cljs"))
1835-
"clj")))))
1838+
(cond
1839+
((cljr--point-in-reader-conditional-p)
1840+
(cljr--point-in-reader-conditional-branch-p :clj))
1841+
(cljr-assume-language-context
1842+
(string-equal cljr-assume-language-context "clj"))
1843+
(t
1844+
(string-equal (cljr--prompt-user-for "Language context at point? "
1845+
(list "clj" "cljs"))
1846+
"clj"))))))
18361847

18371848
(defun cljr--aget (map key)
18381849
(cdr (assoc key map)))

0 commit comments

Comments
 (0)