I have seen examples online where people add paths to the default path in Emacs with:
(add-to-list 'exec-path "/usr/local/bin/")
I am new to Elisp, and I think I understand what the statement above does, but I have a few questions:
In what order does Emacs search through the execution paths? For example, does it consider the value of
$PATH
(env. variable) at all (and if so, before or afterexec-path
?)How can I prepend multiple such paths? Can I just keep concatenating them? e.g.
(add-to-list 'exec-path "PATH1", "PATH2")
or should I do:
(add-to-list 'exec-path "PATH1:PATH2:PATH3")
I also found this interesting package on GitHub: exec-path-from-shell. Why is there a need for a package for this?
Motivation
Ever find that a command works in your shell, but not in Emacs?
This happens a lot on OS X, where an Emacs instance started from the GUI inherits a default set of environment variables.
This library works solves this problem by copying important environment variables from the user's shell: it works by asking your shell to print out the variables of interest, then copying them into the Emacs environment.