[emacs] testCaseMethod → test_case_method

なぜか、Java から Ruby に書き換えていて、大文字区切り名をアンダーライン区切りに書き換える emcas のコマンドが 欲しくなり、10数年ぶりに Emacs Lisp でコマンドを書きました。

(defun c2u-name(s)
  (mapconcat
   (function (lambda(x)
	       (if (and (>= x 65) (<= x 90))
		   (format "_%c" (+ x 32))
		 (format "%c" x))))
   s "")
  )

(defun c2u-word()
  (interactive)
  (let (top botom word)
    (setq top (point))
    (forward-word 1)
    (setq botom (point))
    (setq word (buffer-substring top botom))
    (delete-region top botom)
    (insert (c2u-name word))
    )
  )

すっかり Emacs Lisp のことは忘れていたので、数時間かかってしまいました ^^;