* On 21 Sep 2015, Cameron Simpson wrote: > > So you might have ",y" mapped to a macro to save various settings (i.e. save > everything that any of your macros fiddle with) and ",Y" mapped to pull the > values back from $my_foo et al into the settings again. > > Then put ",y" at the start of your macros and ",Y" at the end.
Similarly, I have macros that cycle through various values of $index_format. There are four of them, named something like "=y0", "=y1", etc. Each macro sets the $index_format, then macros "Y" to the next "=y" in the list. Upshot: each time I press Y my index_format changes, rotating through four options. > I think about this issue frequently. My preferred general approach would be > some kind of stack of settings: "push settings", do work, "pop settings". > And possibly "push particular setting(s)". Before the my_ variables were introduced I had a patch for making variable stacks. I like your idea of push/pop all settings. I didn't have that but it sounds useful. Sort of like a gsave/grestore (for postscript nerds). > There are three trickinesses that spring to mind: (a) defining the "end of > work point", (b) making the "pop settings" operation run even when something > in the middle of your macro fails and (c) what about when you want your > macro to change one setting by hack-and-preserve the rest of them. You'd > need some kind of "set value in the outer set" or "set value in some global > set" or something. Issue (c) would be nasty to define - one can imagine > wanting all sorts of variations depending on circumstances. Keep thinking about this stuff. I'd be interested in a comprehensive plan that addresses multiple use cases and doesn't break existing configs. One passing thought that I haven't given much consideration to: fail-hook, defining what happens when something doesn't complete as intended. (But the _much_ harder problem is detecting failure in a consistent and useful way.) -- David Champion • d...@bikeshed.us