gpt4 book ai didi

windows - 在 Windows 和 Ubuntu Emacs for PHP 中接收 Flymake 错误

转载 作者:可可西里 更新时间:2023-11-01 10:38:36 24 4
gpt4 key购买 nike

我收到此错误。

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 中尝试了这个并且收到了同样的错误。

最佳答案

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

关于windows - 在 Windows 和 Ubuntu Emacs for PHP 中接收 Flymake 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11474077/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com