aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-01-28 16:16:04 -0500
committerStefan Monnier2011-01-28 16:16:04 -0500
commit5e853d01905a1a6c64f11928d5efa086cefb714f (patch)
tree3bfbd48cca5e94e843d5d7b5cead5853cbd35a74
parent07b741a76a67686170d6121790ed36e8d3f8a011 (diff)
downloademacs-5e853d01905a1a6c64f11928d5efa086cefb714f.tar.gz
emacs-5e853d01905a1a6c64f11928d5efa086cefb714f.zip
* lisp/textmodes/tex-mode.el: Get rid of compilation-parse-errors-function
(tex-old-error-file-name): New function, extracted from tex-compilation-parse-errors. (tex-compilation-parse-errors): Remove. (tex-error-regexp-alist): New var. (tex-shell): Use it to avoid compilation-parse-errors-function.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/textmodes/tex-mode.el170
2 files changed, 68 insertions, 109 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b501c6e78a4..663b74ab521 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12011-01-28 Stefan Monnier <monnier@iro.umontreal.ca> 12011-01-28 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * textmodes/tex-mode.el: Get rid of compilation-parse-errors-function
4 (tex-old-error-file-name): New function,
5 extracted from tex-compilation-parse-errors.
6 (tex-compilation-parse-errors): Remove.
7 (tex-error-regexp-alist): New var.
8 (tex-shell): Use it to avoid compilation-parse-errors-function.
9
3 * progmodes/grep.el (grep-regexp-alist): Tighten regexp. 10 * progmodes/grep.el (grep-regexp-alist): Tighten regexp.
4 (grep-mode-font-lock-keywords): Remove regexp that seems like 11 (grep-mode-font-lock-keywords): Remove regexp that seems like
5 a left-over from before we used compile.el. 12 a left-over from before we used compile.el.
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 8a9aa03bf69..428fc1db3a9 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1812,11 +1812,70 @@ Mark is left at original location."
1812;; Why use a shell instead of running TeX directly? Because if TeX 1812;; Why use a shell instead of running TeX directly? Because if TeX
1813;; gets stuck, the user can switch to the shell window and type at it. 1813;; gets stuck, the user can switch to the shell window and type at it.
1814 1814
1815(defvar tex-error-parse-syntax-table
1816 (let ((st (make-syntax-table)))
1817 (modify-syntax-entry ?\( "()" st)
1818 (modify-syntax-entry ?\) ")(" st)
1819 (modify-syntax-entry ?\\ "\\" st)
1820 (modify-syntax-entry ?\{ "_" st)
1821 (modify-syntax-entry ?\} "_" st)
1822 (modify-syntax-entry ?\[ "_" st)
1823 (modify-syntax-entry ?\] "_" st)
1824 ;; Single quotations may appear in errors
1825 (modify-syntax-entry ?\" "_" st)
1826 st)
1827 "Syntax-table used while parsing TeX error messages.")
1828
1829(defun tex-old-error-file-name ()
1830 ;; This is unreliable, partly because we don't try very hard, and
1831 ;; partly because TeX's output format is eminently ambiguous and unfriendly
1832 ;; to automation.
1833 (save-excursion
1834 (save-match-data
1835 (with-syntax-table tex-error-parse-syntax-table
1836 (beginning-of-line)
1837 (backward-up-list 1)
1838 (skip-syntax-forward "(_")
1839 (while (not (let ((try-filename (thing-at-point 'filename)))
1840 (and try-filename
1841 (not (string= "" try-filename))
1842 (file-readable-p try-filename))))
1843 (skip-syntax-backward "(_")
1844 (backward-up-list 1)
1845 (skip-syntax-forward "(_"))
1846 (thing-at-point 'filename)))))
1847
1848(defconst tex-error-regexp-alist
1849 ;; First alternative handles the newer --file-line-error style:
1850 ;; ./test2.tex:14: Too many }'s.
1851 '(gnu
1852 ;; Second handles the old-style, which spans two lines but doesn't include
1853 ;; any file info:
1854 ;; ! Too many }'s.
1855 ;; l.396 toto}
1856 ("^l\\.\\([1-9][0-9]*\\) \\(?:\\.\\.\\.\\)?\\(.*\\)$"
1857 tex-old-error-file-name 1 nil nil nil
1858 ;; Since there's no filename to highlight, let's highlight the message.
1859 (2 compilation-error-face))
1860 ;; A few common warning messages.
1861 ("^\\(?:Und\\|Ov\\)erfull \\\\[hv]box .* at lines? \\(\\([1-9][0-9]*\\)\\(?:--\\([1-9][0-9]*\\)\\)?\\)$"
1862 tex-old-error-file-name (2 . 3) nil 1 nil
1863 (1 compilation-warning-face))
1864 ("^(Font) *\\([^ \n].* on input line \\([1-9][0-9]*\\)\\)\\.$"
1865 tex-old-error-file-name 2 nil 1 1
1866 (2 compilation-warning-face))
1867 ;; Included files get output as (<file> ...).
1868 ;; FIXME: there tend to be a crapload of them at the beginning of the
1869 ;; output which aren't that interesting. Maybe we should filter out
1870 ;; all the file name that start with /usr/share?
1871 ;; ("(\\.?/\\([^() \n]+\\)" 1 nil nil 0)
1872 ))
1873
1815;; The utility functions: 1874;; The utility functions:
1816 1875
1817(define-derived-mode tex-shell shell-mode "TeX-Shell" 1876(define-derived-mode tex-shell shell-mode "TeX-Shell"
1818 (set (make-local-variable 'compilation-parse-errors-function) 1877 (set (make-local-variable 'compilation-error-regexp-alist)
1819 'tex-compilation-parse-errors) 1878 tex-error-regexp-alist)
1820 (compilation-shell-minor-mode t)) 1879 (compilation-shell-minor-mode t))
1821 1880
1822;;;###autoload 1881;;;###autoload
@@ -2314,113 +2373,6 @@ Only applies the FSPEC to the args part of FORMAT."
2314 (tex-display-shell) 2373 (tex-display-shell)
2315 (setq tex-last-buffer-texed (current-buffer))) 2374 (setq tex-last-buffer-texed (current-buffer)))
2316 2375
2317(defvar tex-error-parse-syntax-table
2318 (let ((st (make-syntax-table)))
2319 (modify-syntax-entry ?\( "()" st)
2320 (modify-syntax-entry ?\) ")(" st)
2321 (modify-syntax-entry ?\\ "\\" st)
2322 (modify-syntax-entry ?\{ "_" st)
2323 (modify-syntax-entry ?\} "_" st)
2324 (modify-syntax-entry ?\[ "_" st)
2325 (modify-syntax-entry ?\] "_" st)
2326 ;; Single quotations may appear in errors
2327 (modify-syntax-entry ?\" "_" st)
2328 st)
2329 "Syntax-table used while parsing TeX error messages.")
2330
2331(defun tex-compilation-parse-errors (limit-search find-at-least)
2332 "Parse the current buffer as TeX error messages.
2333See the variable `compilation-parse-errors-function' for the interface it uses.
2334
2335This function parses only the last TeX compilation.
2336It works on TeX compilations only. It is necessary for that purpose,
2337since TeX does not put file names and line numbers on the same line as
2338for the error messages."
2339 (require 'thingatpt)
2340 (setq compilation-error-list nil)
2341 (let ((default-directory ; Perhaps dir has changed meanwhile.
2342 (file-name-directory (buffer-file-name tex-last-buffer-texed)))
2343 found-desired (num-errors-found 0)
2344 last-filename last-linenum last-position
2345 begin-of-error end-of-error errfilename)
2346 ;; Don't reparse messages already seen at last parse.
2347 (goto-char compilation-parsing-end)
2348 ;; Parse messages.
2349 (while (and (not (or found-desired (eobp)))
2350 ;; First alternative handles the newer --file-line-error style:
2351 ;; ./test2.tex:14: Too many }'s.
2352 ;; Second handles the old-style:
2353 ;; ! Too many }'s.
2354 (prog1 (re-search-forward
2355 "^\\(?:\\([^:\n]+\\):[[:digit:]]+:\\|!\\) " nil 'move)
2356 (setq begin-of-error (match-beginning 0)
2357 end-of-error (match-end 0)
2358 errfilename (match-string 1)))
2359 (re-search-forward
2360 "^l\\.\\([0-9]+\\) \\(\\.\\.\\.\\)?\\(.*\\)$" nil 'move))
2361 (let* ((this-error (copy-marker begin-of-error))
2362 (linenum (string-to-number (match-string 1)))
2363 (error-text (regexp-quote (match-string 3)))
2364 try-filename
2365 (filename
2366 ;; Prefer --file-liner-error filename if we have it.
2367 (or errfilename
2368 (save-excursion
2369 (with-syntax-table tex-error-parse-syntax-table
2370 (backward-up-list 1)
2371 (skip-syntax-forward "(_")
2372 (while (not
2373 (and (setq try-filename (thing-at-point
2374 'filename))
2375 (not (string= "" try-filename))
2376 (file-readable-p try-filename)))
2377 (skip-syntax-backward "(_")
2378 (backward-up-list 1)
2379 (skip-syntax-forward "(_"))
2380 (thing-at-point 'filename)))))
2381 (new-file
2382 (or (null last-filename)
2383 (not (string-equal last-filename filename))))
2384 (error-location
2385 (with-current-buffer
2386 (if (equal filename (concat tex-zap-file ".tex"))
2387 tex-last-buffer-texed
2388 (find-file-noselect filename))
2389 (save-excursion
2390 (if new-file
2391 (progn
2392 (goto-char (point-min))
2393 (forward-line (1- linenum))
2394 (setq last-position nil))
2395 (goto-char last-position)
2396 (forward-line (- linenum last-linenum)))
2397 ;; first try a forward search for the error text,
2398 ;; then a backward search limited by the last error.
2399 (let ((starting-point (point)))
2400 (or (re-search-forward error-text nil t)
2401 (re-search-backward error-text last-position t)
2402 (goto-char starting-point)))
2403 (point-marker)))))
2404 (goto-char this-error)
2405 (if (and compilation-error-list
2406 (or (and find-at-least
2407 (>= num-errors-found
2408 find-at-least))
2409 (and limit-search
2410 (>= end-of-error limit-search)))
2411 new-file)
2412 (setq found-desired t)
2413 (setq num-errors-found (1+ num-errors-found)
2414 last-filename filename
2415 last-linenum linenum
2416 last-position error-location
2417 compilation-error-list ; Add the new error
2418 (cons (cons this-error error-location)
2419 compilation-error-list))
2420 (goto-char end-of-error)))))
2421 (set-marker compilation-parsing-end (point))
2422 (setq compilation-error-list (nreverse compilation-error-list)))
2423
2424;;; The commands: 2376;;; The commands:
2425 2377
2426(defun tex-region (beg end) 2378(defun tex-region (beg end)