Flymake替代方案,不需要更改makefile

Eps*_*tor 2 emacs flymake

根据这个问题,为了让Flymake工作,你必须在makefile中添加一个特殊的目标.我不想这样做.有没有替代Flymake,不要求你搞乱makefile?

Che*_*eso 5

不对.

您无需更改makefile即可运行flymake.正如jtahlborn的评论所说,flymake是一个在你的缓冲区改变时运行某些东西的框架.它可能是任何东西.你只需要告诉flymake要运行什么.

例如,有一个名为csslint的程序.它检查CSS文件并标记任何警告或非标准用法.Lint for CSS.当我编辑一个css文件(在css模式下)时,我想让flymake运行CSSlint并向我展示问题.我就是这样做的.

(defun cheeso-flymake-css-init ()
  "the initialization fn for flymake for CSS"
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'cheeso-flymake-create-temp-intemp))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list (concat (getenv "windir") "\\system32\\cscript.exe")
          (list "c:\\users\\cheeso\\bin\\csslint-wsh.js" "--format=compiler" local-file))))

(defun cheeso-css-flymake-install ()
  "install flymake stuff for CSS files."
  (add-to-list
   'flymake-err-line-patterns
   (list css-csslint-error-pattern 1 2 3 4))

  (let* ((key "\\.css\\'")
         (cssentry (assoc key flymake-allowed-file-name-masks)))
    (if cssentry
        (setcdr cssentry '(cheeso-flymake-css-init))
      (add-to-list
       'flymake-allowed-file-name-masks
       (list key 'cheeso-flymake-css-init)))))


(eval-after-load "flymake"
  '(progn
     (cheeso-css-flymake-install)))
Run Code Online (Sandbox Code Playgroud)

加载flymake时会运行fn.fn在flymake的CSS文件关联列表中安装一个条目.该列表中的条目告诉flymake要运行的命令.

还有一点告诉flymake如何解析CSS lint错误消息.但这是一般的想法.