(or emacs irrelevant)

upcase-word, you so silly

Do you know what the most frequently used Emacs commands are? I can confirm by my own experience that they are next-line and previous-line (in that order). So why do M-u - upcase-word, M-l - downcase-word, and M-c - capitalize-word have such terrible synergy with Emacs's best commands?

No, upcase-word, this is not what I had in mind:

Learn basic keystroke commands
Overview of Emacs features at gnu.org
Learn basic keySTROKE commands
Overview of Emacs features at gnu.org

If you say:

But how did you get the cursor in such a crazy position in the first place? You should have used M-b/M-f.

Well, I got there with previous-line - one of the best Emacs commands!

Resolve the *-word malarkey with defadvice

Here are some simple advice commands that I've just rolled:

(defadvice upcase-word (before upcase-word-advice activate)
  (unless (looking-back "\\b")

(defadvice downcase-word (before downcase-word-advice activate)
  (unless (looking-back "\\b")

(defadvice capitalize-word (before capitalize-word-advice activate)
  (unless (looking-back "\\b")

Small explanation to the Elisp novices:

  1. before upcase-word is called, execute the body of upcase-word-advice
  2. unless we are at the beginning of the word
  3. backward-word once to move to the beginning of the word

I'm intentionally not using the newest advice system here, since not everyone has yet upgraded to Emacs 24.4. In fact, I saw this gem today at Stack Overflow:

I am using Emacs 23 and cedet 1.0.1 ...