我正在嘗試將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
aha!非常感謝你。 – Cheeso 2010-03-17 21:02:56