2025-12-01 Uppercasing a single letter

There are some key bindings in Emacs which many people remap to something they consider “more useful”. I do it myself – pretty much the only thing the default binding for C-z (suspend-frame) does is annoy me. What I don’t understand is that some people do this to M-c, M-l and M-u, bound to capitalize-word, downcase-word and upcase-word respectively by default. I consider them tremendously useful (in fact, I sometimes even use C-x C-l (downcase-region) even though I claimed myself back in 2019 that it’s “useless”!). What I want is not fewer case-changing commands, but more of them! My issue is camelCase identifiers. As most Lispers know, camelCase is a terrible idea, and people use special tricks to make it more legible. Still, it is quite popular, among others in the JavaScript world (well, it’s called JavaScript and not java_script, so what should I expect…)

A few days ago I had the following problem when using Knex.js. I had a .whereIn() clause which I wanted to change to .orWhereIn(). My immediate reflex was to position the point on the w, type or and press M-c to change the w to upper case. Of course, this doesn’t work, since capitalizing whereIn changes it to Wherein, not WhereIn.

What would solve my problem would be a command to upcase one character only. Writing such a command is easy enough, but it turned out that a command like this (upcase-char) already exists in Emacs. The only thing I needed was to bind it to some key. Usually commands operating on character vs. words are bound to corresponding C- vs. M- keychords, but of course C-c is, well, out of bounds;-). It turns out, however, that M-C (that is, M-S-c, or Alt+Shift+C) is free. So, I now have this in my init.el:

(global-set-key (kbd "M-C") #'upcase-char)

That’s it for today!

CategoryEnglish, CategoryBlog, CategoryEmacs