在Windows和Ubuntu Emacs for PHP中收到Flymake错误

我收到这个错误。

Error (flymake): Flymake: Failed to launch syntax check process 'php' with args (-f test_flymake.php -l): Searching for program: no such file or directory, php. Flymake will be switched OFF 

我在使用emacs 24 GNU Emacs 24.1.1(i386-mingw-nt6.1.7601)的Windows 7上有一篇文章强调了这个错误,但是它指的是在Linux中检查/ etc,但是我在Windows上。 http://sachachua.com

这是我的.emacs目前相关的部分,我能做些什么来使它工作。

 (add-to-list 'load-path "C:/Users/renshaw family/AppData/Roaming/.emacs.d/elpa/flymake-0.4.11") (require 'flymake) (global-set-key [f3] 'flymake-display-err-menu-for-current-line) (global-set-key [f4] 'flymake-goto-next-error) ;;(require 'flymake-php) (require 'zencoding-mode) (add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes (defun flymake-php-init () "Use php to check the syntax of the current file." (let* ((temp (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local (file-relative-name temp (file-name-directory buffer-file-name)))) (list "php" (list "-f" local "-l")))) (add-to-list 'flymake-err-line-patterns '("\\(Parse\\|Fatal\\) error: +\\(.*?\\) in \\(.*?\\) on line \\([0-9]+\\)$" 3 4 nil 2)) (add-to-list 'flymake-allowed-file-name-masks '("\\.php$" flymake-php-init)) ;; Drupal-type extensions (add-to-list 'flymake-allowed-file-name-masks '("\\.module$" flymake-php-init)) (add-to-list 'flymake-allowed-file-name-masks '("\\.install$" flymake-php-init)) (add-to-list 'flymake-allowed-file-name-masks '("\\.inc$" flymake-php-init)) (add-to-list 'flymake-allowed-file-name-masks '("\\.engine$" flymake-php-init)) (add-hook 'php-mode-hook (lambda () (flymake-mode 1))) (define-key php-mode-map '[MS-up] 'flymake-goto-prev-error) (define-key php-mode-map '[MS-down] 'flymake-goto-next-error) 

编辑:

我现在已经在Ubuntu 12.04中尝试了这一点,并收到相同的错误。

它看起来像flymake找不到PHP解释器。 尝试添加关于在哪里可以找到PHP的显式提示。

有一种方法可以做到这一点,将以下defun添加到您的.emacs中:

 (defun my-flymake-get-php-cmdline (source base-dir) "Gets the command line invocation needed for running a flymake session in a PHP buffer. This gets called by flymake itself." (list "C:\Path\to\PHP\php.exe" ;; Or the path to the PHP CLI executable on the Ubuntu machine you mentioned. (list "-f" source "-l"))) 

然后修改你现在使用的flymate-php-init:

 (defun flymake-php-init () "Use php to check the syntax of the current file." (let* ( (temp (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local (file-relative-name temp (file-name-directory buffer-file-name)))) (get-cmdline-f 'my-flymake-get-php-cmdline))) 

这个建议很大程度上取决于其他人在Windows上使用flymake的答案 。 你也可能会发现答案有帮助,因为他们的情况与你的情况类似。