I’m wondering if there’s any way to make a variable automatically save its old value, so that I can, e.g., write a minor mode that will automatically restore the old values of variables when it’s deactivated (without having to declare a bunch of -old-value variables).

  • JDRiverRunB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    A variable watcher maybe.

        (add-variable-watcher
         'myvar
         (lambda (sym val op buf)
           (when (eq op 'set)
             (push val (get sym 'prior-values)))))