diff --git a/config.el b/config.el index aa53deb..a33c429 100644 --- a/config.el +++ b/config.el @@ -351,7 +351,7 @@ the description. This may destroy existing links, or change their targets so use (cdr bounds)) (old-name (buffer-substring-no-properties begin end))) - (message "Will rename to %s" new-name) + (message "Will rename to %s" new-name) ;; should use as-function-name here (movd (intern old-name) (intern new-name)) (delete-region begin end) (insert (s-dashed-words new-name)) @@ -361,10 +361,11 @@ the description. This may destroy existing links, or change their targets so use ;; tests are better than literate programming when you want to triangulate on the same function ;; org only shows the last return value by default, you can return a list of course, but still (defun as-function-name (candidate-name) - "Take the string and make it suitable to be a function name" - (declare (side-effect-free t)) - (candidate-name) + "Take the string and make it suitable to be a function name. Replaces space with dash and make string all lowercase." + (declare (side-effect-free t)) + (s-join "-" (mapcar 'downcase (split-string candidate-name " " t)))) +;; (s-join "-" (mapcar 'downcase (s-split-words s)))) (ert-deftest refactor-rename-should-leave-forward-slash() (should (equal (as-function-name "qwan/echo") "qwan/echo"))) @@ -372,4 +373,9 @@ the description. This may destroy existing links, or change their targets so use (ert-deftest refactor-rename-should-replace-space-with-dash() (should (equal (as-function-name "qwan/echo chamber") "qwan/echo-chamber"))) + + +(ert-deftest refactor-rename-should-replace-uppercase-with-lowercase() + (should (equal (as-function-name "Echo-chamber") + "echo-chamber"))) (ert "refactor.*")