all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Peter Dyballa <Peter_Dyballa@Web.DE>
To: Doug Lewan <dougl@shubertticketing.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: setenv and find-file
Date: Sat, 18 May 2013 12:07:02 +0200	[thread overview]
Message-ID: <C723B13F-6DE1-46A8-94BF-CACFBEB33486@Web.DE> (raw)
In-Reply-To: <155DEC68569B714B86C2C7075F5EDA9828F7A60D@DAKIYA1.pegasus.local>


Am 17.05.2013 um 23:07 schrieb Doug Lewan:

> I see a problem when M-x find-file is expanding ${VARIABLE} but not taking it from the newly defined environment variable. Everything else picks it up (I presume just via fork/exec).
> 
> I hope this script is clearer.
> 
> In shell:
>    $ echo ${VARIABLE}
>    /a/very/long/path
>    $ emacs &
> Inside emacs:
>    C-x C-f ${VARIABLE}/to/work                <== Finds "/a/very/long/path/to/work".
>    (setenv "VARIABLE" "/shorter/path")
>        => "/shorter/path"
>    M-! echo ${VARIABLE}
>    "/shorter/path"
>    M-x shell
> In shell inside emacs:
>    $ echo ${VARIABLE}
>    "/shorter/path"
> Back in emacs:
>    C-x C-f ${VARIABLE}/to/Grandmothers/house
> This finds the file "/a/very/long/path/to/Grandmothers/house", where I sort of expect it to find "/shorter/path/to/Grandmothers/house".

No, this cannot work in GNU Emacs with a regular *shell* buffer – maybe it works in VIM?

GNU Emacs is a host (or a PC) that allows other programmes to run inside it. Every variable the external (whatsoever: Korn, Bourne, C, …) shell interpreter is setting, is a private variable of and only inside this shell interpreter. And since it's just a shell interpreter it has no access to the variables of GNU Emacs. No shell function exists for this purpose.


The situation is a bit different when some shell variables are defined in a shell from which GNU Emacs is launched. These environment variables also exist in the GNU Emacs process, they are inherited by it, so they can be accessed:

	(getenv "PATH")

With this Elisp statement GNU Emacs has read an environment variable which the shell inside its *shell* buffer also has (the shell's $PATH can be different, because shell interpreter init files can set their own values), but GNU Emacs cannot use the shell interpreter's private value because there is no specialised function (yet) that creates automatically a GNU Emacs variable when you try to access either a (private) shell or an environment variable. In your init file you would need to create "normal" GNU Emacs variables and set their values with what you get from reading environment variables (not: private own shell variables).


Another different situation is when you use eshell instead of an external shell interpreter. This in Emacs Lisp written interpreter has access to all of GNU Emacs variables and functions and vice versa – presumingly! I'm not using it on a regular basis…


Since GNU Emacs and inferior processes are cleanly separated processes, there is no way that both can easily share variables and their values. They would need "neutral" external locations like regular files, pipes, sockets, FIFOs, LIFOs, shared memory areas, servers or services for data exchange (and extra programme code to make use of these external things). Since eshell and GNU Emacs are not separated they probably can share what you are thinking of. But used eshell users should comment on my opinion!

--
Greetings

  Pete     === -Q
             ==<__/% >>
_____________(_)____@_____________________________




  parent reply	other threads:[~2013-05-18 10:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17 15:29 setenv and find-file Doug Lewan
2013-05-17 19:14 ` Peter Dyballa
2013-05-17 20:52   ` andrea crotti
2013-05-17 21:07   ` Doug Lewan
2013-05-18  7:34     ` Eli Zaretskii
2013-05-20 11:42       ` Doug Lewan
2013-05-20 12:04         ` setenv and find-file (I take it back.) Doug Lewan
2013-05-18 10:07     ` Peter Dyballa [this message]
     [not found]     ` <mailman.27.1368871635.22516.help-gnu-emacs@gnu.org>
2013-05-18 11:36       ` setenv and find-file Barry Margolin
2013-05-18 18:09         ` Peter Dyballa

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=C723B13F-6DE1-46A8-94BF-CACFBEB33486@Web.DE \
    --to=peter_dyballa@web.de \
    --cc=dougl@shubertticketing.com \
    --cc=help-gnu-emacs@gnu.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 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.