我正在尝试从Haxe编译器提供flymake输出,但我不知道如何告诉make文件所在的位置(理想情况下,我会使用nxml文件)。到目前为止,我在Makefile中有这个:
BIN = ./bin
MAIN = com.wunderwafer.Main
SWF = wunderwafer.swf
SWFSETTINGS = -debug -swf-version 10 -swf-header 800:600:31
HFLAGS = -main $(MAIN) $(SWFSETTINGS) -cp ./src -swf $(BIN)/$(SWF)
HC = haxe
default: compile
compile: $(HC) $(HFLAGS)
clean:
$(RM) -r $(BIN)/*
.PHONY: check-syntax
check-syntax:
$(HC) $(HFLAGS)
如果我稍后运行它:
$ make -k check-syntax
它产生预期的输出。但是flymake无法找到Makefile(或者看起来似乎如此),因为我试图检查的文件在src目录中更深。
配置flymake的方法是什么,以便知道makefile的位置? (或者,更好的是,只需执行shell命令,因为编译Haxe代码的常用方法是使用* .nxml设置文件。
修改
看起来我越来越近了,非常感谢,但是flymake正在做一些奇怪的事情,我无法理解它到底是做什么的,所以,这是日志:
received 65 byte(s) of output from process 967
file /home/wvxvw/projects/wafer/src/com/wunderwafer/map/Battlefield.hx, init=haxe-flymake-init
parsed 'Error : Invalid class name /home/wvxvw/projects/wafer/build.nxml', no line-err-info
file /home/wvxvw/projects/wafer/src/com/wunderwafer/map/Battlefield.hx, init=haxe-flymake-init
process 967 exited with code 1
cleaning up using haxe-flymake-cleanup
deleted file /tmp/flymake-Battlefield-855Cad.hx
Battlefield.hx: 0 error(s), 0 warning(s) in 0.15 second(s)
switched OFF Flymake mode for buffer Battlefield.hx due to fatal status CFGERR, warning Configuration error has occurred while running (haxe /home/wvxvw/projects/wafer/build.nxml)
我试图让它运行的命令看起来像这样:
(defun haxe-flymake-get-cmdline (source base-dir)
"Gets the cmd line for running a flymake session in a Haxe buffer.
This gets called by flymake itself. The output is a list of two elements:
the command to run, and a list of arguments. The resulting command is like:
$ haxe ${project-root}/build.nxml
"
(message "base-dir %s" (file-name-as-directory base-dir))
(list *haxe-compiler*
(list
(concat (file-name-as-directory base-dir)
*build-nxml*))))
打印的信息如下所示:
base-dir /home/wvxvw/projects/wafer/
所以,据我所知,结果命令应为:
haxe /home/wvxvw/projects/wafer/build.nxml
但看起来flymake要么在参数前面添加一些东西,要么之后添加一些东西,这使得Haxe编译器生成错误“错误:无效的类名” - 如果有一个额外的参数,编译器将会给出此错误已经理解为一个额外的类来编译。但是日志没有显示正在发送的内容......
编辑2:
我添加了:
#!/usr/bin/env bash
echo "$@" > /home/wvxvw/projects/wafer/log
并使flymake调用此脚本而不是编译器,它只传递一个参数,正如我所期望的那样...... 叹息
答案 0 :(得分:1)
这是一个很好的问题。我不知道一种简单的方法,可以将make工具的新“味道”添加到flymake中。我知道一种方式,它并不简单。这就是我为php codesniffer所做的 - 它对于任何任意make工具都是类似的。
首先,定义一个安装fn。
(defun fly/phpcs-install ()
"install flymake stuff for PHP CodeSniffer files."
(add-to-list
'flymake-err-line-patterns
(list fly/phpcs-error-pattern 1 2 3 4))
(let* ((key "\\.php\\'")
(phpentry (assoc key flymake-allowed-file-name-masks)))
(if phpentry
(setcdr phpentry '(fly/phpcs-init fly/phpcs-cleanup))
(add-to-list
'flymake-allowed-file-name-masks
(list key 'fly/phpcs-init 'fly/phpcs-cleanup)))))
这会在flymake alist中安装一个新条目,以.php作为文件扩展名键入。 flymake列表中的条目基本上将文件扩展名与一对函数相关联,一个用于init,另一个用于清理。
init fn只返回运行命令以检查语法。这可以是一个shell命令,带有适当的参数。对于codesniffer,这个fn看起来像这样:
(defun fly/phpcs-init ()
"initialize flymake for PHP using the PHP CodeSniffer tool."
(let ((create-temp-f 'fly/phpcs-create-temp-intemp)
(use-relative-base-dir t)
(use-relative-source t)
(get-cmdline-f 'fly/phpcs-get-cmdline)
args
temp-source-file-name)
(setq temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)
args (flymake-get-syntax-check-program-args
temp-source-file-name "."
use-relative-base-dir use-relative-source
get-cmdline-f))
args))
糟糕!我们走下兔子洞。 get-cmdline fn如下所示:
(defun fly/phpcs-get-cmdline (source base-dir)
"Gets the cmd line for running a flymake session in a PHP buffer.
This gets called by flymake itself. The output is a list of two elements:
the command to run, and a list of arguments. The resulting command is like:
php.exe -d auto_append_file="" -d auto_prepend_file="" phpcs\scripts\phpcs --report=emacs file.php
"
(list fly/phpcs-phpexe
(list
"-d" "auto_append_file=''"
"-d" "auto_prepend_file=''"
(concat (file-name-as-directory fly/phpcs-phpcs-dir)
"scripts\\phpcs")
(concat "--standard=" fly/phpcs-standard)
"--report=emacs"
"-s" ;; show the fullname of the rule being violated
(expand-file-name source))))
您可以在http://www.emacswiki.org/emacs/flyphpcs.el
看到完整的elisp可能有一种更简单的方法。我只是不知道。