如何禁用 Emacs-Flymake 的 html 模式

发布于 2024-09-30 17:34:17 字数 1105 浏览 4 评论 0原文

这是我在 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

生来就爱笑 2024-10-07 17:34:17

从列表中删除 HTML 条目:

(delete '("\\.html?\\'" flymake-xml-init) flymake-allowed-file-name-masks)

Remove the HTML entry from the list:

(delete '("\\.html?\\'" flymake-xml-init) flymake-allowed-file-name-masks)
肤浅与狂妄 2024-10-07 17:34:17

好的,我明白了。这是我所做的:
首先我找到了flymake.el文件。(如果你没有它,你可能在emacs安装下有flymake.elc文件。在这种情况下,只需将flymake.el文件复制到你的加载路径下,这样就会使用它而不是编译版本( .elc 文件)在安装下)。
比我发现以下函数并注释了 .xml 和 .html 绑定。

(defcustom flymake-allowed-file-name-masks
  '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
    ;("\\.xml\\'" flymake-xml-init)
    ;("\\.html?\\'" flymake-xml-init)
    ("\\.cs\\'" flymake-simple-make-init)
    ("\\.p[ml]\\'" flymake-perl-init)
    ("\\.php[345]?\\'" flymake-php-init)
    ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
    ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
    ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
    ("\\.tex\\'" flymake-simple-tex-init)
    ("\\.idl\\'" flymake-simple-make-init)
    ;; ("\\.cpp\\'" 1)
    ;; ("\\.java\\'" 3)
    ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'")
    ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
    ;; ("\\.idl\\'" 1)
    ;; ("\\.odl\\'" 1)
    ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'")
    ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
    ;; ("\\.tex\\'" 1)
    )

其他评论指出的行已经存在。现在 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.

(defcustom flymake-allowed-file-name-masks
  '(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
    ;("\\.xml\\'" flymake-xml-init)
    ;("\\.html?\\'" flymake-xml-init)
    ("\\.cs\\'" flymake-simple-make-init)
    ("\\.p[ml]\\'" flymake-perl-init)
    ("\\.php[345]?\\'" flymake-php-init)
    ("\\.h\\'" flymake-master-make-header-init flymake-master-cleanup)
    ("\\.java\\'" flymake-simple-make-java-init flymake-simple-java-cleanup)
    ("[0-9]+\\.tex\\'" flymake-master-tex-init flymake-master-cleanup)
    ("\\.tex\\'" flymake-simple-tex-init)
    ("\\.idl\\'" flymake-simple-make-init)
    ;; ("\\.cpp\\'" 1)
    ;; ("\\.java\\'" 3)
    ;; ("\\.h\\'" 2 ("\\.cpp\\'" "\\.c\\'")
    ;; ("[ \t]*#[ \t]*include[ \t]*\"\\([\w0-9/\\_\.]*[/\\]*\\)\\(%s\\)\"" 1 2))
    ;; ("\\.idl\\'" 1)
    ;; ("\\.odl\\'" 1)
    ;; ("[0-9]+\\.tex\\'" 2 ("\\.tex\\'")
    ;; ("[ \t]*\\input[ \t]*{\\(.*\\)\\(%s\\)}" 1 2 ))
    ;; ("\\.tex\\'" 1)
    )

Other comment outed lines was already there. Now flymake does not work for html and xml files

朱染 2024-10-07 17:34:17

您收到的错误消息表明它找不到命令行 XML 验证工具 xml。您可以通过安装兼容的 XML 验证工具来修复它(我认为 xmllint 是正确的选择)。

但如果您确实只想对 HTML 和 XML 文件禁用 Flymake,则无需复制整个 Flymake.el 文件并进行更改。只需将此行添加到您的初始化文件中即可:

(defun flymake-xml-init ())

这将使用空函数覆盖 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:

(defun flymake-xml-init ())

This overrides the function that Flymake calls for HTML and XML files with an empty function.

無處可尋 2024-10-07 17:34:17

自定义名为 flymake-allowed-file-name-masks 的变量。

你也可以这样做:

M-x customize-variable RET

flymake-allowed-file-name-masks RET

Customize the variable named flymake-allowed-file-name-masks.

You can do it like this too:

M-x customize-variable RET

flymake-allowed-file-name-masks RET
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文