Workaround a bug for octave-mode of Emacs 25.2.50 under MS-Windows

When I switched to the master branch of Emacs, I found that octave-mode doesn’t work correctly. The run-octave will result in the crash of “octave-gui.exe”, even without the configuration file. Afer hours of digging, I think the problem is related to the default-directory. That is, no matter what the PATH is, only when the default-directory being the directory of octave program can make it work. This may relate to the octave, but in Emacs 24.5 run-octave works correctly. Strang enough. I can workaround the problem by temporarily setting the default-directory. The code looks like:

1
2
3
(let ((default-directory (file-name-directory
(executable-find inferior-octave-program))))
(run-octave))

MS-Windows下变通解决Emacs 25.2.50的octave-mode的bug

当换到master分支后,我发现octave-mode工作不正常了,现象是“octave-gui.exe”崩溃。我捉摸了好长时间,觉得问题出在default-directory取值的问题,不论PATH怎么设置,只有default-directory是octave.exe所在目录时才不会崩溃。这似乎和octave有关系,但Emacs 24.5是正常的,很奇怪。要完全解决这个问题我的功力恐怕不够,只要暂时设置default-directory就好了。代码就像下面的样子:

1
2
3
(let ((default-directory (file-name-directory
(executable-find inferior-octave-program))))
(run-octave))