作者:日落月出星不离_887 | 来源:互联网 | 2023-05-18 04:35
IhavebeenlearningtouseEmacsforalittlewhilenow.Sofarlikingitalot.我一直在学习使用Emacs一段时间。
I have been learning to use Emacs for a little while now. So far liking it a lot.
我一直在学习使用Emacs一段时间。到目前为止喜欢它很多。
My problem is that for little C codes I prefer using Rake instead of Make. However flymake does not seem to want anything else than Make. As it complains that it can not find Makefile. From the command line Rake is used in the same way as Make so I was wondering if there was some emacs configuration I could enter to allow Rake to be used by flymake?
我的问题是,对于小C代码,我更喜欢使用Rake而不是Make。然而,flymake似乎除了Make之外不需要任何其他东西。因为它抱怨它找不到Makefile。从命令行开始,Rake的使用方式与Make相同,所以我想知道是否有一些emacs配置我可以输入以允许flymake使用Rake?
To correct a bit what I am doing. I'm not actually editing a Rakefile. And flymake-ruby does not help at all. I'm working with C code. I just use RAKE to compile the c code using gcc instead of MAKE.
纠正我正在做的事情。我实际上并没有编辑Rakefile。而flymake-ruby根本没有帮助。我正在使用C代码。我只使用RAKE使用gcc而不是MAKE编译c代码。
3 个解决方案
Right, got it now; sorry about the earlier confusion.
对,现在就搞定了;抱歉早先的混乱。
Taking a quick look through flymake.el, for *.c files, the 'make' invocation ultimately comes from here:
快速浏览一下flymake.el,对于* .c文件,'make'调用最终来自这里:
(defun flymake-get-make-cmdline (source base-dir)
(list "make"
(list "-s"
"-C"
base-dir
(concat "CHK_SOURCES=" source)
"SYNTAX_CHECK_MODE=1"
"check-syntax")))
That gets called by flymake-simple-make-init
, which is called because that's what *.c
files are mapped to by flymake-allowed-file-name-masks
.
这是由flymake-simple-make-init调用的,因为这是由flymake-allowed-file-name-masks映射到的* .c文件。
So, the right answer would be to modify flymake-allowed-file-name-masks
to map *.c
files to a different init defun, then write that defun to call rake the way you want. There are a bunch of those defuns already written for various things, and most of them are pretty short and sweet -- so even if you don't know Emacs Lisp, you could probably get something to work with a minimum of futzing. (The really really right answer would be to change flymake-simple-make-init
so that the command name was read from a defcustom variable, then submit that change back upstream...)
因此,正确的答案是修改flymake-allowed-file-name-masks以将* .c文件映射到不同的init defun,然后编写defun以按照您想要的方式调用rake。有很多已经针对各种事情编写的defuns,其中大多数都非常短而且很甜 - 所以即使你不了解Emacs Lisp,你也可以用最少的东西来处理。 (真正正确的答案是更改flymake-simple-make-init,以便从defcustom变量中读取命令名,然后将该更改提交回上游...)
The quick-and-dirty answer, given that you said all you need to do is call 'rake' with the same args as 'make', would be to grab a copy of flymake.el, stick it early in your load-path
, and munge the 'make' string in flymake-get-make-cmdline
to read 'rake' instead. That'll at least get you to the next step...
快速而肮脏的答案,假设你说你需要做的就是用'make'来调用'rake',使用与'make'相同的args,就是获取flymake.el的副本,在你的加载路径中尽早贴上它,并使用flymake-get-make-cmdline中的'make'字符串来代替'rake'。那至少会让你进入下一步......