comparison lisp/progmodes/compile.el @ 55131:2a263df48184

(compilation-error-regexp-alist-alist): Also recognize severe Irix et al. messages. (compilation-normalize-filename, compile-abbreviate-directory): Delete functions. (compilation-get-file-structure): New function inherits functionality of the two preceding ones. (compilation-internal-error-properties, compilation-fake-loc): Use it so that different paths to the same file share the same markers. Also optimize finding adjacent marker slightly.
author Daniel Pfeiffer <occitan@esperanto.org>
date Sun, 25 Apr 2004 12:54:50 +0000
parents b8afe141e350
children 9c215b4c9a6d
comparison
equal deleted inserted replaced
55130:c4aac1add82f 55131:2a263df48184
182 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\ 182 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\
183 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5)) 183 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5))
184 184
185 ;; fixme: should be `mips' 185 ;; fixme: should be `mips'
186 (irix 186 (irix
187 "^[-[:alnum:]_/]+: \\(?:[eE]rror\\|[wW]arnin\\(g\\)\\|[iI]nf\\(o\\)\\)[0-9 ]*:\ 187 "^[-[:alnum:]_/]+: \\(?:[sS]evere\\|[eE]rror\\|[wW]arnin\\(g\\)\\|[iI]nf\\(o\\)\\)[0-9 ]*:\
188 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 3 4 nil (1 . 2)) 188 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 3 4 nil (1 . 2))
189 189
190 (java 190 (java
191 "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1)) 191 "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1))
192 192
585 585
586 (defun compilation-internal-error-properties (file line end-line col end-col type fmt) 586 (defun compilation-internal-error-properties (file line end-line col end-col type fmt)
587 "Get the meta-info that will be added as text-properties. 587 "Get the meta-info that will be added as text-properties.
588 LINE, END-LINE, COL, END-COL are integers or nil. 588 LINE, END-LINE, COL, END-COL are integers or nil.
589 TYPE can be 0, 1, or 2. 589 TYPE can be 0, 1, or 2.
590 FILE should be (FILENAME . DIRNAME) or nil." 590 FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME) or nil."
591 (unless file (setq file '("*unknown*"))) 591 (unless file (setq file '("*unknown*")))
592 (setq file (or (gethash file compilation-locs) 592 (setq file (compilation-get-file-structure file fmt))
593 (puthash file (list file fmt) compilation-locs)))
594 ;; Get first already existing marker (if any has one, all have one). 593 ;; Get first already existing marker (if any has one, all have one).
595 ;; Do this first, as the compilation-assq`s may create new nodes. 594 ;; Do this first, as the compilation-assq`s may create new nodes.
596 (let* ((marker-line (car (cddr file))) ; a line structure 595 (let* ((marker-line (car (cddr file))) ; a line structure
597 (marker (nth 3 (cadr marker-line))) ; its marker 596 (marker (nth 3 (cadr marker-line))) ; its marker
598 (compilation-error-screen-columns compilation-error-screen-columns) 597 (compilation-error-screen-columns compilation-error-screen-columns)
599 end-marker loc end-loc) 598 end-marker loc end-loc)
600 (if (not (and marker (marker-buffer marker))) 599 (if (not (and marker (marker-buffer marker)))
601 (setq marker) ; no valid marker for this file 600 (setq marker) ; no valid marker for this file
602 (setq loc (or line 1) ; normalize no linenumber to line 1 601 (setq loc (or line 1)) ; normalize no linenumber to line 1
603 marker-line) 602 (catch 'marker ; find nearest loc, at least one exists
604 (catch 'marker ; find nearest loc, at least one exists 603 (dolist (x (nthcdr 3 file)) ; loop over remaining lines
605 (dolist (x (cddr file)) ; loop over lines 604 (if (> (car x) loc) ; still bigger
606 (if (> (or (car x) 1) loc) ; still bigger
607 (setq marker-line x) 605 (setq marker-line x)
608 (if (or (not marker-line) ; first in list 606 (if (> (- (or (car marker-line) 1) loc)
609 (> (- (or (car marker-line) 1) loc) 607 (- loc (car x))) ; current line is nearer
610 (- loc (or (car x) 1)))) ; current line is nearer
611 (setq marker-line x)) 608 (setq marker-line x))
612 (throw 'marker t)))) 609 (throw 'marker t))))
613 (setq marker (nth 3 (cadr marker-line)) 610 (setq marker (nth 3 (cadr marker-line))
614 marker-line (car marker-line)) 611 marker-line (or (car marker-line) 1))
615 (with-current-buffer (marker-buffer marker) 612 (with-current-buffer (marker-buffer marker)
616 (save-restriction 613 (save-restriction
617 (widen) 614 (widen)
618 (goto-char (marker-position marker)) 615 (goto-char (marker-position marker))
619 (when (or end-col end-line) 616 (when (or end-col end-line)
1449 (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc)) 1446 (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
1450 (setcdr (nthcdr 3 loc) t))) ; Set this one as visited. 1447 (setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
1451 1448
1452 (defun compilation-fake-loc (marker file &optional line col) 1449 (defun compilation-fake-loc (marker file &optional line col)
1453 "Preassociate MARKER with FILE. 1450 "Preassociate MARKER with FILE.
1451 FILE should be ABSOLUTE-FILENAME or (RELATIVE-FILENAME . DIRNAME).
1454 This is useful when you compile temporary files, but want 1452 This is useful when you compile temporary files, but want
1455 automatic translation of the messages to the real buffer from 1453 automatic translation of the messages to the real buffer from
1456 which the temporary file came. This only works if done before a 1454 which the temporary file came. This only works if done before a
1457 message about FILE appears! 1455 message about FILE appears!
1458 1456
1464 If you concatenate several regions into the temp file (e.g. a 1462 If you concatenate several regions into the temp file (e.g. a
1465 header with variable assignments and a code region), you must 1463 header with variable assignments and a code region), you must
1466 call this several times, once each for the last line of one 1464 call this several times, once each for the last line of one
1467 region and the first line of the next region." 1465 region and the first line of the next region."
1468 (or (consp file) (setq file (list file))) 1466 (or (consp file) (setq file (list file)))
1469 (setq file (or (gethash file compilation-locs) 1467 (setq file (compilation-get-file-structure file))
1470 (puthash file (list file nil) compilation-locs)))
1471 (let ((loc (compilation-assq (or line 1) (cdr file)))) 1468 (let ((loc (compilation-assq (or line 1) (cdr file))))
1472 (setq loc (compilation-assq col loc)) 1469 (setq loc (compilation-assq col loc))
1473 (if (cdr loc) 1470 (if (cdr loc)
1474 (setcdr (cddr loc) (list marker)) 1471 (setcdr (cddr loc) (list marker))
1475 (setcdr loc (list (or line 1) file marker))) 1472 (setcdr loc (list line file marker)))
1476 loc)) 1473 loc))
1477 1474
1478 (defcustom compilation-context-lines next-screen-context-lines 1475 (defcustom compilation-context-lines next-screen-context-lines
1479 "*Display this many lines of leading context before message." 1476 "*Display this many lines of leading context before message."
1480 :type 'integer 1477 :type 'integer
1596 (when (overlay-get ov 'intangible) 1593 (when (overlay-get ov 'intangible)
1597 (overlay-put ov 'intangible nil)))) 1594 (overlay-put ov 'intangible nil))))
1598 (overlays-in (point-min) (point-max))) 1595 (overlays-in (point-min) (point-max)))
1599 buffer))) 1596 buffer)))
1600 1597
1601 (defun compilation-normalize-filename (filename) 1598 (defun compilation-get-file-structure (file &optional fmt)
1602 "Convert FILENAME string found in an error message to make it usable." 1599 "Retrieve FILE's file-structure or create a new one.
1603 1600 FILE should be (ABSOLUTE-FILENAME) or (RELATIVE-FILENAME . DIRNAME)."
1604 ;; Check for a comint-file-name-prefix and prepend it if 1601
1605 ;; appropriate. (This is very useful for 1602 (or (gethash file compilation-locs)
1606 ;; compilation-minor-mode in an rlogin-mode buffer.) 1603 ;; File was not previously encountered, at least not in the form passed.
1607 (and (boundp 'comint-file-name-prefix) 1604 ;; Let's normalize it and look again.
1608 ;; If file name is relative, default-directory will 1605 (let ((filename (car file))
1609 ;; already contain the comint-file-name-prefix (done 1606 (default-directory (if (cdr file)
1610 ;; by compile-abbreviate-directory). 1607 (file-truename (cdr file))
1611 (file-name-absolute-p filename) 1608 default-directory)))
1612 (setq filename 1609
1613 (concat (with-no-warnings 'comint-file-name-prefix) filename))) 1610 ;; Check for a comint-file-name-prefix and prepend it if appropriate.
1614 1611 ;; (This is very useful for compilation-minor-mode in an rlogin-mode
1615 ;; If compilation-parse-errors-filename-function is 1612 ;; buffer.)
1616 ;; defined, use it to process the filename. 1613 (if (boundp 'comint-file-name-prefix)
1617 (when compilation-parse-errors-filename-function 1614 (if (file-name-absolute-p filename)
1618 (setq filename 1615 (setq filename
1619 (funcall compilation-parse-errors-filename-function 1616 (concat (with-no-warnings comint-file-name-prefix) filename))
1620 filename))) 1617 (setq default-directory
1621 1618 (file-truename
1622 ;; Some compilers (e.g. Sun's java compiler, reportedly) 1619 (concat (with-no-warnings comint-file-name-prefix) default-directory)))))
1623 ;; produce bogus file names like "./bar//foo.c" for file 1620
1624 ;; "bar/foo.c"; expand-file-name will collapse these into 1621 ;; If compilation-parse-errors-filename-function is
1625 ;; "/foo.c" and fail to find the appropriate file. So we 1622 ;; defined, use it to process the filename.
1626 ;; look for doubled slashes in the file name and fix them 1623 (when compilation-parse-errors-filename-function
1627 ;; up in the buffer. 1624 (setq filename
1628 (setq filename (command-line-normalize-file-name filename))) 1625 (funcall compilation-parse-errors-filename-function
1629 1626 filename)))
1630 1627
1631 ;; If directory DIR is a subdir of ORIG or of ORIG's parent, 1628 ;; Some compilers (e.g. Sun's java compiler, reportedly) produce bogus
1632 ;; return a relative name for it starting from ORIG or its parent. 1629 ;; file names like "./bar//foo.c" for file "bar/foo.c";
1633 ;; ORIG-EXPANDED is an expanded version of ORIG. 1630 ;; expand-file-name will collapse these into "/foo.c" and fail to find
1634 ;; PARENT-EXPANDED is an expanded version of ORIG's parent. 1631 ;; the appropriate file. So we look for doubled slashes in the file
1635 ;; Those two args could be computed here, but we run faster by 1632 ;; name and fix them.
1636 ;; having the caller compute them just once. 1633 (setq filename (command-line-normalize-file-name filename))
1637 (defun compile-abbreviate-directory (dir orig orig-expanded parent-expanded) 1634
1638 ;; Apply canonical abbreviations to DIR first thing. 1635 ;; Now eliminate any "..", because find-file would get them wrong.
1639 ;; Those abbreviations are already done in the other arguments passed. 1636 ;; Make relative and absolute filenames, with or without links, the
1640 (setq dir (abbreviate-file-name dir)) 1637 ;; same.
1641 1638 (setq filename
1642 ;; Check for a comint-file-name-prefix and prepend it if appropriate. 1639 (list (abbreviate-file-name
1643 ;; (This is very useful for compilation-minor-mode in an rlogin-mode 1640 (file-truename (if (cdr file)
1644 ;; buffer.) 1641 (expand-file-name filename)
1645 (if (boundp 'comint-file-name-prefix) 1642 filename)))))
1646 (setq dir (concat comint-file-name-prefix dir))) 1643
1647 1644 ;; Store it for the possibly unnormalized name
1648 (if (and (> (length dir) (length orig-expanded)) 1645 (puthash file
1649 (string= orig-expanded 1646 ;; Retrieve or create file-structure for normalized name
1650 (substring dir 0 (length orig-expanded)))) 1647 (or (gethash filename compilation-locs)
1651 (setq dir 1648 (puthash filename (list filename fmt) compilation-locs))
1652 (concat orig 1649 compilation-locs))))
1653 (substring dir (length orig-expanded)))))
1654 (if (and (> (length dir) (length parent-expanded))
1655 (string= parent-expanded
1656 (substring dir 0 (length parent-expanded))))
1657 (setq dir
1658 (concat (file-name-directory
1659 (directory-file-name orig))
1660 (substring dir (length parent-expanded)))))
1661 dir)
1662 1650
1663 (add-to-list 'debug-ignored-errors "^No more [-a-z ]+s yet$") 1651 (add-to-list 'debug-ignored-errors "^No more [-a-z ]+s yet$")
1664 1652
1665 ;;; Compatibility with the old compile.el. 1653 ;;; Compatibility with the old compile.el.
1666 1654