all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Shepherd <davidshepherd7@gmail.com>
To: Sean Whitton <spwhitton@spwhitton.name>, help-gnu-emacs@gnu.org
Subject: Re: Converting a list of `set' calls to a minor mode
Date: Thu, 01 Sep 2016 19:14:45 +0000	[thread overview]
Message-ID: <CAOdAAt1cA1BTO1k7SyW5+g5gWWZ84eou1zbayCP=3zRfNOF2pg@mail.gmail.com> (raw)
In-Reply-To: <CAOdAAt1LCKy5g2iWaDUK_o9UjMMOVKy8tbu1SWuyTjcNw-x-zA@mail.gmail.com>

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
>>
>


      parent reply	other threads:[~2016-09-01 19:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOdAAt1cA1BTO1k7SyW5+g5gWWZ84eou1zbayCP=3zRfNOF2pg@mail.gmail.com' \
    --to=davidshepherd7@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=spwhitton@spwhitton.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.