Note: If it wasn’t obvious from the title, there will be no pictures of Gabe in this particular post.
In the course of my job, on rare occasion, I manually deal with input files from the client. Said files are typically lines of text delimited by a setia (cethia? sethia?). The setia character looks like a capital C with a squiggly tail, like so: Ç. Though the client refers to this character explicitly as setia or some close derivative spelling , the HTML entity name for is “C with cedilla”.
Inserting the “C with cedilla” into an emacs buffer turned out to be one of those easy/near-impossible things. It is easy once you know how to do it, but if you had to figure it out yourself the first time it was near impossible.
So the first thing to do is figure out C-q is “quoted-insert”. The second thing to do is realize that the input is the character code in Octal. In this case, I needed to figure out that 199 is 307 in octal. Converting that was simple, once I remembered how to do it (with some help from friends). The answer is repeatedly divide by 8, like so:
199/8 | 24, remainder 7 | 7 is the last digit of the octal number |
24/8 | 3, remainder 0 | 0 is the next to last digit of the octal number |
3/8 | 0, remainder 3 | 3 is the first (most significant) digit of the number |
So armed with that information, the simple key combination of C-q 307 gives me a “C with Cedilla” Woo Hoo!
So know that I know how to do that, I want a simple function so that I don’t have to do that much work again for one character. Google Groups led me to the gnu.emacs.help Newsgroup, where I was able to rip off an emacs function from a guy who wanted a quick way to all those funky foreign (foreign to most US folks, that is) accent symbols.
In all its compact glory:
(defun setia () (interactive (insert (format "%c" ?307))))
You nerd