Reputation: 819
camelCase.el emacswiki has a function to un-camelcase. But It doesn't seem to work. I added that piece to the camelCase.el itself. But can't get it to work. What am I missing ? Did anyone else have the same problem ?
EDIT : I have added last two functions, one of which is the function that doesn't work
(defun camelCase-downcase-word (count)
"Make word starting at point lowercase, leaving point after word."
(interactive "*p")
(let ((start (point)))
(camelCase-forward-word count)
(downcase-region start (point))))
(defun un-camelcase-string (s &optional sep start)
"Convert CamelCase string S to lower case with word separator SEP.
Default for SEP is a hyphen \"-\".
If third argument START is non-nil, convert words after that
index in STRING."
(let ((case-fold-search nil))
(while (string-match "[A-Z]" s (or start 1))
(setq s (replace-match (concat (or sep "_")
(downcase (match-string 0 s)))
t nil s)))
(downcase s)))
(provide 'camelCase)
Upvotes: 0
Views: 121
Reputation: 14065
Other than the misleading doc-string (it actually defaults to "_", not "-" for the separator), the definition of un-camelcase-string
you provide works. Can you give us more details about how it fails and under what circumstances?
Upvotes: 1