string-inflection

underscore -> UPCASE -> CamelCase conversion of names

Github星跟蹤圖

  • underscore -> UPCASE -> CamelCase conversion of names

#+html:
#+html:
#+html:

[[https://github.com/akicho8/string-inflection/blob/master/HISTORY.org][Change History]]

** Configuration Examples

*** Example 1

#+BEGIN_SRC elisp
(require 'string-inflection)

;; C-q C-u is the key bindings similar to Vz Editor.
(global-unset-key (kbd "C-q"))
(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 python
((eq major-mode 'python-mode)
(string-inflection-python-style-cycle))
;; for java
((eq major-mode 'java-mode)
(string-inflection-java-style-cycle))
(t
;; default
(string-inflection-ruby-style-cycle))))
#+END_SRC

*** Example 2

#+BEGIN_SRC elisp
(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)))

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

#+END_SRC

** How to use

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-python-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 => 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

#+BEGIN_SRC elisp
(string-inflection-underscore-function "EmacsLisp") ; => "emacs_lisp"
(string-inflection-pascal-case-function "emacs_lisp") ; => "EmacsLisp"
(string-inflection-camelcase-function "emacs_lisp") ; => "emacsLisp"
(string-inflection-upcase-function "emacs_lisp") ; => "EMACS_LISP"
(string-inflection-kebab-case-function "emacs_lisp") ; => "emacs-lisp"
(string-inflection-capital-underscore-function "emacs_lisp") ; => "Emacs_Lisp"

(string-inflection-pascal-case-p "EmacsLisp") ; => t
(string-inflection-pascal-case-p "emacs_lisp") ; => nil
; etc...
#+END_SRC

主要指標

概覽
名稱與所有者akicho8/string-inflection
主編程語言Emacs Lisp
編程語言Emacs Lisp (語言數: 1)
平台
許可證
所有者活动
創建於2012-10-11 14:20:57
推送於2024-08-16 05:33:56
最后一次提交2024-08-16 14:33:43
發布數13
最新版本名稱v1.0.16 (發布於 )
第一版名稱v1.0.4 (發布於 )
用户参与
星數254
關注者數5
派生數23
提交數122
已啟用問題?
問題數20
打開的問題數1
拉請求數23
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?