underscore -> UPCASE -> CamelCase conversion of names
Emacs Lisp
Latest commit 297aaf6 Apr 20, 2017 @akicho8 committed on GitHub Merge pull request #18 from fvaresi/use-region
When region is selected consider it a single word
Permalink
Failed to load latest commit information.
test Fix string-inflection-camelcase-p Dec 14, 2016
.gitignore rm test/ert.elc Feb 27, 2015
README.org Update README.org Dec 13, 2016
string-inflection.el

README.org

underscore -> UPCASE -> CamelCase conversion of names

Configuration Example

;; Setting Example 1

(require 'string-inflection)
(global-unset-key (kbd "C-q"))
;; C-q C-u is the key bindings similar to Vz Editor.
(global-set-key (kbd "C-q C-u") 'my-string-inflection-cycle-auto)

(defun my-string-inflection-cycle-auto ()
  "switching by major-mode"
  (interactive)
  (cond
   ;; for emacs-lisp-mode
   ((eq major-mode 'emacs-lisp-mode)
    (string-inflection-all-cycle))
   ;; for java
   ((eq major-mode 'java-mode)
    (string-inflection-java-style-cycle))
   (t
    ;; default
    (string-inflection-ruby-style-cycle))))


;; Setting Example 2

(require 'string-inflection)

;; default
(global-set-key (kbd "C-c C-u") 'string-inflection-all-cycle)

;; for ruby
(add-hook 'ruby-mode-hook
          '(lambda ()
             (local-set-key (kbd "C-c C-u") 'string-inflection-ruby-style-cycle)))

;; for java
(add-hook 'java-mode-hook
          '(lambda ()
             (local-set-key (kbd "C-c C-u") 'string-inflection-java-style-cycle)))

We will change as follows each type C-q C-u Place the cursor in the emacs_lisp.

In the case of `string-inflection-ruby-style-cycle`

emacs_lisp => EMACS_LISP => EmacsLisp => emacs_lisp

In the case of `string-inflection-java-style-cycle`

emacsLisp => EMACS_LISP => EmacsLisp => emacsLisp

In the case of `string-inflection-all-cycle`

emacs_lisp => EMACS_LISP => EmacsLisp => emacsLisp => emacs-lisp => emacs_lisp

The `string-inflection-all-cycle`, conversion often. However, conversion occurs even when there is no need to lower-camelcase. Therefore so difficult to use, is not recommended

Function that can be used alone

(string-inflection-underscore-function "EmacsLisp")       ; => "emacs_lisp"
(string-inflection-camelcase-function "emacs_lisp")       ; => "EmacsLisp"
(string-inflection-lower-camelcase-function "emacs_lisp") ; => "emacsLisp"
(string-inflection-upcase-function "emacs_lisp")          ; => "EMACS_LISP"
(string-inflection-kebab-case-function "emacs_lisp")      ; => "emacs-lisp"

(string-inflection-camelcase-p "EmacsLisp")               ; => t
(string-inflection-camelcase-p "emacs_lisp")              ; => nil