Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capitalize english string in Emacs

I'm wondering what's people using to correctly capitalize english strings since ''capitalize'' won't do the job:

(capitalize "can't")
=> "Can'T"

Although writing this function is trivial, I'm wondering if there's a preferred built-in way to do it.

like image 303
Federico Builes Avatar asked Aug 21 '09 23:08

Federico Builes


2 Answers

Maybe if you temporarily add ' to the current word constituent syntax table:

(modify-syntax-entry ?' "w")

(capitalize "can't")
=> "Can't"
like image 82
Karl Voigtland Avatar answered Oct 05 '22 10:10

Karl Voigtland


I have M-c bound to capitalize-word, and it works to capitalize can't correctly.

like image 20
Cheeso Avatar answered Oct 05 '22 10:10

Cheeso