help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting a list of `set' calls to a minor mode


From: David Shepherd
Subject: Re: Converting a list of `set' calls to a minor mode
Date: Mon, 15 Aug 2016 16:41:20 +0000

Hi,

[Please keep me in the CC as well if possible, I'm also not subscribed]

I actually looked for a way to do do such a "set/unset with memory" a
few weeks ago but didn't find anything useful. It does seem strange
(and unlikely) that no one has needed something like this before.

If nothing turns up I might have a go implementing something. A pattern
I've come across in Javascript is to have a function that returns a closure
that will revert the effects of calling the function. I'd be interested in
playing with emacs' lexical scoping rules to see if something similar
is possible for this problem (probably yes).

No guarantees on a timescale for that though, I'm away a lot this month.

David


On Sat, 13 Aug 2016 at 17:03 Sean Whitton <spwhitton@spwhitton.name> wrote:

> Hello,
>
> [Kindly keep me in the CC as I'm not subscribed]
>
> I want to convert frames-only-mode[1] to an actual global minor mode.
> At present, it is just a long list of calls to `set' and `advice-add'.
>
> When deactivating the minor mode, undoing the `advice-add' calls is
> straightforward, but I also need to undo the `set' calls.  I think that
> they should be set back to whatever they were set to previously, so long
> as the user hasn't modified them since the minor mode was activated.
> I.e., for each var, if
>
> - var was set to foo before the minor mode was activated, and
> - we set var to bar when activating the minor mode, and
> - var is still set to bar
>
> ... then we set var back to foo.
>
> Is there some macro to do this?  I envisage calling (set-and-remember
> var) when activating the minor mode and (restore var) when deactivating
> it.  Surely there is already a global minor mode that has solved this
> problem.
>
> Thanks!
>
> [1] https://github.com/davidshepherd7/frames-only-mode/
>
> --
> Sean Whitton
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]