2

我正在尝试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-variableon compilation-error-regexp-alist,它会向我显示我认为它应该具有的值。但是.. 编译缓冲区中的错误没有被突出显示,并且M-x next-error不起作用。

替代文字

如果我将错误正则表达式值添加到compilation-error-regexp-alistvia setq-default,如下所示:

(setq-default compilation-error-regexp-alist
  '(
     ... jslint regexp here ...
     ... many other regexp's here...
   ))

...然后它的工作原理。编译缓冲区中的错误会正确突出显示并按M-x next-error预期运行。

替代文字

4

1 回答 1

2

我不相信该compile命令会继承您为compilation-error-regexp-alist. 解决方案是为*compilation*缓冲区本身定制一个钩子,请参阅compile-mode-hook和compile-start-hook。

于 2010-03-17T21:01:13.397 回答