un-camelCase代码不起作用

时间:2013-03-14 21:41:31

标签: emacs camelcasing

camelCase.el emacswiki具有un-camelcase功能。但它似乎没有用。我把那篇文章添加到了camelCase.el本身。但无法让它发挥作用。 我错过了什么?有没有其他人有同样的问题?

编辑:我添加了最后两个函数,其中一个函数不起作用

(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)

1 个答案:

答案 0 :(得分:1)

除了误导性的文档字符串(它实际上默认为“_”,而不是分隔符的“ - ”),您提供的un-camelcase-string的定义有效。你能否告诉我们更多关于它如何失败的细节以及在什么情况下?