Skip to content

Commit df7c4f1

Browse files
committed
Replace s-dashed-words
As part of the drive to replace the dependency on the functions from s.el replacing s-dashed-words with function that relies only on functions that come as part of Emacs release.
1 parent cb32710 commit df7c4f1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

clj-refactor.el

+14-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
(require 'sgml-mode)
4242
(require 'inflections)
4343
(require 'hydra)
44+
(require 'subword)
4445

4546
(defcustom cljr-add-ns-to-blank-clj-files t
4647
"If t, automatically add a ns form to new .clj files."
@@ -3365,6 +3366,17 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
33653366
(when (string-match "[^/]+$" s)
33663367
(substring s (car (match-data)) (car (cdr (match-data))))))
33673368

3369+
(defun cljr--dashed-words (s)
3370+
"Take the string S and replace all the word separators with '-'
3371+
and make the whole string lower-cased."
3372+
(with-temp-buffer
3373+
(insert s)
3374+
(goto-char (point-min))
3375+
(while (not (eobp))
3376+
(subword-forward)
3377+
(insert " "))
3378+
(mapconcat 'identity (split-string (downcase (buffer-string))) "-")))
3379+
33683380
(defun cljr--guess-param-name (form)
33693381
(let* ((prepped-form (cljr--strip-off-semantic-noops
33703382
(cljr--unwind-s form)))
@@ -3375,11 +3387,11 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-e
33753387
((cljr--keyword-lookup-p prepped-form)
33763388
(cljr--strip-keyword-ns (match-string 1 prepped-form)))
33773389
((and fn-call (string-suffix-p "." fn-call))
3378-
(s-dashed-words (car (last (split-string fn-call "\\." t)))))
3390+
(cljr--dashed-words (car (last (split-string fn-call "\\." t)))))
33793391
((and fn-call (string-prefix-p "create-" fn-call))
33803392
(string-remove-prefix "create-" fn-call))
33813393
((and fn-call (string-prefix-p ".get" fn-call))
3382-
(s-dashed-words (string-remove-prefix ".get" fn-call)))
3394+
(cljr--dashed-words (string-remove-prefix ".get" fn-call)))
33833395
((string= "get-in" fn-call)
33843396
(cljr--find-param-name-from-get-in prepped-form))
33853397
((string= "get" fn-call)

0 commit comments

Comments
 (0)