简体   繁体   English

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

[英]Receiving Flymake error in Windows & Ubuntu Emacs for PHP

I am receiving this error. 我收到此错误。

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

I am on windows 7 with emacs 24 GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) There is an article which highlights this error but it is referring to checking /etc in linux however I am on windows. 我在Windows 7上使用emacs 24 GNU Emacs 24.1.1(i386-mingw-nt6.1.7601)有一篇文章强调了此错误,但它指的是在Linux中检查/ etc,但是我在Windows上。 http://sachachua.com http://sachachua.com

This is the currently relevant part of my .emacs, what can I do to get it working. 这是我的.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)

Edit: 编辑:

I have now tried this in ubuntu 12.04 as well and receive the same error. 我现在也在ubuntu 12.04中尝试过此操作,并收到相同的错误。

It looks like flymake can't find the PHP interpreter. 看起来flymake无法找到PHP解释器。 Try adding an explicit hint about where to find PHP. 尝试添加有关在哪里可以找到PHP的明确提示。

One way you could do this is by adding the following defun to your .emacs: 一种方法是在.emacs中添加以下defun:

(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")))

Then modifying the flymate-php-init you're using now into this: 然后将您现在使用的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)))

This advice is heavily based on this answer from someone else using flymake on Windows for PHP . 该建议很大程度上基于其他人在Windows for PHP上使用flymake的答案 You might also find that answer helpful, since their situation is similar to yours. 您可能还会发现该答案很有用,因为他们的情况与您的情况相似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM