5th June 2007

Posted in

Blog :: That's very sensitive of you

Don't you love it when tool designers have anticipated your needs?

I just noticed that replace-string in Emacs is replacement case sensitive. I was doing something I've done many times before: copy a row of an html form and paste, than change the label "for" attribute, the label text, and the name and id of the input element to get a new row for a different piece of data. So I had this:

   <li><label for="title">Title:</label><input type="text" id="title" name="title"></li>

and wanted a new row titled "Serves". Now I want to use search and replace, but my label text has an uppercase first letter and the rest of the attributes (for, id, name) are all lowercase. Selecting the line and C-x n n narrowed my buffer to the line I wanted to work on (this is a nice Emacs feature that lets you restrict global operations to a selection) and did an m-x replace-string with "title" and "serves" as my search and replace terms. Emacs search is case insensitive if the search term is all lower case, any upper case letters triggers case sensitivity. So I anticipated getting all lowercase replacements and then manually uppercase the first letter (of course there's a command for that: upcase-initials-region) of the label text. To my suprise, however, I got back

    <li><label for="serves">Serves:</label><input type="text" id="serves" name="serves"></li>

Emacs automatically honored the target case in doing the replacement. Now that is usability!

Posted on June 5th 2007, 12:09 PM