Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Flyspell error

542 views
Skip to first unread message

sam jesse

unread,
Jul 31, 2009, 8:06:33 PM7/31/09
to help-gn...@gnu.org
Hi
when I try to enable it, I get
Enabling Flyspell mode gave an error

GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) of 2008-09-07 on SOFT-MJASON under Windows XP.

how do I go about fixing this?

Thank you

Eli Zaretskii

unread,
Aug 1, 2009, 3:29:29 AM8/1/09
to help-gn...@gnu.org
> Date: Sat, 1 Aug 2009 10:06:33 +1000
> From: sam jesse <rev...@gmail.com>

Do you have ispell.exe or aspell.exe installed? If not, install them
first.

If you already have them installed and they work from outside Emacs,
then set the variables debug-on-error and debug-on-signal to t and try
again. You should get a backtrace with more details about where the
error happened. If you cannot figure that out, post the backtrace
here.


Eli Zaretskii

unread,
Aug 1, 2009, 6:01:08 AM8/1/09
to help-gn...@gnu.org
> Date: Sat, 1 Aug 2009 18:53:01 +1000
> From: sam jesse <rev...@gmail.com>
> Cc: help-gn...@gnu.org
>
> do I need to install both?

No. aspell comes with a shell script called `ispell' to emulate Ispell.

> I already installed aspell and the trace I am getting is:
>
> Debugger entered--Lisp error: (file-error "Searching for program" "no such
> file or directory" "ispell")
> call-process("ispell" nil t nil "-vv")

Maybe the shell script is not compatible with Windows. Do you have an
ispell.bat or ispell.cmd batch file as well? If not, perhaps create a
batch file that does what the `ispell' shell script does, and you
should be set.

(I don't use aspell, so I cannot help you if the above doesn't resolve
the problem.)


Richard Riley

unread,
Aug 1, 2009, 6:13:06 AM8/1/09
to
Eli Zaretskii <el...@gnu.org> writes:

I didnt see the whole thread, but does he have:

(setq-default ispell-program-name "aspell")


`

sam jesse

unread,
Aug 1, 2009, 4:53:01 AM8/1/09
to Eli Zaretskii, help-gn...@gnu.org
do I need to install both? I already installed aspell and the trace I am getting is:


Debugger entered--Lisp error: (file-error "Searching for program" "no such file or directory" "ispell")
  call-process("ispell" nil t nil "-vv")
  apply(call-process ("ispell" nil t nil "-vv"))
  ispell-call-process("ispell" nil t nil "-vv")
  ispell-check-version()
  byte-code("숁 " [nil (ispell-check-version) ((error))] 3)
  (defvar ispell-library-directory (byte-code "숁 " [nil ... ...] 3) ("c:/Documents and Settings/emp1/My Documents/emacs-22.3/lisp/textmodes/ispell.elc" . 25279))


also I have in my .emacs
(setq flyspell-mode t)
(setq debug-on-error t)
(setq debug-on-signal t)

On Sat, Aug 1, 2009 at 5:29 PM, Eli Zaretskii <el...@gnu.org> wrote:
> Date: Sat, 1 Aug 2009 10:06:33 +1000
> From: sam jesse <rev...@gmail.com>
>

> when I try to enable it, I get
> Enabling Flyspell mode gave an error
>
> GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) of 2008-09-07 on SOFT-MJASON under
> Windows XP.
>
> how do I go about fixing this?

Xah Lee

unread,
Aug 1, 2009, 5:58:13 PM8/1/09
to
On Aug 1, 1:53 am, sam jesse <rev...@gmail.com> wrote:
> do I need to install both? I already installed aspell and the trace I am
> getting is:
>
> Debugger entered--Lisp error: (file-error "Searching for program" "no such
> file or directory" "ispell")
> call-process("ispell" nil t nil "-vv")
> apply(call-process ("ispell" nil t nil "-vv"))
> ispell-call-process("ispell" nil t nil "-vv")
> ispell-check-version()
> byte-code("숁 " [nil (ispell-check-version) ((error))] 3)
> (defvar ispell-library-directory (byte-code "숁 " [nil ... ...] 3)
> ("c:/Documents and Settings/emp1/My
> Documents/emacs-22.3/lisp/textmodes/ispell.elc" . 25279))
>
> also I have in my .emacs
> (setq flyspell-mode t)
> (setq debug-on-error t)
> (setq debug-on-signal t)

make sure ispell is in your windows path.

e.g. here's what i have in my init file:

(when (string-equal system-type "windows-nt")
(progn
(setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/
cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/
System32/Wbem")
(setq exec-path
'(
"C:/Program Files (x86)/Emacs/emacs/bin/"
"C:/Windows/system32/"
"C:/Windows/"
"C:/Windows/System32/Wbem/"
"C:/Windows/system32/WindowsPowerShell/v1.0/"
"C:/cygwin/bin/"
)
)
)
)

Xah
http://xahlee.org/


sam jesse

unread,
Aug 2, 2009, 3:10:04 AM8/2/09
to Xah Lee, help-gn...@gnu.org
I installed Aspell and not Ispell.
I now have Start > Programs > Aspell ...
can I start this application on its own to see if it is working fine? it does not seam to provide a short cut for running the application.
I seam to missing the bigger picture; why the error trace says ispell when I have aspell installed, I have ispell.el and ispell.elc in
C:\Documents and Settings\emp1\My Documents\emacs-22.3\lisp\textmodes

Xah Lee

unread,
Aug 2, 2009, 4:02:45 PM8/2/09
to
On Aug 2, 12:10 am, sam jesse <rev...@gmail.com> wrote:
> I installed Aspell and not Ispell.
> I now have Start > Programs > Aspell ...
> can I start this application on its own to see if it is working fine?

type Win+r, then launch cmd.exe.
cd to your aspell dir, then type aspell. It should run like that.

> it
> does not seam to provide a short cut for running the application.
> I seam to missing the bigger picture; why the error trace says ispell when I
> have aspell installed, I have ispell.el and ispell.elc in
> C:\Documents and Settings\emp1\My Documents\emacs-22.3\lisp\textmodes

you need to tell emacs that your spelling program is aspell not
ispell.

Richard Riley gave you this:

> I didnt see the whole thread, but does he have:
> (setq-default ispell-program-name "aspell")

however, i cant' find the var ispell-program-name in my emacs. Don't
want to spend time on this but there a var somewhere you need to set
about that. Best to read the emacs's doc on the spelling section for
good detail ... you know how to use emacs's info doc?

seems to me you are new to emacs?

if so, i'd suggest you download emacsW32 to begin with because that
distribution made things much easier for window users.

Xah
http://xahlee.org/

Richard Riley

unread,
Aug 2, 2009, 4:28:53 PM8/2/09
to
Xah Lee <xah...@gmail.com> writes:

> On Aug 2, 12:10 am, sam jesse <rev...@gmail.com> wrote:
>> I installed Aspell and not Ispell.
>> I now have Start > Programs > Aspell ...
>> can I start this application on its own to see if it is working fine?
>
> type Win+r, then launch cmd.exe.
> cd to your aspell dir, then type aspell. It should run like that.
>
>> it
>> does not seam to provide a short cut for running the application.
>> I seam to missing the bigger picture; why the error trace says ispell when I
>> have aspell installed, I have ispell.el and ispell.elc in
>> C:\Documents and Settings\emp1\My Documents\emacs-22.3\lisp\textmodes
>
> you need to tell emacs that your spelling program is aspell not
> ispell.
>
> Richard Riley gave you this:
>
>> I didnt see the whole thread, but does he have:
>> (setq-default ispell-program-name "aspell")
>
> however, i cant' find the var ispell-program-name in my emacs. Don't

I'm not sure what you mean by "can't find".

http://www.emacswiki.org/emacs/InteractiveSpell

http://www.emacswiki.org/emacs/InteractiveSpell#toc5

,----
| You might be interested in using a different spell checker. In
| particular, Aspell is a fairly new replacement for much of Ispell’s
| functionality. Fortunately, using Aspell with Emacs is very easy:
|
| (setq ispell-program-name "aspell")
|
| (Aspell has an Ispell-emulation mode, so it behaves like ispell.el
| expects.)
|
| For lots more information on Aspell, see the Aspell website:
|
| * http://aspell.net/
|
| Compared with Ispell, Aspell is much better at coming up with suggested
| spellings, and at putting them in likely order. This is particularly
| useful when used with flyspell-auto-correct-previous-word, where you can
| iterate through suggested spellings – it’s much more useful when the
| correct spelling is near the head of the list.
|
| The problem with using aspell with flyspell is that in its default mode,
| it it a lot slower than ispell. Fortunately, you can tell it to speed
| up, though this reduces somewhat the quality of its suggestions. So try
| this:
|
| (setq ispell-program-name "aspell") (setq ispell-extra-args
| '("--sug-mode=ultra"))
|
| According to the aspell documentation, “ultra” is the fastest mode,
| which is still twice as slow as ispell; but I don’t notice the
| difference from ispell on my machine. If your machine is fast enough, a
| better option might be to try “fast” mode, which is twice as slow as
| “ultra”, but more accurate. The “normal” mode, which is the aspell
| default, is even more accurate, but is reportedly 10 times slower than
| “fast” mode, and on my machine it makes editing and motion around the
| buffer noticeably sluggish when in flyspell-mode. YMMV, depending on how
| fast your machine is, and how big your word-lists are.
`----

Lennart Borgman

unread,
Aug 2, 2009, 5:21:46 PM8/2/09
to Xah Lee, help-gn...@gnu.org
On Sun, Aug 2, 2009 at 10:02 PM, Xah Lee<xah...@gmail.com> wrote:
> Richard Riley gave you this:
>
>> I didnt see the whole thread, but does he have:
>> (setq-default ispell-program-name "aspell")
>
> however, i cant' find the var ispell-program-name in my emacs. Don't


It is in ispell.el, if you do (require 'ispell) first you can see it.

Perhaps it should be autoloaded.


Xah Lee

unread,
Aug 2, 2009, 8:08:50 PM8/2/09
to
Lennart Borgman answered the question. Thanks.

for me, i use speck.el, which i find better than ispell based flyspell-
* etc.

Xah

> | *http://aspell.net/

Xah Lee

unread,
Aug 2, 2009, 8:10:56 PM8/2/09
to
btw, recently someone posted a question about how to use hunspell.

I'd very much interested in that... i did some 1 hour research on
wikipedia about this in the past month... hunspell seems to be the
best one and used in opera, firefox etc.

anyone has tried to make it work with emacs?

Xah
http://xahlee.org/


sam jesse

unread,
Aug 3, 2009, 4:51:45 PM8/3/09
to Xah Lee, help-gn...@gnu.org
I am still trying to fix my spelling feature in emacs running on my windows XP.
when I hit M-$ I get

Starting new Ispell process [default] ...
apply: Searching for program: no such file or directory, aspell

in the trace.

I can run aspell from
C:\Program Files\Aspell\bin>

I have
"C:/Program Files/Aspell" "C:/Program Files/Aspell/bin"
in my load-path

and also I have aspell as the value of the variable ispell-program-name

what am I missing?

sam jesse

unread,
Aug 3, 2009, 4:54:58 PM8/3/09
to Xah Lee, help-gn...@gnu.org
here is what I get in the trace

Debugger entered--Lisp error: (file-error "Searching for program" "no such file or directory" "aspell")
  call-process("aspell" nil t nil "-v")
  apply(call-process ("aspell" nil t nil "-v"))
  ispell-call-process("aspell" nil t nil "-v")
  ispell-check-version()


On Tue, Aug 4, 2009 at 6:51 AM, sam jesse <rev...@gmail.com> wrote:
I am still trying to fix my spelling feature in emacs running on my windows XP.
when I hit M-$ I get

Starting new Ispell process [default] ...
apply: Searching for program: no such file or directory, aspell

in the trace.

I can run aspell from
C:\Program Files\Aspell\bin>

I have
"C:/Program Files/Aspell" "C:/Program Files/Aspell/bin"
in my load-path

and also I have aspell as the value of the variable ispell-program-name

what am I missing?

sam jesse

unread,
Aug 3, 2009, 7:12:06 PM8/3/09
to xah...@gmail.com, help-gn...@gnu.org
Thanks for giving a wider picture for what is going on.
let me first fix the PATH.

I noticed when I fired up cmd.exe and type aspell that it says
"aspell is not recognized as internal or external command",

so I went to the OS env var and added the location of aspell to the path like this ";C:\Program Files\Aspell\bin\" with out the (""), since this is the location I have to go to to fire up aspell. but when I go back to my C:\Documents and Settings\unsername> and typ aspell, it still gives me the same error as above.


On Tue, Aug 4, 2009 at 8:21 AM, Xah Lee <xah...@gmail.com> wrote:
Sam,

load-path is not relevant. The relevant vars discussed is exec-path and the PATH env var.

exec-path in emacs is the var that tells emacs which paths to search to locate external programs.

The PATH env var serves similar function in the OS's shell. It must be set correctly.

But also, emacs also needs to use the OS's PATH env var, and must inherited it correctly, as emacs does not always inherit it correctly due to various complications such as where or how you launched emacs, OS differences, etc.

Emacs's load-path is a set of paths for emacs to locate elisp files. It is irrevalent here.

i gave code in previous message on how you set exec-path and PATH.

you gotta pay attention to details here if you want to use emacs.

PS but note to emacs developers, it'd be really good to god damn include the essential unix utils as used by emacs. Their executable are tiny by today's standards, and saves huge amount of headache. In particular, spell checking is essential to emacs. On linuxes, all's peach n cream. But unfortunately, linux is used by minority however you count it. On OS X, it's also a pain with spell checking, as there are lots questions about getting it to work or how to use OS X's bundled spell checker that's far superior, yet nigh impossible to get emacs to use. On Windows, getting spell checking to work is a pain in the ass. Not possible unless you have fair degree of sys admin expertise and some emacs know how about all the path vars and mechanisms, AND, have the time to tech geek for fucking hours to get it to work (installing cygwin, dig into cygwin's interactions with OS, sundries minor compatibility issues, researching MinWGW and alternative unix binaries for Windows, dig into online forums ... ). Spell checking works out of the box on any commercial editor today.

  Xah



On Mon, Aug 3, 2009 at 1:51 PM, sam jesse <rev...@gmail.com> wrote:
I am still trying to fix my spelling feature in emacs running on my windows XP.
when I hit M-$ I get

Starting new Ispell process [default] ...
apply: Searching for program: no such file or directory, aspell

in the trace.

I can run aspell from
C:\Program Files\Aspell\bin>

I have
"C:/Program Files/Aspell" "C:/Program Files/Aspell/bin"
in my load-path

and also I have aspell as the value of the variable ispell-program-name

what am I missing?





--
 Xah
http://xahlee.org/

Xah Lee

unread,
Aug 3, 2009, 6:21:26 PM8/3/09
to sam jesse, help-gn...@gnu.org
Sam,

load-path is not relevant. The relevant vars discussed is exec-path and the PATH env var.

exec-path in emacs is the var that tells emacs which paths to search to locate external programs.

The PATH env var serves similar function in the OS's shell. It must be set correctly.

But also, emacs also needs to use the OS's PATH env var, and must inherited it correctly, as emacs does not always inherit it correctly due to various complications such as where or how you launched emacs, OS differences, etc.

Emacs's load-path is a set of paths for emacs to locate elisp files. It is irrevalent here.

i gave code in previous message on how you set exec-path and PATH.

you gotta pay attention to details here if you want to use emacs.

PS but note to emacs developers, it'd be really good to god damn include the essential unix utils as used by emacs. Their executable are tiny by today's standards, and saves huge amount of headache. In particular, spell checking is essential to emacs. On linuxes, all's peach n cream. But unfortunately, linux is used by minority however you count it. On OS X, it's also a pain with spell checking, as there are lots questions about getting it to work or how to use OS X's bundled spell checker that's far superior, yet nigh impossible to get emacs to use. On Windows, getting spell checking to work is a pain in the ass. Not possible unless you have fair degree of sys admin expertise and some emacs know how about all the path vars and mechanisms, AND, have the time to tech geek for fucking hours to get it to work (installing cygwin, dig into cygwin's interactions with OS, sundries minor compatibility issues, researching MinWGW and alternative unix binaries for Windows, dig into online forums ... ). Spell checking works out of the box on any commercial editor today.

  Xah


On Mon, Aug 3, 2009 at 1:51 PM, sam jesse <rev...@gmail.com> wrote:
I am still trying to fix my spelling feature in emacs running on my windows XP.
when I hit M-$ I get

Starting new Ispell process [default] ...
apply: Searching for program: no such file or directory, aspell

in the trace.

I can run aspell from
C:\Program Files\Aspell\bin>

I have
"C:/Program Files/Aspell" "C:/Program Files/Aspell/bin"
in my load-path

and also I have aspell as the value of the variable ispell-program-name

what am I missing?





--
 Xah
http://xahlee.org/

Xah Lee

unread,
Aug 3, 2009, 10:17:36 PM8/3/09
to
ok, first make sure the PATH env var in your Windows is setup
correctly.

some tips here

• Using PowerShell to Manage Environment Variables
http://xahlee.org/powershell/environment_variables.html

then, restart your cmd.exe (by just closing it).
After restart, type

echo %PATH%

e.g. on my machine shows:

C:\Users\xah>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\hp\bin
\Python;c:\Prog
ram Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
(x86)\Quic
kTime\QTSystem\;C:\Windows\system32\WindowsPowerShell\v1.0\

Once you got this, then type aspell from any dir and see it works.
You need to get this step fixed.

Once good, launch emacs, then in emacs, type Alt+x shell or Alt+x cmd-
shell (the latter is in emacsW32, not sure if it is in other emacs on
Windows)

then type
echo %PATH%

the output should match the same as in your cmd.exe. If not, try the
set paths elisp code:

(when (string-equal system-type "windows-nt")
(progn
(setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/
cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/
System32/Wbem")
(setq exec-path
'(
"C:/Program Files (x86)/Emacs/emacs/bin/"
"C:/Windows/system32/"
"C:/Windows/"
"C:/Windows/System32/Wbem/"
"C:/Windows/system32/WindowsPowerShell/v1.0/"
"C:/cygwin/bin/"
)
)
)
)

mod the path for your machine and put it in your emacs init file.
Select the code, then type Alt+x eval-region.

Now, close your shell buffer. Start it again. Try
echo %PATH%

again.
If good, type aspell while in emacs's cmd shell. It should run. If so,
hten you should be have spell checking in emacs now.

--------

on my machine, i have the above in my init file, but often the env var
PATH shown in emacs is still different from OS's PATH value. This
causes running SOME of the unix commands to fail. I haven't
investigated why yet, but i workaround by eval that code again in
emacs whenever that happens ....

nor do i know what exactly is the diff between exec-path and setenv
with PATH...

... spent way too much time writing this. Good luck.

Xah
http://xahlee.org/


sam jesse

unread,
Aug 4, 2009, 12:44:33 AM8/4/09
to Xah Lee, help-gn...@gnu.org
Thanks a lot for write this.
I followed through, the problem I am having is that the echo %PATH% output is not the same in the cmd.exe vs. the emacs shell.

here is the modified code in my .emacs.

***********************************************************


(when (string-equal system-type "windows-nt")
 (progn
   (setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin")
(setq exec-path
'(

"C:/Windows/system32/"
"C:/Windows/"
"C:/Windows/System32/Wbem/"
"C:/Windows/system32/WindowsPowerShell/v1.0/"
"C:/Program Files/Aspell/bin/"
)
 )
   )
 )

***********************************************************
I have a feeling there is something not write with my modification above.
Aspell is installed under "C:/Program Files/

cmd.exe > echo %PATH% puts out

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Aspell\bin\

emacs shell echo %PATH% puts out


/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/


should I copy the output from the cmd and put it in the code inside my .emacs?

suvayu ali

unread,
Aug 4, 2009, 1:34:40 PM8/4/09
to help-gn...@gnu.org
2009/8/3 sam jesse <rev...@gmail.com>:

> Thanks a lot for write this.
> I followed through, the problem I am having is that the echo %PATH% output
> is not the same in the cmd.exe vs. the emacs shell.
>
> here is the modified code in my .emacs.
>
> ***********************************************************
>
> (when (string-equal system-type "windows-nt")
>  (progn
>    (setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin")

I am an emacs newbie, so take everything I write with a grain of salt.
The path value quoted above looks valid for a *nix system not XP.

> should I copy the output from the cmd and put it in the code inside my
> .emacs?
>

Since you are on XP that would be a reasonable thing to try.

--
Suvayu

Open source is the future. It sets us free.


Eli Zaretskii

unread,
Aug 4, 2009, 2:10:12 PM8/4/09
to help-gn...@gnu.org
> Date: Tue, 4 Aug 2009 14:44:33 +1000
> From: sam jesse <rev...@gmail.com>
> Cc: help-gn...@gnu.org

>
> (when (string-equal system-type "windows-nt")
> (progn
> (setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin")

Huh? why do you set PATH to a Unixy value when you are on a Windows
machine?

You should instead set PATH to the same value you set exec-path (only
not as a Lisp list):

> (setq exec-path
> '(


> "C:/Windows/system32/"
> "C:/Windows/"
> "C:/Windows/System32/Wbem/"
> "C:/Windows/system32/WindowsPowerShell/v1.0/"

> "C:/Program Files/Aspell/bin/"

> emacs shell echo %PATH% puts out
>

> /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/

Of course! because that's what you set it to, above.


Xah Lee

unread,
Aug 4, 2009, 2:57:31 PM8/4/09
to

Thanks for catching that.

i set my PATH in my Windows emacs to unix paths because i'm mostly
using cygwin shell inside emacs...

i still need to do some study on the various paths to have a some sort
of more universal setup, so that i should be able to invoke cygwin or
Windows commands in all of emacs interactive shells: shell, cmd-shell,
powershell... as of now, am not sure that's even desirable... i guess
i needs to understand more about how these shells relates to each
other technically outside of emacs first... the path separator issue
of / vs \ and their automatic conversion in different shells has also
been a pain... in all shells (cygwin bash, cmd.exe, PowerShell) they
all have automatic conversion as you use the shell, but when you write
scripts or set paths, you can't arbitrarily use / or \ (even if
properly quoted in string), the rule for the omission of drive letter
is also a complex issue, and cygwin has some rather esoteric
mechanisms to map drives (e.g. in cygwin bash, “/cygdrive/c” maps to
“C:\”) ...

Xah

Xah Lee

unread,
Aug 4, 2009, 3:02:55 PM8/4/09
to
On Aug 4, 11:10 am, Eli Zaretskii <e...@gnu.org> wrote:
> > Date: Tue, 4 Aug 2009 14:44:33 +1000
> > From: sam jesse <rev...@gmail.com>
> > Cc: help-gnu-em...@gnu.org

>
> > (when (string-equal system-type "windows-nt")
> >  (progn
> >    (setenv "PATH" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin")
>
> Huh? why do you set PATH to a Unixy value when you are on a Windows
> machine?

my bad... am using cygwin.

> You should instead set PATH to the same value you set exec-path (only
> not as a Lisp list):

so the setenv PATH is equivalent to just setq exec-path? this is great
to know.

Xah

Xah Lee

unread,
Aug 4, 2009, 6:06:35 PM8/4/09
to
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/


sam jesse

unread,
Aug 4, 2009, 5:29:23 PM8/4/09
to Xah Lee, help-gn...@gnu.org
I tried to put
(when (string-equal system-type "windows-nt")
  (progn
     (setenv "PATH"  C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Aspell\bin\
.
.
.

do I need to replace \ with /?
do I need to replace ; with :? and if so, what about the : after the C?
this setenv, does it modify the PATH in my OS? if so, do I need to be logged in with admin account? and if I do modify it, does it effect my other programs in my windows XP?
I read the setenv and getenv but could not figure out the above.
why setenv PATH when there is setq exec-path?

Lennart Borgman

unread,
Aug 5, 2009, 1:52:46 AM8/5/09
to Xah Lee, help-gn...@gnu.org
On Wed, Aug 5, 2009 at 12:06 AM, Xah Lee<xah...@gmail.com> wrote:

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

w32shell.el (where cmd-shell lives) contains wrappers for the "shell"
function that comes with Emacs itself.

The purpose of it is to make it more easy to switch between uing cmd,
Cygwin, MSYS etc as the shell program in command shell. (The name is a
bit unfortunate. I did not know it was so hard to get additions like
this into Emacs so I choose something that could fit Emacs.)


Xah Lee

unread,
Aug 5, 2009, 3:03:34 AM8/5/09
to
On Aug 4, 2:29 pm, sam jesse <rev...@gmail.com> wrote:
> I tried to put
> (when (string-equal system-type "windows-nt")
> (progn
> (setenv "PATH"
> C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program
> Files\QuickTime\QTSystem\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Pro gram
> Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL
> Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL
> Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Aspell\bin\
> .
> .
> .
>
> do I need to replace \ with /?
> do I need to replace ; with :? and if so, what about the : after the C?
> this setenv, does it modify the PATH in my OS? if so, do I need to be logged
> in with admin account? and if I do modify it, does it effect my other
> programs in my windows XP?
> I read the setenv and getenv but could not figure out the above.
> why setenv PATH when there is setq exec-path?


I wrote a summary of my findings. Please see here:

• Difference between Emacs's “(setenv PATH ...)” and “(setq exec-
path ...)”
http://xahlee.org/emacs/emacs_env_var_paths.html

most your q are answered there.

here's your other ones:

> do I need to replace \ with /?
> do I need to replace ; with :?
> and if so, what about the : after the C?

Since my shell in emacs invokes the unix shell by cygwin bash, thus i
need to use unix conventions. In your case, stick with the Windows
convention.

> this setenv, does it modify the PATH in my OS?

No. It only effect how emacs sees the system's env var within emacs's
shells.

> why setenv PATH when there is setq exec-path?

see the link above. I gave a fair bit of explanation on why there are
two.

Oh, you need to escape the back quote in your string, because
backslash in emacs is a escaping mechanism in string. So, do like
this:

(setenv "PATH"
"C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem"

)

Xah
http://xahlee.org/


Anselm Helbig

unread,
Aug 5, 2009, 3:07:27 AM8/5/09
to
Hi!

I don't have that much windows experience, but I'll do my best. 8-)

> I tried to put
> (when (string-equal system-type "windows-nt")
>   (progn
>      (setenv "PATH"  C:\WINDOWS\system32;C:\
> WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\
> QuickTime\QTSystem\;C:\WINDOWS\system32\
> WindowsPowerShell\v1.0;c:\Program Files\Microsoft
> SQL Server\100\Tools\Binn\;c:\Program Files\
> Microsoft SQL Server\100\DTS\Binn\;c:\Program Files
> \Microsoft SQL Server\100\Tools\Binn\VSShell\
> Common7\IDE\;C:\Program Files\Aspell\bin\
> .
> .
> .
>
> do I need to replace \ with /?

Yes, either with / or you need to double the backslash like this: \\,
because the Backslash is the quoting character in emacs lisp strings.

> do I need to replace ; with :? and if so, what
> about the : after the C?

No, I think that would be wrong.

> this setenv, does it modify the PATH in my OS? if
> so, do I need to be logged in with admin account?
> and if I do modify it, does it effect my other
> programs in my windows XP?

You don't need admin rights to change environment variables. It only
has an effect on programs you start from within emacs.

> I read the setenv and getenv but could not figure
> out the above.
> why setenv PATH when there is setq exec-path?

`setenv' sets the environment variable. Whenever emacs uses the OS'
shell to start a program, the shell will see the value of PATH you set
in Emacs. However, Emacs can also start a program without using the
shell, and to this end it has exec-path.

`exec-path' gets set to the list of paths in your PATH environment
variable when emacs starts. Setting PATH in your .emacs is too late,
unfortunately. So to have everything in one place, I'd rather not
touch PATH or exec-path in .emacs, but rather set the system's PATH
correctly in the first place. This fixes the issue not only for Emacs
but for all other programs as well. You shouldn't need admin rights to
do this as this doesn't affect other users.

HTH,

Anselm


--
Anselm Helbig
mailto:anselm.helb...@googlemail.com

Xah Lee

unread,
Aug 5, 2009, 8:40:40 AM8/5/09
to
Hi Len,

thanks for the w32shell.el tip.

we chatted this before... but i'll have to spend some time down the
road to study this.

it'd be nice to integrate PowerShell into it too. Hopefully i can look
at it soon and maybe send you a patch.

On Aug 4, 10:52 pm, Lennart Borgman <lennart.borg...@gmail.com> wrote:


> On Wed, Aug 5, 2009 at 12:06 AM,XahLee<xah...@gmail.com> wrote:
> > btw, on Windows emacsW23, it has cmd-shell. Is this particular to
> > emacsW23 or is it in GNU Emacs's Windows branch?
>
> w32shell.el (where cmd-shell lives) contains wrappers for the "shell"
> function that comes with Emacs itself.

i believe you are saying that w32shell.el is NOT in GNU Emacs code
base right?

so, when people compile emacs 23 on Windows, they don't have cmd-
shell, but just shell, which invokes Windows's cmd.exe right?

what are the reasons not to have w32shell.el in GNU emacs? It seems to
me that it is good to have separate shells. Cause for me, i use all
cmd.exe, cygwin bash, and PowerShell on my Windows machine, and i'd
prefer to be able to run them indivdually while in emacs, instead of
one shell that has all these shell's paths togeter... at least the
unix cygwin bash shell wouldn't mesh well with Windows's.

> The purpose of it is to make it more easy to switch between uing cmd,
> Cygwin, MSYS etc as the shell program in command shell. (The name is a
> bit unfortunate. I did not know it was so hard to get additions like
> this into Emacs so I choose something that could fit Emacs.)

Thanks for the info.

Today i just compiled emacs 23 on my old PPC Mac, and it went very
smooth! I was fantastically happy. Especially so because my mac is a
late 2005 machine running OSX 10.4, and all the other Mac ports of
emacs all have abandoned it for about a year now. I haven't compiled a
program for years... last time i did compile emacs is sometimes in
2002, lol. This week or so i'll install cygwin gcc or whatever
Microsoft's compiler offerings (if free) and try to compile it on
Windows.

Xah
http://xahlee.org/


Eli Zaretskii

unread,
Aug 5, 2009, 1:14:44 PM8/5/09
to help-gn...@gnu.org
> From: Xah Lee <xah...@gmail.com>
> Date: Tue, 4 Aug 2009 15:06:35 -0700 (PDT)

>
> 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.

Actually, my advice is to have them both identical (well, actually,
equivalent, not identical, because one is a list while the other is a
string). That's because exec-path is used when Emacs invokes programs
directly (e.g., via `call-process') while PATH is used indirectly when
Emacs invokes programs via the shell, like in "M-x compile" or "M-x grep".
In the latter case, the shell will look for programs along PATH.
If your values are not equivalent, some Emacs commands that invoke
subsidiary programs will mysteriously fail, and unless you know very
well which Emacs command uses the shell and which does not, you will
have hard time figuring out how to set them correctly.

Of course, if PATH is modified before Emacs is started, then exec-path
will be automatically equivalent to PATH, because it's computed from
PATH's value.


Drew Adams

unread,
Aug 5, 2009, 1:25:17 PM8/5/09
to Eli Zaretskii, help-gn...@gnu.org
> Actually, my advice is to have them both identical (well, actually,
> equivalent, not identical, because one is a list while the other is a
> string). That's because exec-path is used when Emacs invokes programs
> directly (e.g., via `call-process') while PATH is used indirectly when
> Emacs invokes programs via the shell, like in "M-x compile"
> or "M-x grep".
> In the latter case, the shell will look for programs along PATH.
> If your values are not equivalent, some Emacs commands that invoke
> subsidiary programs will mysteriously fail, and unless you know very
> well which Emacs command uses the shell and which does not, you will
> have hard time figuring out how to set them correctly.
>
> Of course, if PATH is modified before Emacs is started, then exec-path
> will be automatically equivalent to PATH, because it's computed from
> PATH's value.

It might be good to add that advice to the Emacs manual. The last sentence,
about the default value of `exec-path', is there (in nodes `Single Shell' and
`Interactive Shell'), but not the rest.

There is also env var EMACSPATH, which is used to initialize `exec-path' (see
node `General Variables'). Note that the same thing is said, in the same node,
about env var `PATH'. Nothing is said about which of them takes precedence, if
both env vars are defined. And while PATH is mentioned in nodes `Single Shell'
and `Interactive Shell' as the start-time source of `exec-path', EMACSPATH is
not mentioned beyond the one-liner in node `General Variables'.

sam jesse

unread,
Aug 5, 2009, 1:46:27 PM8/5/09
to anselm.helb...@googlemail.com, help-gn...@gnu.org
OK

I made the code simple to cover my need:
*********************************************8

(when (string-equal system-type "windows-nt")
 (progn
   (setenv "PATH" "C:/Program Files/Aspell/bin/")
   (setq exec-path '("C:/Program Files/Aspell/bin") )
 )
)
***************************************************

but on M-$ I get

Debugger entered--Lisp error: (error "Error: No word lists can be found for the language \"en_US\".")
  signal(error ("Error: No word lists can be found for the language \"en_US\"."))
  error("%s" "Error: No word lists can be found for the language \"en_US\".")
  ispell-init-process()
  ispell-buffer-local-words()
  ispell-accept-buffer-local-defs()
  ispell-word(nil nil nil)
  call-interactively(ispell-word)

Xah Lee

unread,
Aug 5, 2009, 7:51:03 PM8/5/09
to

interesting and very informative.

For Windows emacs users who uses unix shell, won't there be
exceptions?

For example, i use emacs on windows, but right now predominately uses
unix shell cygwin

when i run “M-x shell” in emacs, i don't want my shell to touch any of
the Windows's executables if possible. e.g. i set PATH in emacs in a
way assuming i'm working in cygwin bash:

typical paths for unix shell:
"/usr/local/bin"
"/usr/bin"
"/bin"
"/usr/X11R6/bin"
"/cygdrive/c/Windows/Program Files (x86)/PHP/"

some Windows paths that are i think necessary in order for cygwin to
run.
"/cygdrive/c/Windows/system32"
"/cygdrive/c/Windows"
"/cygdrive/c/Windows/System32/Wbem"

but when i'm not in shell in emacs, i do want Windows emacs to be able
to access any normal Windows's executables, so my exec-path is like
this:

"C:/cygwin/bin/"
"C:/Program Files (x86)/Emacs/emacs/bin/"
"C:/Program Files (x86)/PHP/"


"C:/Windows/system32/"
"C:/Windows/"
"C:/Windows/System32/Wbem/"

if i just setenv PATH and just let emacs set exec-path, i think i ran
into some problems in emacs... that could be i messed something up in
my setenv PATH...

Xah
http://xahlee.org/


sam jesse

unread,
Aug 6, 2009, 3:48:32 AM8/6/09
to anselm.helb...@googlemail.com, help-gn...@gnu.org
any idea how to install an en word list to window xp for my aspell to work?

On Thu, Aug 6, 2009 at 3:46 AM, sam jesse <rev...@gmail.com> wrote:
OK

I made the code simple to cover my need:
*********************************************8
(when (string-equal system-type "windows-nt")
 (progn
   (setenv "PATH" "C:/Program Files/Aspell/bin/")
   (setq exec-path '("C:/Program Files/Aspell/bin") )
 )
)
***************************************************

but on M-$ I get

Debugger entered--Lisp error: (error "Error: No word lists can be found for the language \"en_US\".")
  signal(error ("Error: No word lists can be found for the language \"en_US\"."))
  error("%s" "Error: No word lists can be found for the language \"en_US\".")
  ispell-init-process()
  ispell-buffer-local-words()
  ispell-accept-buffer-local-defs()
  ispell-word(nil nil nil)
  call-interactively(ispell-word)
On Wed, Aug 5, 2009 at 5:07 PM, Anselm Helbig <anselm.helb...@googlemail.com> wrote:

Eli Zaretskii

unread,
Aug 7, 2009, 5:30:24 AM8/7/09
to help-gn...@gnu.org
> From: Xah Lee <xah...@gmail.com>
> Date: Wed, 5 Aug 2009 16:51:03 -0700 (PDT)

IMO, mixing a native Windows build of Emacs and Cygwin executables
that Emacs features need is asking for trouble. You can, of course,
make this work, but then you'd need to tinker quite a lot with Emacs
features, read their code, and change many defaults to make them work
as intended. PATH and exec-path are indeed two settings you will need
to put under tight control, to make things work. But I'm sure there
are others.

I don't recommend such a mix to anyone who needs Emacs on Windows to
"just work". If you like Cygwin, simply install the Cygwin build of
Emacs and be done. Emacs 23.1 _does_ supported the Cygwin build, and
after many years there's again an active maintainer of the Cygwin
Emacs. So any problems you find there will probably be fixed without
delays.

OTOH, if you need to be able to invoke native Windows programs from
Emacs, and Cygwin somehow doesn't let you to do that, use native
Windows ports exclusively. That is what I do, and I have yet to see a
significant problem that wouldn't be resolved by installing a native
Windows port of some utility, or by fixing some bug in Emacs. (For
example, yesterday I fixed Calc to allow graphing commands to work
with the native Windows port of Gnuplot.)

Keeping your work environment uniform and coherent will save you many
hours of grief and hair-pulling. Unless, of course, you like to
tinker, in which case the mix you have now is the way to go. I'm sure
you will learn a lot down the road, both about Emacs and about the
programs it invokes.

Xah Lee

unread,
Aug 7, 2009, 7:43:33 AM8/7/09
to

umm... good idea. Sounds like a good advice. Thanks.

> I'm sure
> you will learn a lot down the road, both about Emacs and about the
> programs it invokes.

O wait, this bit i don't think i agree. LOL.

Xah
http://xahlee.org/


0 new messages