Skip to content

Commit 657a169

Browse files
yuhan0bbatsov
authored andcommitted
cljr-slash: refactor conditional
1 parent f50fb24 commit 657a169

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

clj-refactor.el

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,28 +1977,28 @@ command will add the corresponding require statement to the ns
19771977
form."
19781978
(interactive)
19791979
(insert "/")
1980-
(unless (or (cljr--in-map-destructuring?)
1981-
(cljr--in-ns-above-point-p)
1982-
(cljr--in-reader-literal-p))
1983-
(when-let (aliases (and cljr-magic-requires
1984-
(not (cider-in-comment-p))
1985-
(not (cider-in-string-p))
1986-
(not (cljr--in-keyword-sans-alias-p))
1987-
(clojure-find-ns)
1988-
(cljr--magic-requires-lookup-alias)))
1989-
(let ((short (cl-first aliases)))
1990-
(when-let (long (cljr--prompt-user-for "Require " (cl-second aliases)))
1991-
(when (and (not (cljr--in-namespace-declaration-p (concat ":as " short "\b")))
1992-
(or (not (eq :prompt cljr-magic-requires))
1993-
(not (> (length (cl-second aliases)) 1)) ; already prompted
1994-
(yes-or-no-p (format "Add %s :as %s to requires?" long short))))
1995-
(save-excursion
1996-
(cljr--insert-in-ns ":require")
1997-
(let ((libspec (format "[%s :as %s]" long short)))
1998-
(insert libspec)
1999-
(ignore-errors (cljr--maybe-eval-ns-form))
2000-
(cljr--indent-defun)
2001-
(cljr--post-command-message "Required %s" libspec)))))))))
1980+
(when-let (aliases (and cljr-magic-requires
1981+
(not (cljr--in-map-destructuring?))
1982+
(not (cljr--in-ns-above-point-p))
1983+
(not (cljr--in-reader-literal-p))
1984+
(not (cider-in-comment-p))
1985+
(not (cider-in-string-p))
1986+
(not (cljr--in-keyword-sans-alias-p))
1987+
(clojure-find-ns)
1988+
(cljr--magic-requires-lookup-alias)))
1989+
(let ((short (cl-first aliases)))
1990+
(when-let (long (cljr--prompt-user-for "Require " (cl-second aliases)))
1991+
(when (and (not (cljr--in-namespace-declaration-p (concat ":as " short "\b")))
1992+
(or (not (eq :prompt cljr-magic-requires))
1993+
(not (> (length (cl-second aliases)) 1)) ; already prompted
1994+
(yes-or-no-p (format "Add %s :as %s to requires?" long short))))
1995+
(save-excursion
1996+
(cljr--insert-in-ns ":require")
1997+
(let ((libspec (format "[%s :as %s]" long short)))
1998+
(insert libspec)
1999+
(ignore-errors (cljr--maybe-eval-ns-form))
2000+
(cljr--indent-defun)
2001+
(cljr--post-command-message "Required %s" libspec))))))))
20022002

20032003
(defun cljr--in-namespace-declaration-p (s)
20042004
(save-excursion

0 commit comments

Comments
 (0)