* dir-locals.el process-environment
@ 2018-02-19 18:44 edgar
0 siblings, 0 replies; 11+ messages in thread
From: edgar @ 2018-02-19 18:44 UTC (permalink / raw)
To: help-gnu-emacs
Hi, I am trying to customise my building environment (debugging
included). I have this in my .dir-locals.el
(("src" ;https://stackoverflow.com/a/19521152
. ((c++-mode
;https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
.
((eval ;https://emacs.stackexchange.com/a/35965
. (progn
(make-local-variable 'process-environment)
(setq process-environment
(copy-sequence process-environment))
(setenv "CC" "mpicc"))))))))
However, if I printf "$CC" I get nothing. How can I achieve this?
Thanks.
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 11+ messages in thread
* dir-locals.el process-environment
@ 2018-02-26 4:30 edgar
2018-02-26 19:15 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: edgar @ 2018-02-26 4:30 UTC (permalink / raw)
To: help-gnu-emacs
Did someone receive my question? Is this the right mailing list? Thanks!
Hi, I am trying to customise my building environment (debugging
included). I have this in my .dir-locals.el
(("src" ;https://stackoverflow.com/a/19521152
. ((c++-mode
;https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
.
((eval ;https://emacs.stackexchange.com/a/35965
. (progn
(make-local-variable 'process-environment)
(setq process-environment
(copy-sequence process-environment))
(setenv "CC" "mpicc"))))))))
However, if I printf "$CC" I get nothing. How can I achieve this?
Thanks.
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.25.1519750804.23377.help-gnu-emacs@gnu.org>]
* Re: dir-locals.el process-environment
@ 2018-02-28 22:18 edgar
2018-03-01 3:32 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: edgar @ 2018-02-28 22:18 UTC (permalink / raw)
To: help-gnu-emacs
Yes! Sorry again. Thank you for your help. The whole process is like
this:
1. create .dir-locals.el in the top directory with this:
(
("src" ;https://stackoverflow.com/a/19521152
. ((c++-mode
;https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
.
((eval ;https://emacs.stackexchange.com/a/35965
. (progn
(make-local-variable 'process-environment)
(setq process-environment
(copy-sequence process-environment))
(setenv "CC" "mpicc")))
(compile-command . "printf x$CC"))))))
2. visit src/main.C (it can be empty)
3. press F5 (or M-x compile RET)
Actual output
The result is a buffer with the following contents.
-*- mode: compilation; default-directory: "src/" -*-
Compilation started at DATE
printf x$CC
x
Compilation finished at DATE
Expected output
I was expecting
-*- mode: compilation; default-directory: "src/" -*-
Compilation started at DATE
printf x$CC
xmpicc
Compilation finished at DATE
System specifications
- GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of
2017-09-22, modified by Debian
- Linux 4.13.0-32-generic #35-Ubuntu (it's not like Ubuntu is my cup of
tea, but it was the best compromise at the time)
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: dir-locals.el process-environment
2018-02-28 22:18 edgar
@ 2018-03-01 3:32 ` Eli Zaretskii
0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2018-03-01 3:32 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 28 Feb 2018 22:18:50 +0000
> From: edgar@openmail.cc
>
> 1. create .dir-locals.el in the top directory with this:
>
> (
> ("src" ;https://stackoverflow.com/a/19521152
> . ((c++-mode
>
> ;https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
> .
> ((eval ;https://emacs.stackexchange.com/a/35965
> . (progn
> (make-local-variable 'process-environment)
> (setq process-environment
> (copy-sequence process-environment))
> (setenv "CC" "mpicc")))
> (compile-command . "printf x$CC"))))))
>
> 2. visit src/main.C (it can be empty)
> 3. press F5 (or M-x compile RET)
>
> Actual output
> The result is a buffer with the following contents.
> -*- mode: compilation; default-directory: "src/" -*-
> Compilation started at DATE
>
> printf x$CC
> x
> Compilation finished at DATE
>
> Expected output
> I was expecting
> -*- mode: compilation; default-directory: "src/" -*-
> Compilation started at DATE
>
> printf x$CC
> xmpicc
> Compilation finished at DATE
You make process-environment local to the buffer main.c, but
compilation runs in its own buffer, *compilation*, where
process-environment doesn't include the $CC setting.
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.23.1519923605.5908.help-gnu-emacs@gnu.org>]
* Re: dir-locals.el process-environment
[not found] <mailman.23.1519923605.5908.help-gnu-emacs@gnu.org>
@ 2018-03-02 2:25 ` edgar
2018-03-02 14:13 ` Stefan Monnier
0 siblings, 1 reply; 11+ messages in thread
From: edgar @ 2018-03-02 2:25 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Thu, 01 Mar 2018 05:32:53 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: dir-locals.el process-environment>
>
> You make process-environment local to the buffer main.c, but
> compilation runs in its own buffer, *compilation*, where
> process-environment doesn't include the $CC setting.
Thanks, Eli. I removed the line
(make-local-variable 'process-environment)
and now the compile command shows what I expected :) . Than you for your
time!
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: dir-locals.el process-environment
2018-03-02 2:25 ` edgar
@ 2018-03-02 14:13 ` Stefan Monnier
0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2018-03-02 14:13 UTC (permalink / raw)
To: help-gnu-emacs
>> You make process-environment local to the buffer main.c, but
>> compilation runs in its own buffer, *compilation*, where
>> process-environment doesn't include the $CC setting.
Maybe `compile` should take its process-environment from the buffer from
which it is invoked, rather than from the buffer in which the command is run.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.23.1520010004.25009.help-gnu-emacs@gnu.org>]
* Re: dir-locals.el process-environment
[not found] <mailman.23.1520010004.25009.help-gnu-emacs@gnu.org>
@ 2018-03-03 5:40 ` edgar
0 siblings, 0 replies; 11+ messages in thread
From: edgar @ 2018-03-03 5:40 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 02 Mar 2018 09:13:07 -0500
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> To: help-gnu-emacs@gnu.org
> Subject: Re: dir-locals.el process-environment
> Message-ID: <jwv4llybm7s.fsf-monnier+gmane.emacs.help@gnu.org>
>
> Maybe `compile` should take its process-environment from the buffer
> from
> which it is invoked, rather than from the buffer in which the command
> is run.
>
>
> Stefan
It's not a bad idea Stefan, but I am not a fan of buffer-local variables
(if that is what you mean). I find it intrusive for other users. Thanks
for the suggestion.
I still have to check if the debugging will use those environmental
variables :P .
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: dir-locals.el process-environment
@ 2018-05-17 19:55 edgar
0 siblings, 0 replies; 11+ messages in thread
From: edgar @ 2018-05-17 19:55 UTC (permalink / raw)
To: help-gnu-emacs
On Sat, 03 Mar 2018 05:40:03 +0000
> I still have to check if the debugging will use those environmental
> variables :P .
Hello,
I want to report on my progress. This allows me to source environment
variables for process-environment, which is used for compilation and
debugging (gdb). The variables are set with a BASH script. I hope
that it is useful to others.
Note that
1. the name of the sourced file needs to be changed:
`/path/to/environment/file.sh'
2. Emac's `compile-command' may not need the `METHOD=dbg' (it's
something for me)
3. `$ENV_VAR_CPU' sets set the number of processes to run with
make. This variable is defined in `/path/to/environment/file.sh'.
┌────
│ (
│ ("src" ;https://stackoverflow.com/a/19521152
│ .
│ (
│ (c++-mode
│ .
│ (
│ (eval ;https://emacs.stackexchange.com/a/35965
│ . (progn
│ (with-temp-buffer
;https://stackoverflow.com/a/16789182
│ (call-process "bash" nil t nil "-c"
│ "source /path/to/environment/file.sh; env")
│ (goto-char (point-min))
│ (while (not (eobp))
│ (setq process-environment
│ (cons (buffer-substring (point)
(line-end-position))
│ process-environment))
│ (forward-line 1)))
│ ))
│
│ (compile-command
│ . (concat
│ "METHOD=dbg make -j $ENV_VAR_CPU -C ../"))
│ )
│ )
│ )
│ )
│ )
└────
This is how I check if the environment is working:
┌────
│ # https://stackoverflow.com/a/32917097
│ xargs -0 printf %s\\n < /proc/($pidof gdb)/environ
└────
These threads may be related:
[https://stackoverflow.com/a/9669183]
[https://lists.gnu.org/archive/html/help-gnu-emacs/2008-06/msg00158.html]
[https://lists.gnu.org/archive/html/help-gnu-emacs/2008-06/msg00063.html]
[https://lists.gnu.org/archive/html/help-gnu-emacs/2018-02/msg00162.html]
[https://lists.gnu.org/archive/html/help-gnu-emacs/2018-03/msg00007.html]
Thanks for your help!
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2018-05-17 19:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-19 18:44 dir-locals.el process-environment edgar
-- strict thread matches above, loose matches on Subject: below --
2018-02-26 4:30 edgar
2018-02-26 19:15 ` Eli Zaretskii
[not found] <mailman.25.1519750804.23377.help-gnu-emacs@gnu.org>
2018-02-28 5:47 ` edgar
2018-02-28 16:37 ` Eli Zaretskii
2018-02-28 22:18 edgar
2018-03-01 3:32 ` Eli Zaretskii
[not found] <mailman.23.1519923605.5908.help-gnu-emacs@gnu.org>
2018-03-02 2:25 ` edgar
2018-03-02 14:13 ` Stefan Monnier
[not found] <mailman.23.1520010004.25009.help-gnu-emacs@gnu.org>
2018-03-03 5:40 ` edgar
2018-05-17 19:55 edgar
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).