【问题标题】:Receiving Flymake error in Windows & Ubuntu Emacs for PHP在 Windows 和 Ubuntu Emacs for PHP 中接收 Flymake 错误
【发布时间】:2012-07-13 15:59:50
【问题描述】:

我收到此错误。

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://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 '[M-S-up] 'flymake-goto-prev-error)
(define-key php-mode-map '[M-S-down] 'flymake-goto-next-error)

编辑:

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

【问题讨论】:

  • 只是为了仔细检查 -- 是 "(add-to-list 'load-path "C:/Users/renshaw family/AppData/Roaming/.emacs.d/elpa/flymake-0.4.11")" 字面意思是你的 .emacs 中的内容,还是正斜杠只是拼写错误,实际文件具有 Windows 路径分隔符而不是 Unixy 路径分隔符?

标签: windows ubuntu emacs flymake nxhtml


【解决方案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)))

此建议很大程度上基于this answer from someone else using flymake on Windows for PHP。您可能还会发现该答案很有帮助,因为他们的情况与您的情况相似。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-11
    相关资源
    最近更新 更多