【发布时间】:2012-06-13 16:14:53
【问题描述】:
我正在尝试从 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 调用这个脚本而不是编译器,它只传递一个参数,正如我所期望的那样...... sigh
【问题讨论】:
-
你越来越近了。当您开始执行 sytntax 检查的操作系统进程以非零状态码退出时,flymake 会发生 CFGERR 事情。在这种情况下,它看起来像是以状态 1 退出。Flymake 认为这是一个错误,并随后停止尝试检查语法。如果您的语法检查在成功完成时返回非零值,但是当它发现语法错误时,您需要修复
flymake-process-sentinel函数。同样,我不知道仅通过设置将其关闭的方法。有关这方面的示例,请参阅emacswiki.org/emacs/vbnet-mode.el -
另外,为了帮助排除故障,您可以
(setq flymake-log-level 3),在随后运行 flymake 时,您将在 emacs 中的 Messages 缓冲区中看到语法检查程序的输出.