help-gnu-emacs
[Top][All Lists]
Advanced

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

setevn PATH vs exec-path [was Re: Flyspell error]


From: Xah Lee
Subject: setevn PATH vs exec-path [was Re: Flyspell error]
Date: Tue, 4 Aug 2009 15:06:35 -0700 (PDT)
User-agent: G2/1.0

spent some time to study the diff between (setenv "PATH" ...) vs (setq
exec-path ...).

Their docs are here:

• System Environment - GNU Emacs Lisp Reference Manual
  http://xahlee.org/elisp/System-Environment.html
  (info "(elisp) System Environment")

• Subprocess Creation - GNU Emacs Lisp Reference Manual
  http://xahlee.org/elisp/Subprocess-Creation.html
  (info "(elisp) Subprocess Creation")


in summary:

“setenv” is for setting OS env vars within emacs. Unixes and Windows
both have env vars. Env vars are global info available to processes
(apps). A process is free to use the info in env var. Some env var are
important as they contain system info such as Windows WINDIR that
contains OS path, and PATH in both Windows and unixes that specify
program paths. Many are config items such as HOME dir in unix and
Windows, and “locale” in unixes. When a process launchs, it inherits
(have access) to all the env vars where the process is launched.

emacs uses the system's env var just like other apps, but more
importantly, emacs shells are interfaces to OS's shells, so as a sys
admin or programer who uses emacs, you want to be able to config
system's env vars as seen in shell within emacs when emacs startup a
shell. (this is done with emacs commands “setenv” and “getenv”, which
are wrappers that manipulate emacs's process-environment var.)

Emacs's “exec-path” var is actually the var emacs uses to locate
external programs. Here's a quote: «Emacs initializes exec-path when
it starts up, based on the value of the environment variable PATH.»

So, the system's PATH env var and emacs exec-path needs not to be the
same, and ideally their values probably shouldn't be identical if one
is a control freak, since they serve different purposes.

The value for exec-path is important to emacs in locating programs,
while the PATH system env var is more important in using emacs as a
shell.

so, judging from all i know, getting aspell to work in emacs means
exec-path should contain the path to aspell. Since emacs set exec-path
to system's PATH env var when it starts, thus setting aspell path in
OS's PATH env var should work too.

Ok. Great to have studied this at least a bit now.

btw, on Windows emacsW23, it has cmd-shell. Is this particular to
emacsW23 or is it in GNU Emacs's Windows branch?

  Xah
∑ http://xahlee.org/

reply via email to

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