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: simple useful functions Date: Mon, 6 Dec 2010 10:39:45 -0800 Message-ID: <20101206.103945.379575954.Takaaki.Ota@am.sony.com> References: <20101203.185802.425329138.Takaaki.Ota@am.sony.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1291661997 4009 80.91.229.12 (6 Dec 2010 18:59:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 6 Dec 2010 18:59:57 +0000 (UTC) Cc: emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 06 19:59:53 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PPgHx-00013Q-Bt for ged-emacs-devel@m.gmane.org; Mon, 06 Dec 2010 19:59:53 +0100 Original-Received: from localhost ([127.0.0.1]:36641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPgHw-0005fu-T1 for ged-emacs-devel@m.gmane.org; Mon, 06 Dec 2010 13:59:52 -0500 Original-Received: from [140.186.70.92] (port=60783 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPfyV-0002Mw-9K for emacs-devel@gnu.org; Mon, 06 Dec 2010 13:39:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPfyP-0001Tu-CL for emacs-devel@gnu.org; Mon, 06 Dec 2010 13:39:47 -0500 Original-Received: from va3ehsobe005.messaging.microsoft.com ([216.32.180.31]:4493 helo=VA3EHSOBE005.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPfyP-0001T8-9u for emacs-devel@gnu.org; Mon, 06 Dec 2010 13:39:41 -0500 Original-Received: from mail153-va3-R.bigfish.com (10.7.14.247) by VA3EHSOBE005.bigfish.com (10.7.40.25) with Microsoft SMTP Server id 14.1.225.8; Mon, 6 Dec 2010 18:39:39 +0000 Original-Received: from mail153-va3 (localhost.localdomain [127.0.0.1]) by mail153-va3-R.bigfish.com (Postfix) with ESMTP id 425AE19F0240; Mon, 6 Dec 2010 18:39:39 +0000 (UTC) X-SpamScore: -12 X-BigFish: VPS-12(zz1432N98dNzz1202hzzz2fh2a8h668h61h) X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:mail7.fw-bc.sony.com; RD:mail7.fw-bc.sony.com; EFVD:NLI Original-Received: from mail153-va3 (localhost.localdomain [127.0.0.1]) by mail153-va3 (MessageSwitch) id 1291660778929729_14389; Mon, 6 Dec 2010 18:39:38 +0000 (UTC) Original-Received: from VA3EHSMHS005.bigfish.com (unknown [10.7.14.250]) by mail153-va3.bigfish.com (Postfix) with ESMTP id D0F708C004D; Mon, 6 Dec 2010 18:39:38 +0000 (UTC) Original-Received: from mail7.fw-bc.sony.com (160.33.98.74) by VA3EHSMHS005.bigfish.com (10.7.99.15) with Microsoft SMTP Server (TLS) id 14.1.225.8; Mon, 6 Dec 2010 18:39:34 +0000 Original-Received: from mail1x.bc.in.sel.sony.com ([43.144.65.112]) by mail7.fw-bc.sony.com (Switch-3.4.2/Switch-3.3.2mp) with ESMTP id oB6IdWsQ019980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 6 Dec 2010 18:39:33 GMT Original-Received: from localhost (tak-vaio-z1290-043191017095.am.sony.com [43.191.17.95] (may be forged)) by mail1x.bc.in.sel.sony.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oB6IdWnE008361; Mon, 6 Dec 2010 18:39:32 GMT In-Reply-To: X-Mailer: Mew-6.3.50 on Emacs-23.2.90.1 (i386-mingw-nt6.1.7600 built on 2010-11-22) X-OriginatorOrg: am.sony.com X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) 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:133462 Archived-At: Fri, 3 Dec 2010 20:36:09 -0800: Stefan Monnier wrote: > >> - I fail to see in which circumstance(s) this is useful. > > OK, I see this may not be useful for everybody. > > That's not necessarily a problem, tho. Most packages in Emacs are not > useful for everybody, after all. Still, it needs to be useful to more > than a handful; and, more importantly, it should provide a clear > functionality in a "generic" way (this is what is likely to make it > useful to more than a handful of users). > > > The reason I wrote this command was to support embedded software > > development. In embedded development work we are usually required to > > use some cross compilation tools. Such tools often come with a setup > > script which includes setting up necessary environment variables for > > command paths and library paths. I understand. > IIUC these scripts are written for /bin/sh, right? How do (t)csh users > handle that? > [ Sorry, I'm not that familiar with cross-compiling: OpenWRT is about > as far as I got into this, and it "takes care of things" in ways > I haven't tried to understand. They don't use such setup scripts, at > least in a user-visible way (although the user does perform the > cross-compiling). ] Those scripts are written for the shell the tool provider intends user to use. The shell to use is not always our choice. > > In order to compile software in this environment from Emacs I need to > > start Emacs from the shell that has run the script. But to me Emacs > > is not a text editor but a working environment. > > I partly understand the context. But right here I think your script > fails to serve you: it uses `setenv' which affects all inferior > processes, so if you're working on several projects at the same time > from the same Emacs session (likely if you're using it as a work > environment, which is also the intended use to a large extent), you get > pollution from one project to the other. I think this issue is > important, and I suspect that figuring out how it should be solved is > necessary to figure out what is a good/generic way to provide this > "source" feature. This is a good point. I am contaminating the whole emacs. It made me review compile.el and I learned the existence of compilation-environment which I think is more appropriate than `setenv' function. (defun source (script &optional shell keep-current-directory) "Source the specified shell script and set `compilation-environment'. Source the shell SCRIPT and import the environment into `compilation-environment'. 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 it." (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 ". " (shell-quote-argument script) "; printenv")) (setq compilation-environment (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))))