all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* setenv and find-file
@ 2013-05-17 15:29 Doug Lewan
  2013-05-17 19:14 ` Peter Dyballa
  0 siblings, 1 reply; 10+ messages in thread
From: Doug Lewan @ 2013-05-17 15:29 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

It seems like I'm seeing the following.

1. Change a shell variable via (setenv "NAME" "value").
2. Use that variable in subshells in various ways and life is fine.
   M-x ! echo ${NAME}	=> value
   M-x shell		inherits the value
3. Find a file using that variable and C-x C-f uses the /previous/ value.

So, would anyone mind confirming that for me. (I'm easily confused.) Should this be regarded as a bug?

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: setenv and find-file
  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
  0 siblings, 2 replies; 10+ messages in thread
From: Peter Dyballa @ 2013-05-17 19:14 UTC (permalink / raw)
  To: Doug Lewan; +Cc: help-gnu-emacs@gnu.org


Am 17.05.2013 um 17:29 schrieb Doug Lewan:

> 3. Find a file using that variable and C-x C-f uses the /previous/ value.

Can you describe, in other words, maybe in more than one sentence, what the cited line is trying to express? I only understand "station"…

--
Greetings

  Pete

We have to expect it, otherwise we would be surprised.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: setenv and find-file
  2013-05-17 19:14 ` Peter Dyballa
@ 2013-05-17 20:52   ` andrea crotti
  2013-05-17 21:07   ` Doug Lewan
  1 sibling, 0 replies; 10+ messages in thread
From: andrea crotti @ 2013-05-17 20:52 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs@gnu.org

2013/5/17 Peter Dyballa <Peter_Dyballa@web.de>

>
> Am 17.05.2013 um 17:29 schrieb Doug Lewan:
>
> > 3. Find a file using that variable and C-x C-f uses the /previous/ value.
>
> Can you describe, in other words, maybe in more than one sentence, what
> the cited line is trying to express? I only understand "station"…
>
>
I think he means that doing
C-x C-f $VAR/path
doesn't expand the variable to the value that he just assigned to it, right?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: setenv and find-file
  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
                       ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Doug Lewan @ 2013-05-17 21:07 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Peter,

Sorry if I was too terse.

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".

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?

-----Original Message-----
From: Peter Dyballa [mailto:Peter_Dyballa@Web.DE] 
Sent: Friday, 2013 May 17 15:14
To: Doug Lewan
Cc: help-gnu-emacs@gnu.org
Subject: Re: setenv and find-file


Am 17.05.2013 um 17:29 schrieb Doug Lewan:

> 3. Find a file using that variable and C-x C-f uses the /previous/ value.

Can you describe, in other words, maybe in more than one sentence, what the cited line is trying to express? I only understand "station"...

--
Greetings

  Pete

We have to expect it, otherwise we would be surprised.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: setenv and find-file
  2013-05-17 21:07   ` Doug Lewan
@ 2013-05-18  7:34     ` Eli Zaretskii
  2013-05-20 11:42       ` Doug Lewan
  2013-05-18 10:07     ` setenv and find-file Peter Dyballa
       [not found]     ` <mailman.27.1368871635.22516.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2013-05-18  7:34 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Doug Lewan <dougl@shubertticketing.com>
> Date: Fri, 17 May 2013 21:07:51 +0000
> 
> 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".

I cannot reproduce this.  What version of Emacs is this, and on what
OS?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: setenv and find-file
  2013-05-17 21:07   ` Doug Lewan
  2013-05-18  7:34     ` Eli Zaretskii
@ 2013-05-18 10:07     ` Peter Dyballa
       [not found]     ` <mailman.27.1368871635.22516.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Dyballa @ 2013-05-18 10:07 UTC (permalink / raw)
  To: Doug Lewan; +Cc: help-gnu-emacs@gnu.org


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
             ==<__/% >>
_____________(_)____@_____________________________




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: setenv and find-file
       [not found]     ` <mailman.27.1368871635.22516.help-gnu-emacs@gnu.org>
@ 2013-05-18 11:36       ` Barry Margolin
  2013-05-18 18:09         ` Peter Dyballa
  0 siblings, 1 reply; 10+ messages in thread
From: Barry Margolin @ 2013-05-18 11:36 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]

In article <mailman.27.1368871635.22516.help-gnu-emacs@gnu.org>,
 Peter Dyballa <Peter_Dyballa@Web.DE> wrote:

> 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.

But if you do:

M-: (setenv "VARIABLE" "/shorter/path")

inside Emacs, you're setting an environment variable in the Emacs 
process, not just within a program that's hosted by Emacs.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: setenv and find-file
  2013-05-18 11:36       ` Barry Margolin
@ 2013-05-18 18:09         ` Peter Dyballa
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Dyballa @ 2013-05-18 18:09 UTC (permalink / raw)
  To: Barry Margolin; +Cc: help-gnu-emacs


Am 18.05.2013 um 13:36 schrieb Barry Margolin:

> But if you do:
> 
> M-: (setenv "VARIABLE" "/shorter/path")
> 
> inside Emacs, you're setting an environment variable in the Emacs 
> process, not just within a program that's hosted by Emacs.

And when a shell in *shell* buffer is started afterwards it can inherit that setting… Yes, that could be another away! (Given that either a corresponding GNU Emacs variable is also defined or (getenv "VARIABLE") is used.)

--
Greetings

  Pete                           <]
             o        __o         |__    o       HPV, the real
    ___o    /I       -\<,         |o \  -\),-%     high speed!
___/\ /\___./ \___...O/ O____.....`-O-'-()--o_________________




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: setenv and find-file
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Doug Lewan @ 2013-05-20 11:42 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Eli,

Version and OS? Sorry, I forgot. (And it turns out to be important!)

This funny behavior happens on

    emacs version 24.3.1
    OS: AIX 6.1

It does NOT happen with on CYGWIN (also emacs version 24.3.1). Hmmmm.


,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?


-----Original Message-----
From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On Behalf Of Eli Zaretskii
Sent: Saturday, 2013 May 18 03:34
To: help-gnu-emacs@gnu.org
Subject: Re: setenv and find-file

> From: Doug Lewan <dougl@shubertticketing.com>
> Date: Fri, 17 May 2013 21:07:51 +0000
> 
> 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".

I cannot reproduce this.  What version of Emacs is this, and on what
OS?




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: setenv and find-file (I take it back.)
  2013-05-20 11:42       ` Doug Lewan
@ 2013-05-20 12:04         ` Doug Lewan
  0 siblings, 0 replies; 10+ messages in thread
From: Doug Lewan @ 2013-05-20 12:04 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

I take it back. I can't reproduce this on AIX anymore. Sorry for the trouble. :(

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?


-----Original Message-----
From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On Behalf Of Doug Lewan
Sent: Monday, 2013 May 20 07:43
To: help-gnu-emacs@gnu.org
Subject: RE: setenv and find-file

Eli,

Version and OS? Sorry, I forgot. (And it turns out to be important!)

This funny behavior happens on

    emacs version 24.3.1
    OS: AIX 6.1

It does NOT happen with on CYGWIN (also emacs version 24.3.1). Hmmmm.


,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?


-----Original Message-----
From: help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org [mailto:help-gnu-emacs-bounces+dougl=shubertticketing.com@gnu.org] On Behalf Of Eli Zaretskii
Sent: Saturday, 2013 May 18 03:34
To: help-gnu-emacs@gnu.org
Subject: Re: setenv and find-file

> From: Doug Lewan <dougl@shubertticketing.com>
> Date: Fri, 17 May 2013 21:07:51 +0000
> 
> 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".

I cannot reproduce this.  What version of Emacs is this, and on what
OS?





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-05-20 12:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` setenv and find-file Peter Dyballa
     [not found]     ` <mailman.27.1368871635.22516.help-gnu-emacs@gnu.org>
2013-05-18 11:36       ` Barry Margolin
2013-05-18 18:09         ` Peter Dyballa

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.