From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tak Ota Newsgroups: gmane.emacs.devel Subject: Re: sourcing environment Date: Wed, 11 Oct 2006 12:15:57 -0700 (PDT) Organization: Sony Electronics Inc. Message-ID: <20061011.121557.186976084.Takaaki.Ota@am.sony.com> References: <20061011.090745.01371169.Takaaki.Ota@am.sony.com> <20061011190012.GD64381@gothmog.pc> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1160594249 15200 80.91.229.2 (11 Oct 2006 19:17:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 Oct 2006 19:17:29 +0000 (UTC) Cc: stephen_leake@member.fsf.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 11 21:17:26 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GXjYz-0000Fe-Mo for ged-emacs-devel@m.gmane.org; Wed, 11 Oct 2006 21:16:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GXjYz-00017a-5k for ged-emacs-devel@m.gmane.org; Wed, 11 Oct 2006 15:16:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GXjYg-00016O-Mt for emacs-devel@gnu.org; Wed, 11 Oct 2006 15:16:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GXjYf-00015u-F4 for emacs-devel@gnu.org; Wed, 11 Oct 2006 15:16:01 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GXjYf-00015p-5q for emacs-devel@gnu.org; Wed, 11 Oct 2006 15:16:01 -0400 Original-Received: from [206.16.192.249] (helo=outbound2-ash-R.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1GXjgi-0000nf-PQ for emacs-devel@gnu.org; Wed, 11 Oct 2006 15:24:21 -0400 Original-Received: from outbound2-ash.bigfish.com (localhost.localdomain [127.0.0.1]) by outbound2-ash-R.bigfish.com (Postfix) with ESMTP id 1DC45148E9D1; Wed, 11 Oct 2006 19:16:00 +0000 (UTC) Original-Received: from mail67-ash-R.bigfish.com (unknown [172.18.2.3]) by outbound2-ash.bigfish.com (Postfix) with ESMTP id 1681E148E9CD; Wed, 11 Oct 2006 19:16:00 +0000 (UTC) Original-Received: from mail67-ash.bigfish.com (localhost.localdomain [127.0.0.1]) by mail67-ash-R.bigfish.com (Postfix) with ESMTP id 0BC065219FF; Wed, 11 Oct 2006 19:16:00 +0000 (UTC) X-BigFish: V Original-Received: by mail67-ash (MessageSwitch) id 11605941606470_24230; Wed, 11 Oct 2006 19:16:00 +0000 (UCT) Original-Received: from mail8.fw-bc.sony.com (mail8.fw-bc.sony.com [160.33.98.75]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by mail67-ash.bigfish.com (Postfix) with ESMTP id E63B351EF6F; Wed, 11 Oct 2006 19:15:59 +0000 (UTC) Original-Received: from mail1.sgo.in.sel.sony.com (mail1.sgo.in.sel.sony.com [43.130.1.111]) by mail8.fw-bc.sony.com (8.12.11/8.12.11) with ESMTP id k9BJFxXu017674; Wed, 11 Oct 2006 19:15:59 GMT Original-Received: from localhost (us00130290172a.am.sony.com [43.191.14.104]) by mail1.sgo.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id k9BJFwpB005876; Wed, 11 Oct 2006 19:15:58 GMT Original-To: keramida@ceid.upatras.gr In-Reply-To: <20061011190012.GD64381@gothmog.pc> X-Telephone: +1-858-942-3239 X-Fax------: +1-858-942-9142 X-SnailMail: 16450 West Bernardo Drive MZ7205, San Diego, CA 92127-1804 X-Mailer: Mew-5.1.50 on Emacs-22.0.50.1 (i386-mingw-nt5.1.2600 built on 2006-10-09) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:60616 Archived-At: Wed, 11 Oct 2006 22:00:12 +0300: Giorgos Keramidas wrote: > > M-x kill-emacs > > $ source env-xxx.sh > > $ emacs > > It looks like you would have to spawn a subshell, save its environment > somewhere, source the script, save the new environment, diff the two > environments and 'translate' the diff output to appropriate > > (setenv "FOO" "bar") > > or > > (setenv "FOO" nil) > > calls :( That is pretty much what I do with the following function. My question is if this equivalent feature is already available in any form in the current emacs? -Tak ;; ;; Shell Script Sourcing ;; (defun source (script &optional shell keep-current-directory) "Source the specified shell script. Source the shell SCRIPT and import the environment into this emacs. The optional SHELL specifies the shell other than the default `shell-file-name'. When KEEP-CURRENT-DIRECTORY is nil, which is the default, the current directory is temporarily changed to the directory where the script resides while sourcing the script." (interactive "fscript file: ") (if (null shell) (setq shell shell-file-name)) (with-temp-buffer (unless keep-current-directory (setq default-directory (file-name-directory script))) (call-process shell nil t nil "-c" (concat "source " script "; printenv")) (while (re-search-backward "^\\([^=]+\\)=\\(.*\\)$" nil t) (setenv (match-string 1) (match-string 2)))))