emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating and accessing environmental variables


From: Ship Mints
Subject: Re: Creating and accessing environmental variables
Date: Sun, 8 Dec 2024 15:14:11 -0500

Sheesh, I need more coffee... More like this since it's an OS path:

  (concat "/tmp/foo/bar" path-separator (getenv "PATH"))

On Sun, Dec 8, 2024 at 2:51 PM Ship Mints <shipmints@gmail.com> wrote:
Couple of things. First, you should not be concatenating paths like you showed. Do the following instead and it will be cross platform and more "correct":

  (file-name-concat "/tmp/foo/bar" (getenv "PATH"))

Second, a question. After you setenv your PATH, in eshell, what does "echo $PATH" show?

On Sun, Dec 8, 2024 at 1:51 PM the_wurfkreuz via Emacs development discussions. <emacs-devel@gnu.org> wrote:
Is it possible to set environment variables and access them immediately without reloading the Emacs configuration (like using the load-file function)?

For instance, when I evaluate this code to set the PATH variable:

(let ((paths '("/some/path"
              "/some/path/2")))
  ;; (setq exec-path (append paths exec-path))
  (setenv "PATH" (concat (string-join paths ":")
                        ":"
                        (getenv "PATH"))))

And then try to launch eshell in the current Emacs session, I find that the new values aren't appended. The only way to set them is to put the code into a config file and reload it through (load-file "~/.emacs.d/init.el").

reply via email to

[Prev in Thread] Current Thread [Next in Thread]