[OS X Emacs] map-query-replace-regexp: why?

K. Richard Pixley rich at noir.com
Thu Sep 30 13:34:33 EDT 2010


  On 9/30/10 10:25 , Jack Repenning wrote:
> On Sep 30, 2010, at 9:14 AM, Enrico Franconi wrote
>> This goes back to a typical lisp programming pattern, familiar to the older among us who did a lot of lisp programming in their youth :-)
> Well, yeah, I recognize the pattern, and was writing lisp when people still got huffy about spelling it LISP ;-). But even AI programmers usually have a *reason* for doing something! I also find it odd that, despite its name, this routine doesn't really follow the LISP/lisp/e-lisp "map" pattern, in that the "list" of values to map in is actually presented as a space-delimited string, not an actual, you know ... *list*. That seems an odd choice to this old cons-er, and also seems to force the substitutions to be space-free, an odd presumption in a text editor, which once again seems to imply some very specific purpose. Which I can't, for the life of me, guess.
I can think of a number of uses.  Some of them replace awk in the sense 
of munging positional values of a shell style "record".  Some of them 
provide the reverse function to "cat" in the sense that they could, 
potentially, be used to "deal" a series of values into separate buckets.

I routinely write keyboard macros of the sort: (first, manually find 
some position), then "go forward or backwards a bit to the interesting 
part, replace it with VALUE1, then go forward or backward a bit more and 
replace another interesting part with VALUE2, and finally, find the next 
interesting position at which I might want to rerun this macro (which 
allows for repetitive evaluation)"  This funky map could do some similar 
things.

I'm not saying it's a good, valuable, or well thought out function - 
only that I have a talented imagination.

--rich



More information about the MacOSX-Emacs mailing list