Skip to content

Instantly share code, notes, and snippets.

@k-bx
Created May 7, 2012 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-bx/2627879 to your computer and use it in GitHub Desktop.
Save k-bx/2627879 to your computer and use it in GitHub Desktop.
(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)))
# -*- mode: snippet -*-
# key: ut
# name: ut
# expand-env: ((yas/indent-line 'fixed))
# --
class Test${1:Foo}(BaseTestCase):
def setUp(self):
super(Test$1, self).setUp()
def tearDown(self):
super(Test$1, self).tearDown()
def test_should_${1:$(un-camelcase-string text "_")}(self):
$2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment