From: Tak Ota <Takaaki.Ota@am.sony.com>
To: <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: simple useful functions
Date: Mon, 6 Dec 2010 10:39:45 -0800 [thread overview]
Message-ID: <20101206.103945.379575954.Takaaki.Ota@am.sony.com> (raw)
In-Reply-To: <jwv8w06kvui.fsf-monnier+emacs@gnu.org>
Fri, 3 Dec 2010 20:36:09 -0800: Stefan Monnier <monnier@IRO.UMontreal.CA> 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"))))
next prev parent reply other threads:[~2010-12-06 18:39 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 18:56 simple useful functions Tak Ota
2010-10-29 3:39 ` Stephen J. Turnbull
2010-10-29 18:13 ` Tak Ota
2010-10-29 19:02 ` Drew Adams
2010-10-29 19:26 ` Andreas Schwab
2010-10-29 20:19 ` Drew Adams
2010-10-29 20:47 ` Andreas Schwab
2010-10-29 20:56 ` Chad Brown
2010-10-29 21:23 ` Drew Adams
2010-10-30 9:01 ` Stephen J. Turnbull
2010-10-30 10:55 ` Thierry Volpiatto
2010-11-02 0:40 ` Tak Ota
2010-11-02 2:22 ` Stephen J. Turnbull
2010-11-03 0:38 ` Tak Ota
2010-11-03 5:27 ` Stephen J. Turnbull
2010-11-03 8:09 ` Andreas Röhler
2010-11-03 10:13 ` Stephen J. Turnbull
2010-11-03 18:08 ` Tak Ota
2010-11-03 18:01 ` Tak Ota
2010-11-04 2:10 ` Stephen J. Turnbull
2010-11-04 2:20 ` Tak Ota
2010-11-04 13:58 ` collect-string (was: simple useful functions) Stefan Monnier
2010-11-04 18:36 ` Tak Ota
2010-11-04 20:18 ` Tak Ota
2010-11-04 20:27 ` Tak Ota
2010-11-05 7:52 ` Andreas Röhler
2010-11-08 18:36 ` collect-string Stefan Monnier
2010-11-09 0:18 ` collect-string Tak Ota
2010-11-09 9:06 ` collect-string Stephen J. Turnbull
2010-11-10 2:12 ` collect-string Tak Ota
2010-11-30 2:14 ` collect-string Tak Ota
2010-11-30 5:27 ` collect-string Stephen J. Turnbull
2010-12-02 1:59 ` collect-string Tak Ota
2010-12-02 7:00 ` collect-string Stephen J. Turnbull
2010-12-02 14:16 ` collect-string Stefan Monnier
2010-12-03 1:03 ` collect-string Tak Ota
2010-12-03 19:17 ` collect-string Stefan Monnier
2010-12-03 22:31 ` collect-string Tak Ota
2010-12-03 22:40 ` collect-string Davis Herring
2010-12-03 22:47 ` collect-string Tak Ota
2010-12-03 22:56 ` collect-string Stefan Monnier
2010-12-03 23:15 ` collect-string Tak Ota
2010-12-04 2:01 ` collect-string Stefan Monnier
2010-12-04 2:07 ` collect-string Tak Ota
2010-12-04 3:27 ` collect-string Glenn Morris
2010-10-29 8:44 ` simple useful functions Andreas Schwab
2010-11-02 7:27 ` Andreas Röhler
2010-12-03 23:37 ` Tak Ota
2010-12-04 2:36 ` Stefan Monnier
2010-12-04 2:58 ` Tak Ota
2010-12-04 4:36 ` Stefan Monnier
2010-12-04 9:10 ` David Kastrup
2010-12-06 14:08 ` René Kyllingstad
2010-12-06 19:31 ` Stefan Monnier
2010-12-06 18:39 ` Tak Ota [this message]
2010-12-06 20:23 ` Stefan Monnier
2010-12-06 21:25 ` Tak Ota
2010-12-07 3:24 ` Stefan Monnier
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=20101206.103945.379575954.Takaaki.Ota@am.sony.com \
--to=takaaki.ota@am.sony.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/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.