From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Phillip Lord" Newsgroups: gmane.emacs.devel Subject: Re: Emacs Lisp container Date: Tue, 27 Jun 2017 07:22:02 -0000 Message-ID: <481a66a174a3059874f60d8f882cf18f.squirrel@cloud103.planethippo.com> References: <87podqdtdu.fsf@x230.lts> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1498548182 32119 195.159.176.226 (27 Jun 2017 07:23:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 27 Jun 2017 07:23:02 +0000 (UTC) User-Agent: SquirrelMail/1.5.2 [SVN] Cc: emacs-devel@gnu.org To: =?utf-8?B?IkV0aWVubmUgUHJ1ZOKAmWhvbW1lIg==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 27 09:22:58 2017 Return-path: Envelope-to: ged-emacs-devel@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 1dPkpt-000856-6g for ged-emacs-devel@m.gmane.org; Tue, 27 Jun 2017 09:22:57 +0200 Original-Received: from localhost ([::1]:51006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPkpy-0003c1-Dr for ged-emacs-devel@m.gmane.org; Tue, 27 Jun 2017 03:23:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPkpm-0003bl-L7 for emacs-devel@gnu.org; Tue, 27 Jun 2017 03:22:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dPkph-00066M-OS for emacs-devel@gnu.org; Tue, 27 Jun 2017 03:22:50 -0400 Original-Received: from cloud103.planethippo.com ([78.129.138.110]:33008) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dPkph-0005rI-EL for emacs-devel@gnu.org; Tue, 27 Jun 2017 03:22:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Cc:To:From:Subject:Date:References:In-Reply-To:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TnNrMCR6cmmC2fJAlFxf0B9lp8MTa+qIynvkHeL6/h4=; b=ohD9rjAeTibGn7+qMlZmpWCSzt LRbLc0z7nllJQKDE0Myt9e7KZjK+fXycbbxdTUByxyGgwSzhH9IcaNMO9OZEdFK7ZJshRRr81LDhj htY4MJKo96yrqcf4CTIH4j71GC57hnxxk7VjSeqMiLUmIM+xyjV9TV0uk4g8d0Nc9fJqMR13q66wB dgkjr8Fq5eDS6HRFgUdub7lowVUCzOECeaGfZcxL6UlkDhCvb50VJUHW4u4rEf5wak5NV5fyKUIxn Ajksp10MeeOHwTL8yPA8j/ZYOlYcISQdNXsJ+uPlo6pNN+I8RTUzXMmqltvNAA0N+FCpbuIemJZNy q6abeHRQ==; Original-Received: from [127.0.0.1] (port=46775 helo=cloud103.planethippo.com) by cloud103.planethippo.com with esmtpa (Exim 4.89) (envelope-from ) id 1dPkp0-000Mrh-OZ; Tue, 27 Jun 2017 07:22:02 +0000 Original-Received: from 92.233.204.101 ([92.233.204.101]) (SquirrelMail authenticated user phillip.lord@russet.org.uk) by cloud103.planethippo.com with HTTP; Tue, 27 Jun 2017 07:22:02 -0000 In-Reply-To: <87podqdtdu.fsf@x230.lts> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 78.129.138.110 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216022 Archived-At: On Tue, June 27, 2017 3:03 am, Etienne Prud’homme wrote: > Hi, > > > I’ve tried to find a library or some tool to execute Elisp in a running > session while keeping the same environment, but found none. Some call it a > container or sandbox or even jail. > > What I mean by that, is that I would like to execute a body of code and > get the result without actually modifying the variables, functions, loaded > features, etc. of the current session. > > I’m fully aware that starting a new session seem to do the same thing, > but I want to execute the piece of code in the *current running > environment*. > > > I finally came up with a small library I named _container_[1]. There > are many ways to escape the container (like using `funcall` & `apply` and > also using `eval` on a quoted `eval` form). It’s more of a proof a > concept than a working library right now. > > e.g. > >> (let ((container-ignore-error t) >> (container >> (add-to-list 'load-path "~/Documents/") >> (require 'foo) >> (setq emacs-version "0.0.0") >> emacs-version)) ; => "0.0.0" emacs-version ; => 26.0.50 > > The above snippet doesn’t (seem to) have side-effects. > > > What it does is the following: > > > * Saves the window configuration and opens a new buffer. > > > * Overrides the `require` & `load` functions to unload after the > container finished executing. > > * Overrides the `load-theme` function to restore the original theme > configuration after. > > * Overrides the `set`, `setq` & `set-default` functions to make the > variable buffer local. > > * Overrides the `eval` function to apply the above. This one is > particularly tricky since we could escape it using a quoted form. I’m > considering disabling it altogheter and signal an error. > > * (Work in Progress) Overrides the `funcall` & `apply` functions to > apply the rules above. This is also tricky since the evaluation process > doesn’t make much sense to me. I’m probably not used enough with > evalutation. I can’t figure out why: > >> (funcall #'setq test 1) >> > > works while: > >> (funcall #'setq 'test 1) >> > > doesn’t work. > > Of course, I may be totally wrong in my approach and would appreciate > being corrected. Help and comments are welcomed! It's a nice idea, but I think that C-level calls to setq will just ignore your changes. Likewise for all your other alterations. So, this will get you some of the way there, but not all of the way. Besides which you still allow buffer changes which is, of course, a major issue with statelessness. Phil