2013-03-14 116 views
0

camelCase.el emacswiki有一個un-camelcase函數。但它似乎並不奏效。我把這件作品添加到了camelCase.el本身。但不能讓它工作。 我錯過了什麼?其他人有沒有同樣的問題?un-camelCase代碼不能正常工作

編輯:我還有最後增加了兩個功能,其中之一是不工作

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

向我們顯示代碼。 – phils 2013-03-14 22:53:05

回答

1

除了誤導DOC字符串(它實際上默認功能爲「_」,而不是「 - 「爲分隔符),您提供的作品的定義爲un-camelcase-string。你能否給我們提供更多關於它在哪些情況下失敗的細節?

+0

是的,我改變了。 當我有一個用駝峯格式寫的cpp文件。我使用這個函數將一個變量轉換爲谷歌風格的大小寫。我已嘗試啓用camelcase模式並禁用 無論是選擇該詞還是未選擇該詞。當我做M-X時,我無法得到這個函數來顯示使用 – navderm 2013-03-15 18:28:03

+0

只有命令(以'(交互式)'聲明開始的函數)可用於'M-x'。代碼中的 – phils 2013-03-15 22:44:32

+0

,第三個參數是非可選的。我如何提供。你能告訴我你是如何使用這個功能的嗎? 我添加了交互功能,可以爲同一個 – navderm 2013-03-16 02:54:08