From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: David Shepherd Newsgroups: gmane.emacs.help Subject: Re: Converting a list of `set' calls to a minor mode Date: Mon, 15 Aug 2016 16:41:20 +0000 Message-ID: References: <20160813160333.gahqlrcq42hkl2yy@hephaestus.silentflame.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1471282269 25173 195.159.176.226 (15 Aug 2016 17:31:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Aug 2016 17:31:09 +0000 (UTC) To: Sean Whitton , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 15 19:31:05 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZLj7-0006CJ-0E for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Aug 2016 19:31:05 +0200 Original-Received: from localhost ([::1]:38217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZLj4-00008u-13 for geh-help-gnu-emacs@m.gmane.org; Mon, 15 Aug 2016 13:31:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZKxC-0000FI-Ut for help-gnu-emacs@gnu.org; Mon, 15 Aug 2016 12:41:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZKxA-00019i-H6 for help-gnu-emacs@gnu.org; Mon, 15 Aug 2016 12:41:33 -0400 Original-Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZKxA-00019Z-6i for help-gnu-emacs@gnu.org; Mon, 15 Aug 2016 12:41:32 -0400 Original-Received: by mail-wm0-x22d.google.com with SMTP id o80so114351107wme.1 for ; Mon, 15 Aug 2016 09:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=zeHoJ9mlxURRY2DmWkpvF4iemwfFoqCHkpIWPLHRaGA=; b=H2sReL0/qlwKwr6HRdSrefl4PwaQoB9AlAe4tmBjGoZwoi956OALxv/id9dE6JXi/3 8G3Jcs7SjVdx4MlTlzarbeev43c1ix3ffcGwFLGMNVlRz1w5hPzob9AIFEieX52ua++F ttJN3jyH+of6hoKStz1GMc5408qrAbmTYGu0T2ko3vYp57sIdYvc8/jma41HLI0gVEzs GhOOuk2U2VbMRR4e/NI0sknB+wC/+dT86+f7B8lZrPXt+ffEgiei0aKgcM4Qpd1ygcd7 7yP92VxXFdPrj/OXkRDree+IQutZt2MTcAOanQwd8F/AHmyXHvNox3C5U+2AiEA6+2iN EG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=zeHoJ9mlxURRY2DmWkpvF4iemwfFoqCHkpIWPLHRaGA=; b=ZvSUUXuTWbeDzm4zhnMaVV4JwMH0u+xbtZ3G/3whpmLMpbGc3GBcg6tRkKZRhihjnK jtro6cn1c2GAYiRFo4iT2He1Lx6xjsrDEUYJKRCjCPSSDHxfR3oQP2KLtOTqkgJtkD5/ oescq7dDAydwfMH+Wsc49HgPWID7ZwO7+aM8QMImApXAZhD4ZhxYerwrDSy3uq/xMLkr 3v8Bsv8E2KuBVCdpZ7G+XCMTN3MIFUZZCbre5t7NNma7idjRQWH/gt7xtPKtDswjqyro OSoGjYa9v0xsD8M5lmOsK8A43KCTmDlUyBExB2Lb+VdpDuG5i0bPJ4aGs2SJffTS2HaV DA8g== X-Gm-Message-State: AEkoouvYSgNOdWCiqegFkGTzz+e7jTZXto2kKSHDgVaRHXp5aFcMcf5EFyuPYDFuoSLKT6tBIuajpMNqervWRA== X-Received: by 10.194.95.36 with SMTP id dh4mr24760470wjb.149.1471279291078; Mon, 15 Aug 2016 09:41:31 -0700 (PDT) In-Reply-To: <20160813160333.gahqlrcq42hkl2yy@hephaestus.silentflame.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d X-Mailman-Approved-At: Mon, 15 Aug 2016 13:28:16 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111147 Archived-At: 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 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 >