Replacing identifiers in an Emacs buffer
Posted on Fri, 9 Jan 2009
Recently I had a need to replace a large number of identifier names in a collection of source code without replacing other uses of those names in comments or string literals. Not finding a satisfactory solution, I decided to write one. It's based on an earlier function I wrote to do the same thing in Common Lisp code, but is generalized to work on any buffer for which the Emacs functions `forward-sexp', `backward-sexp', `down-list', and `backward-up-list' work properly. I've been using it today to rename types in C, and I'd expect that it'd work properly with most language modes.
If you have similar needs, you might find my ambitiously-named refactor.el to be useful!