* Converting a list of `set' calls to a minor mode
@ 2016-08-13 16:03 Sean Whitton
2016-08-15 16:41 ` David Shepherd
0 siblings, 1 reply; 4+ messages in thread
From: Sean Whitton @ 2016-08-13 16:03 UTC (permalink / raw
To: help-gnu-emacs; +Cc: davidshepherd7
[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Converting a list of `set' calls to a minor mode
2016-08-13 16:03 Converting a list of `set' calls to a minor mode Sean Whitton
@ 2016-08-15 16:41 ` David Shepherd
2016-08-15 23:20 ` Stefan Monnier
2016-09-01 19:14 ` David Shepherd
0 siblings, 2 replies; 4+ messages in thread
From: David Shepherd @ 2016-08-15 16:41 UTC (permalink / raw
To: Sean Whitton, help-gnu-emacs
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Converting a list of `set' calls to a minor mode
2016-08-15 16:41 ` David Shepherd
@ 2016-08-15 23:20 ` Stefan Monnier
2016-09-01 19:14 ` David Shepherd
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2016-08-15 23:20 UTC (permalink / raw
To: help-gnu-emacs
> 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.
I don't think there is. I did write some such code for some minor
mode(s), but never got around to make it clean and generic.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Converting a list of `set' calls to a minor mode
2016-08-15 16:41 ` David Shepherd
2016-08-15 23:20 ` Stefan Monnier
@ 2016-09-01 19:14 ` David Shepherd
1 sibling, 0 replies; 4+ messages in thread
From: David Shepherd @ 2016-09-01 19:14 UTC (permalink / raw
To: Sean Whitton, help-gnu-emacs
Hi,
I've implemented a set/unset function as described above in let-mode [1]
(might need a better name, suggestions welcome). At the moment
it's very basic, and usage instructions are just the tests! I'll probably
add more functionality and usability wrappers over the next few
days but just wanted to let you (Sean) know it's there.
[1]: https://github.com/davidshepherd7/let-mode
On Mon, 15 Aug 2016 at 17:41 David Shepherd <davidshepherd7@gmail.com>
wrote:
> 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
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-01 19:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-13 16:03 Converting a list of `set' calls to a minor mode Sean Whitton
2016-08-15 16:41 ` David Shepherd
2016-08-15 23:20 ` Stefan Monnier
2016-09-01 19:14 ` David Shepherd
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.