我正在尝试compilation-error-regexp-alist
在我添加为模式挂钩的函数中设置。
(defun cheeso-javascript-mode-fn ()
(turn-on-font-lock)
...bunch of other stuff
;; for JSLINT
(make-local-variable 'compilation-error-regexp-alist)
(setq compilation-error-regexp-alist
'(
("^[ \t]*\\([A-Za-z.0-9_: \\-]+\\)(\\([0-9]+\\)[,]\\( *[0-9]+\\))\\( Microsoft JScript runtime error\\| JSLINT\\): \\(.+\\)$" 1 2 3)
))
;;(make-local-variable 'compile-command)
(setq compile-command
(let ((file (file-name-nondirectory buffer-file-name)))
(concat "%windir%\\system32\\cscript.exe \\cheeso\\bin\\jslint.js " file)))
)
(add-hook 'javascript-mode-hook 'cheeso-javascript-mode-fn)
模式挂钩运行。我在模式挂钩中设置的各种东西都有效。compile-command
得到设置。但是由于某种原因,该compilation-error-regexp-alist
值没有生效。
如果我稍后执行M-x describe-variable
on compilation-error-regexp-alist
,它会向我显示我认为它应该具有的值。但是.. 编译缓冲区中的错误没有被突出显示,并且M-x next-error
不起作用。
如果我将错误正则表达式值添加到compilation-error-regexp-alist
via setq-default
,如下所示:
(setq-default compilation-error-regexp-alist
'(
... jslint regexp here ...
... many other regexp's here...
))
...然后它的工作原理。编译缓冲区中的错误会正确突出显示并按M-x next-error
预期运行。