Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (progn
- (defun camel-case-p (s)
- (let ((case-fold-search nil))
- (not (split-string s "[A-Z][a-z0-9]*" t))))
- (defun camel-case-to-lower-underscore (s)
- (if (camel-case-p s)
- (let ((case-fold-search nil))
- (downcase (replace-regexp-in-string "\\([a-z0-9]\\)\\([A-Z]\\)" "\\1_\\2" s)))
- (message "Not a CamelCase string.")))
- (defun camel-case-to-upper-underscore (s)
- (if (camel-case-p s)
- (let ((case-fold-search nil))
- (upcase (replace-regexp-in-string "\\([a-z0-9]\\)\\([A-Z]\\)" "\\1_\\2" s)))
- (message "Not a CamelCase string.")))
- (defun replace-various-conventions (s1 s2)
- "doc here"
- (interactive "MReplace variable: \nMReplace variable with: ")
- (if (and (camel-case-p s1) (camel-case-p s2))
- (save-excursion
- (let ((case-fold-search nil)
- (replace-list
- (list
- (list s1 s2)
- (list (camel-case-to-upper-underscore s1) (camel-case-to-upper-underscore s2))
- (list (camel-case-to-lower-underscore s1) (camel-case-to-lower-underscore s2)))))
- (mapcar (lambda (list)
- (goto-char (point-min))
- (perform-replace (car list) (cadr list) nil nil nil (point-min) (point-max)))
- replace-list)
- )
- )
- (message "Either %s or %s is not in CamelCase." s1 s2)
- )
- )
Add Comment
Please, Sign In to add comment