make camelcase work on already-camelcased text
start working on caser-upper-camelcase-region
make the dwim functions autoloaded
This package provides functions which change the case of text -- from camelCase
to dash-case
to snake_case
and back.
We recommend binding these functions to relevant keys:
(bind-key "M-C" #'caser-camelcase-dwim)
(bind-key "M-S" #'caser-snakecase-dwim)
(bind-key "M-D" #'caser-dashcase-dwim)
Put some camelcase, snakecase, or dashcase text into a buffer. Then call one of the functions below.
caser-camelcase-dwim
changes text to camelCasecaser-snakecase-dwim
changes text to snake_casecaser-dashcase-dwim
changes text to dash-case.The functions Do What I Mean. Hopefully, that is.
-dwim
functions act on the region.-dwim
functions act on the next word.-dwim
functions act on that many words forward.Sometimes, it's easier to call a dwim
function multiple times in a row, rather than select a region first. To make this easier, this mode supports repeat-mode. Repeat-mode is a way of easily repeating related commands.
To enable it, run this line:
(repeat-mode 1)
Then, each function is able to be repeated by pressing a single letter. Once you run caser-snakecase-dwim, it can be ran gain with s
. Similarly, caser-camelcase-dwim can be repeated with c
; caser-dashcase-dwim can be repeated with d
.
These keys can be customized; see variables caser-snakecase-repeat-map
, caser-camelcase-repeat-map
, and caser-dashcase-repeat-map
.
Because this package uses standard Emacs regexp character classes and case conversion functions, it fully supports changing the case of languages that don't use only ASCII letters. Try orð á íslensku
(Icelandic), or Deutsch ist ähnlich
(German).
Although languages with no capitalization can't be camelCased, they can still be changed from dash-case to snake_case: try 한국어-단어
(Korean).
This is not the first casing-related Emacs package. However, it works slightly differently than these existing packages.
CI is set up at builds.sr.ht. Hopefully everything is passing.