如何禁用 Emacs-Flymake 的 html 模式
这是我在 .emacs 文件中的 Flymake 设置:
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
(load-library "flymake-cursor")
我只想对 .py 文件使用 Flymake。并禁用它的其余部分。但它始终处于启用状态。 例如,当我打开 html 文件时,我总是收到以下错误 错误(flymake):Flymake:无法使用参数启动语法检查进程“xml”(val /home/huseyin/vipsatis/templates/cancellation/base_flymake.html):搜索程序:没有这样的文件或目录,xml。 Flymake 将被关闭
所以我想关闭除 py 文件之外的任何内容。是否可以?
( 对于遇到同样问题的人,我想解释一下错误消息:Flymake 使用 xmlstarlet 进行 xml 和 html 验证。它尝试将其称为“xml val ......”,但必须将其称为“xmlstarlet val......”要解决此问题,您必须找到 Flymake.el 文件并使用 xmlstarlet 更改 xml 调用。 )
Here is my flymake setup in .emacs file:
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pyflakes" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
(load-library "flymake-cursor")
I want to use flymake only for .py files. and disable it for the rest. but It is always enabled.
For example when I open an html file I always get following error
Error (flymake): Flymake: Failed to launch syntax check process 'xml' with args (val /home/huseyin/vipsatis/templates/cancellation/base_flymake.html): Searching for program: no such file or directory, xml. Flymake will be switched OFF
So I want to turn it off for anything but py files. is it possible?
(
For the people having the same problem, I want to explain the error message: Flymake uses xmlstarlet for xml and html validation. And it tries to call it as "xml val ......" but it has to call it as "xmlstarlet val...." to fix this you have to find flymake.el file and change the xml call with xmlstarlet.
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从列表中删除 HTML 条目:
Remove the HTML entry from the list:
好的,我明白了。这是我所做的:
首先我找到了flymake.el文件。(如果你没有它,你可能在emacs安装下有flymake.elc文件。在这种情况下,只需将flymake.el文件复制到你的加载路径下,这样就会使用它而不是编译版本( .elc 文件)在安装下)。
比我发现以下函数并注释了 .xml 和 .html 绑定。
其他评论指出的行已经存在。现在 Flymake 不适用于 html 和 xml 文件
OK I got it. here is what I did:
first of all I found flymake.el file.(If you dont have it you probably have flymake.elc file under emacs installation.In that case just copy flymake.el file under your load path so it will be used instead of compiled version(.elc file) under insallation).
than I found following function and commented .xml and .html bindings.
Other comment outed lines was already there. Now flymake does not work for html and xml files
您收到的错误消息表明它找不到命令行 XML 验证工具
xml
。您可以通过安装兼容的 XML 验证工具来修复它(我认为 xmllint 是正确的选择)。但如果您确实只想对 HTML 和 XML 文件禁用 Flymake,则无需复制整个 Flymake.el 文件并进行更改。只需将此行添加到您的初始化文件中即可:
这将使用空函数覆盖 Flymake 为 HTML 和 XML 文件调用的函数。
In the error message you receive it's telling that it can't find the command-line XML validation tool
xml
. You can fix it by installing a compatible XML validation tool (xmllint
is the right choice I guess).But if you really just want to disable Flymake for HTML and XML files you don't have to copy whole the flymake.el file and change it. Simply add this line your init file:
This overrides the function that Flymake calls for HTML and XML files with an empty function.
自定义名为
flymake-allowed-file-name-masks
的变量。你也可以这样做:
Customize the variable named
flymake-allowed-file-name-masks
.You can do it like this too: