unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* 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
[parent not found: <mailman.23.1519923605.5908.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.23.1520010004.25009.help-gnu-emacs@gnu.org>]
* 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).