通常的做法是将字体锁定关键字添加到主要模式,但输出文件处于基本模式,因此您可能需要使用define-derived-mode
(如下所示)编写简单的主要模式,然后提示说C-c C-l
)打开该模式(肯定有更好的功能建议,但我不知道哪一个)。
(define-derived-mode latex-output-mode fundamental-mode "LaTeX Output"
"Simple mode for colorizing LaTeX output."
(set (make-local-variable 'font-lock-defaults)
'((("^!.*" . font-lock-warning-face) ; LaTeX error
("^-+$" . font-lock-builtin-face) ; latexmk divider
("^\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\).*" . font-lock-string-face)
;; .....
))))
(defadvice TeX-recenter-output-buffer (after colorize-latex-output activate)
(latex-output-mode))
或者,你可以(为N.N.建议)覆盖TeX-parse-error
添加突出你感兴趣的部分文本属性或覆盖。这有一个缺点,如果TeX-parse-error
更新,你将不得不手动更新你的版本,但否则可能会减少工作量。当然,只有当它已经在搜索你想要突出显示的东西,即错误,警告,过满/不满框和文件信息时,它才会起作用。
第二个选项的一个例子可能是:
(defun TeX-parse-error (old)
"Goto next error. Pop to OLD buffer if no more errors are found.
This version colorizes file name parsing helping to track down annoying bugs"
(let ((regexp
(concat
;; TeX error
"^\\(!\\|\\(.*?\\):[0-9]+:\\) \\|"
;; New file
"(\\(\"[^\"]*?\"\\|/*\
\\(?:\\.+[^()\r\n{} \\/]*\\|[^()\r\n{} .\\/]+\
\\(?: [^()\r\n{} .\\/]+\\)*\\(?:\\.[-0-9a-zA-Z_.]*\\)?\\)\
\\(?:[\\/]+\\(?:\\.+[^()\r\n{} \\/]*\\|[^()\r\n{} .\\/]+\
\\(?: [^()\r\n{} .\\/]+\\)*\\(?:\\.[-0-9a-zA-Z_.]*\\)?\\)?\\)*\\)\
)*\\(?: \\|\r?$\\)\\|"
;; End of file
"\\()\\))*\\|"
;; Hook to change line numbers
" !\\(?:offset(\\([---0-9]+\\))\\|"
;; Hook to change file name
"name(\\([^)]+\\))\\)\\|"
;; LaTeX bad box
"^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\)\
\\\\.*?[0-9]+--[0-9]+\\)\\|"
;; LaTeX warning
"^\\(LaTeX [A-Za-z]*\\|Package [A-Za-z]+ \\)Warning:.*")))
(while
(cond
;; Nothing found
((null
(re-search-forward regexp nil t))
;; No more errors.
(message "No more errors.")
(beep)
(TeX-pop-to-buffer old)
nil)
;; TeX error
((match-beginning 1)
(put-text-property (match-beginning 2) (match-end 2)
'face 'font-lock-warning-face)
(when (match-beginning 2)
(unless TeX-error-file
(push nil TeX-error-file)
(push nil TeX-error-offset))
(unless (car TeX-error-offset)
(rplaca TeX-error-file (TeX-match-buffer 2))))
(if (looking-at "Preview ")
t
(TeX-error)
nil))
;; LaTeX bad box
((match-beginning 7)
(put-text-property (match-beginning 0) (match-end 0)
'face 'font-lock-doc-face)
(if TeX-debug-bad-boxes
(progn
(TeX-warning (TeX-match-buffer 7))
nil)
(re-search-forward "\r?\n\
\\(?:.\\{79\\}\r?\n\
\\)*.*\r?$")
t))
;; LaTeX warning
((match-beginning 8)
(put-text-property (match-beginning 0) (match-end 0)
'face 'font-lock-string-face)
(if TeX-debug-warnings
(progn
(TeX-warning (TeX-match-buffer 8))
nil)
t))
;; New file -- Push on stack
((match-beginning 3)
(let ((file (TeX-match-buffer 3))
(end (match-end 3)))
(put-text-property (match-beginning 0) (match-end 0)
'face 'font-lock-type-face)
;; Strip quotation marks and remove newlines if necessary
(when (or (eq (string-to-char file) ?\")
(string-match "\n" file))
(setq file
(mapconcat 'identity (split-string file "[\"\n]+") "")))
(push file TeX-error-file)
(push nil TeX-error-offset)
(goto-char end))
t)
;; End of file -- Pop from stack
((match-beginning 4)
;; (overlay-put
;; (make-overlay (match-beginning 4) (match-end 4))
;; 'face 'font-lock-warning-face)
(put-text-property (match-beginning 0) (match-end 0)
'face 'font-lock-warning-face)
(when (> (length TeX-error-file) 1)
(when (string= (pop TeX-error-file) "./auctex-bug.tex")
(goto-char (match-end 4)))
(pop TeX-error-offset))
(goto-char (match-end 4))
t)
;; Hook to change line numbers
((match-beginning 5)
(setq TeX-error-offset
(list (string-to-number (TeX-match-buffer 5))))
t)
;; Hook to change file name
((match-beginning 6)
(setq TeX-error-file
(list (TeX-match-buffer 6)))
t)))))
也许你可以使用http://stackoverflow.com/questions/7885853/emacs-latexmk-function-throws-me描述的colorizer的位-INTO-一个空缓冲 - 和增加最高度邻/ 7903668#7903668 –