Elisp: exec-path, External Program Search Paths
exec-path
- exec-path
-
List of dir paths to search external programs. An element may be nil, it means default-directory.
By default the last element of this list is exec-directory (the emacs bin dir.) .
Emacs uses exec-path to find executable binary programs.
For example,
- Alt+x
diff
tries to find unixdiff
- Alt+x
grep
tries to find unixgrep
- Alt+x
shell
tries to find unixbash
if emacs is on linux. - Alt+x
dired-do-compress
tries to find unixgzip
- Alt+x
ispell-word
tries to find unixispell
oraspell
By default, emacs copies the value of (getenv "PATH")
to exec-path. So, their values should be identical.
Here's a example of setting exec-path:
(when (eq system-type 'windows-nt) (push (expand-file-name "~/bin/oxipng/") exec-path))
Difference between exec-path and PATH
- The value of environment variable “PATH” is used by emacs when you are trying to call a linux command from a shell in emacs.
- The exec-path is used by emacs itself to find programs it needs for its features, such as spell checking, file compression, compiling, grep, diff, etc.
The value of (getenv "PATH")
and exec-path do not need to be the same.