2010-03-17 71 views
2

我正在尝试将compilation-error-regexp-alist设置为一个我添加为模式钩子的函数。emacs:我可以在模式钩子fn中设置编译错误 - 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值不生效。

如果我后来在compilation-error-regexp-alist上做了M-x describe-variable,它显示出我认为它应该有的值。但是..编译缓冲区中的错误不会突出显示,并且M-x next-error不起作用。

alt text http://i40.tinypic.com/drb3g4.jpg

如果我通过setq-default添加错误的正则表达式的值到compilation-error-regexp-alist,就像这样:

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

...然后它的作品。编译缓冲区中的错误得到正确突出显示,M-x next-error按预期运行。

alt text http://i40.tinypic.com/10nclxv.jpg

回答

2

我不相信compile命令继承你为compilation-error-regexp-alist设置本地值。解决方案是自定义*compilation*缓冲区的钩子,请参阅compilation-mode-hook和编译 - 开始钩子。

+0

aha!非常感谢你。 – Cheeso 2010-03-17 21:02:56