unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc: stephen_leake@member.fsf.org, emacs-devel@gnu.org
Subject: Re: sourcing environment
Date: Wed, 11 Oct 2006 23:22:11 +0300	[thread overview]
Message-ID: <20061011202211.GA82982@gothmog.pc> (raw)
In-Reply-To: <20061011.121557.186976084.Takaaki.Ota@am.sony.com>

On 2006-10-11 12:15, Tak Ota <Takaaki.Ota@am.sony.com> wrote:
> Wed, 11 Oct 2006 22:00:12 +0300: Giorgos Keramidas <keramida@ceid.upatras.gr> 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?

I don't think so, but I don't know everything about Emacs :-/

> ;;
> ;; 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)))))

      reply	other threads:[~2006-10-11 20:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-10 22:09 sourcing environment Tak Ota
2006-10-11  8:35 ` Stephen Leake
2006-10-11 16:07   ` Tak Ota
2006-10-11 19:00     ` Giorgos Keramidas
2006-10-11 19:15       ` Tak Ota
2006-10-11 20:22         ` Giorgos Keramidas [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061011202211.GA82982@gothmog.pc \
    --to=keramida@ceid.upatras.gr \
    --cc=emacs-devel@gnu.org \
    --cc=stephen_leake@member.fsf.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).