Add LaTeX-compile-filters

master
Jacopo De Simoi 12 years ago
parent 53663f5ece
commit d1548af0a7
  1. 1
      init.el
  2. 72
      latex-compile-filters.el

@ -386,6 +386,7 @@ closing brace."
(if arg (TeX-insert-braces (- 0 arg))
(insert TeX-grcl)))
(load "latex-compile-filters.el")
(setq server-name (kde-current-activity))

@ -0,0 +1,72 @@
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
;; Thanks to ffevotte https://github.com/ffevotte/emacs.d/blob/master/setup-compile.el
;; Parse LaTeX output to determine the source file
(defun ff/compilation-error-latex-file ()
"Analyse the LaTeX output to find the source file in which an error was reported."
(condition-case nil
(save-excursion
(save-match-data
(let ((found nil)
(bound (point))
beg
filename)
(while (not found)
;; Search backward for an opening paren
(search-backward "(" nil)
;; Try to find a matching closing paren
(condition-case nil
(save-excursion
(goto-char (scan-sexps (point) 1))
(when (or (> (point) bound) ;; Closing paren after the error message
(not (looking-back ")"))) ;; Non-matching closing delimiter
(setq found t)))
;; Unbalanced expression
((error)
(setq found t))))
;; Extract filename
(setq beg (1+ (point)))
(re-search-forward "[[:space:]]" nil)
(setq filename (buffer-substring beg (- (point) 1)))
(list filename))))
;; Unexpected error
((error)
nil)))
;; Unfill "LaTeX Warning" lines
(defun ff/compilation-LaTeX-filter ()
(interactive)
(save-excursion
(goto-char (point-min))
(setq buffer-read-only nil)
(while (re-search-forward "^LaTeX Warning: " nil t)
(while (not (re-search-forward "\\.$" (line-end-position) t))
(end-of-line)
(delete-char 1)
(beginning-of-line)))
;; Cleanup avail lists so that the error parser does not get confused
(goto-char (point-min))
(if (search-forward " avail lists: " nil t)
(delete-char -2))
(setq buffer-read-only t)))
(add-hook 'compilation-filter-hook 'ff/compilation-LaTeX-filter)
(require 'compile)
(add-to-list 'compilation-error-regexp-alist 'latex-warning)
(add-to-list 'compilation-error-regexp-alist-alist
'(latex-warning
"^LaTeX Warning: .* on input line \\([[:digit:]]+\\)\\.$" ;; Regular expression
ff/compilation-error-latex-file ;; Filename
1 ;; Line number
nil ;; Column number
1)) ;; Type (warning)
Loading…
Cancel
Save