Yeah that's a really effective way of seeing mapcar in action and I'm surprised it didn't come up during the various mapcar discussions. Or if it did I've read too much and don't remember it.
That said, let's break it down for anyone who may learn from this:
(setq var '(cmdecho insunits attreq)) ;set a variable 'var' which is a list to contain the sysvars to be modified
(setq val (mapcar 'getvar var)) ;set a variable 'val' which holds the values when mapcar applies the "getvar" command to each item in the 'var' list
(mapcar 'setvar var '(0 0 1)) ;so we're mapping "setvar" over the var list this time, with quoted 0 0 1, so basically it's a shorthand way to express the following:
; (setvar "cmdecho" 0) (setvar "insunits" 0) (setvar "attreq" 1), this has the added benefit of when you're ready to expand this list to contain
;more variables you can do so by typing the sysvar name and the value wanted for that var, much easier than even the typical commands
;to set and store user settings beforehand.
My only question that I've noticed when seeing this use of mapcar is where are the users original settings stored? If the program is modifying attreq to do it's duty, shouldn't attreq be put back to what it's value was before the program was initiated ? j/w, typically heard this is good coding practice and perhaps just a quick and dirty routine was given, still- trying to be clear on the topic!
So let me be clear myself! I'm not asking this to point out any inadequacies in the given code as any code given is a gem and should be respected, ie. not everyone can do it, it's time consuming, and it's very useful for the person intended for. That's a heck of a combination. I did, however, ask because i'm genuinely wondering if there's a mapcar method to save the sys vars beforehand, or is it handled in another fashion when this setup is used.....or...? Thanks! that's why i'm asking.