2

我收到此错误。

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

我在 Windows 7 上使用 emacs 24 GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) 有一篇文章强调了这个错误,但它指的是在 linux 中检查 /etc 但是我在 Windows 上。http://sachchua.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 '[M-S-up] 'flymake-goto-prev-error)
(define-key php-mode-map '[M-S-down] 'flymake-goto-next-error)

编辑:

我现在也在 ubuntu 12.04 中尝试过这个并且收到同样的错误。

4

1 回答 1

1

看起来 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 for PHP 的回答。您可能还会发现该答案很有帮助,因为他们的情况与您的情况相似。

于 2012-07-26T00:33:09.847 回答