comparison lisp/progmodes/compile.el @ 54742:0a2de4900b34

(compilation-warning-face, compilation-info-face, compilation-skip-threshold) (compilation-skip-visited, compilation-context-lines): Declare :version when added to Emacs. (compilation-error-regexp-alist-alist): Extend caml and irix. (compilation-setup): Fix if font-locked w/o font-lock-defaults. (compilation-mode-font-lock-keywords): Temporarily undo line as function patch, which wasn't ready.
author Daniel Pfeiffer <occitan@esperanto.org>
date Wed, 07 Apr 2004 12:56:08 +0000
parents 677905e471e2
children bdc00a83ecd1
comparison
equal deleted inserted replaced
54741:bcb154ea0393 54742:0a2de4900b34
67 ;; buffer. 67 ;; buffer.
68 68
69 69
70 ;;; Code: 70 ;;; Code:
71 71
72 ;; This is the parsing engine for compile:
73
74 (defgroup compilation nil 72 (defgroup compilation nil
75 "Run compiler as inferior of Emacs, parse error messages." 73 "Run compiler as inferior of Emacs, parse error messages."
76 :group 'tools 74 :group 'tools
77 :group 'processes) 75 :group 'processes)
78 76
167 "^\\(?:Error\\|Warnin\\(g\\)\\) \\(?:[FEW][0-9]+ \\)?\ 165 "^\\(?:Error\\|Warnin\\(g\\)\\) \\(?:[FEW][0-9]+ \\)?\
168 \\([a-zA-Z]?:?[^:( \t\n]+\\)\ 166 \\([a-zA-Z]?:?[^:( \t\n]+\\)\
169 \\([0-9]+\\)\\(?:[) \t]\\|:[^0-9\n]\\)" 2 3 nil (1)) 167 \\([0-9]+\\)\\(?:[) \t]\\|:[^0-9\n]\\)" 2 3 nil (1))
170 168
171 (caml 169 (caml
172 "^ *File \"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)-?\\([0-9]+\\)?,\ 170 "^ *File \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1, lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\
173 \\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning:\\)?" 171 \\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning:\\)?\\)"
174 1 (2 . 3) (4 . 5) (6)) 172 2 (3 . 4) (5 . 6) (7))
175 173
176 (comma 174 (comma
177 "^\"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)\ 175 "^\"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)\
178 \\(?:[(. pos]+\\([0-9]+\\))?\\)?[:.,; (-]\\( warning:\\|[-0-9 ]*(W)\\)?" 1 2 3 (4)) 176 \\(?:[(. pos]+\\([0-9]+\\))?\\)?[:.,; (-]\\( warning:\\|[-0-9 ]*(W)\\)?" 1 2 3 (4))
179 177
187 (ibm 185 (ibm
188 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\ 186 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\
189 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5)) 187 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5))
190 188
191 (irix 189 (irix
192 "^[a-z0-9/]+: \\(?:[eE]rror\\|[wW]arnin\\(g\\)\\)[0-9 ]*:\ 190 "^[a-z0-9/]+: \\(?:[eE]rror\\|[wW]arnin\\(g\\)\\|[iI]nf\\(o\\)\\)[0-9 ]*:\
193 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 2 3 nil (1)) 191 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 3 4 nil (1 . 2))
194 192
195 (java 193 (java
196 "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1)) 194 "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1))
197 195
198 (jikes-file 196 (jikes-file
450 (defface compilation-warning-face 448 (defface compilation-warning-face
451 '((((type tty) (class color)) (:foreground "cyan" :weight bold)) 449 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
452 (((class color)) (:foreground "Orange" :weight bold)) 450 (((class color)) (:foreground "Orange" :weight bold))
453 (t (:weight bold))) 451 (t (:weight bold)))
454 "Face used to highlight compiler warnings." 452 "Face used to highlight compiler warnings."
455 :group 'font-lock-highlighting-faces) 453 :group 'font-lock-highlighting-faces
454 :version "21.4")
456 455
457 (defface compilation-info-face 456 (defface compilation-info-face
458 '((((type tty) (class color)) (:foreground "green" :weight bold)) 457 '((((type tty) (class color)) (:foreground "green" :weight bold))
459 (((class color) (background light)) (:foreground "Green3" :weight bold)) 458 (((class color) (background light)) (:foreground "Green3" :weight bold))
460 (((class color) (background dark)) (:foreground "Green" :weight bold)) 459 (((class color) (background dark)) (:foreground "Green" :weight bold))
461 (t (:weight bold))) 460 (t (:weight bold)))
462 "Face used to highlight compiler warnings." 461 "Face used to highlight compiler warnings."
463 :group 'font-lock-highlighting-faces) 462 :group 'font-lock-highlighting-faces
463 :version "21.4")
464 464
465 (defvar compilation-message-face nil 465 (defvar compilation-message-face nil
466 "Face name to use for whole messages. 466 "Face name to use for whole messages.
467 Faces `compilation-error-face', `compilation-warning-face', 467 Faces `compilation-error-face', `compilation-warning-face',
468 `compilation-info-face', `compilation-line-face' and 468 `compilation-info-face', `compilation-line-face' and
647 "mouse-2: visit this file")) 647 "mouse-2: visit this file"))
648 mouse-face highlight)))) 648 mouse-face highlight))))
649 649
650 (defun compilation-mode-font-lock-keywords () 650 (defun compilation-mode-font-lock-keywords ()
651 "Return expressions to highlight in Compilation mode." 651 "Return expressions to highlight in Compilation mode."
652 (if compilation-parse-errors-function 652 (nconc
653 ;; An old package! Try the compatibility code. 653 ;; make directory tracking
654 '((compilation-compat-parse-errors)) 654 (if compilation-directory-matcher
655 (append 655 `((,(car compilation-directory-matcher)
656 ;; make directory tracking 656 ,@(mapcar (lambda (elt)
657 (if compilation-directory-matcher 657 `(,(car elt)
658 `((,(car compilation-directory-matcher) 658 (compilation-directory-properties
659 ,@(mapcar (lambda (elt) 659 ,(car elt) ,(cdr elt))
660 `(,(car elt) 660 t))
661 (compilation-directory-properties 661 (cdr compilation-directory-matcher)))))
662 ,(car elt) ,(cdr elt)) 662
663 t)) 663 ;; Compiler warning/error lines.
664 (cdr compilation-directory-matcher))))) 664 (mapcar (lambda (item)
665 665 (if (symbolp item)
666 ;; Compiler warning/error lines. 666 (setq item (cdr (assq item
667 (mapcar 667 compilation-error-regexp-alist-alist))))
668 (lambda (item) 668 (let ((file (nth 1 item))
669 (if (symbolp item) 669 (line (nth 2 item))
670 (setq item (cdr (assq item 670 (col (nth 3 item))
671 compilation-error-regexp-alist-alist)))) 671 (type (nth 4 item))
672 (let ((file (nth 1 item)) 672 end-line end-col fmt)
673 (line (nth 2 item)) 673 (if (consp file) (setq fmt (cdr file) file (car file)))
674 (col (nth 3 item)) 674 (if (consp line) (setq end-line (cdr line) line (car line)))
675 (type (nth 4 item)) 675 (if (consp col) (setq end-col (cdr col) col (car col)))
676 end-line end-col fmt) 676
677 (if (consp file) (setq fmt (cdr file) file (car file))) 677 `(,(nth 0 item)
678 (if (consp line) (setq end-line (cdr line) line (car line))) 678
679 (if (consp col) (setq end-col (cdr col) col (car col))) 679 ,@(when (integerp file)
680 680 `((,file ,(if (consp type)
681 (if (symbolp line) 681 `(compilation-face ',type)
682 ;; The old compile.el had here an undocumented hook that 682 (aref [compilation-info-face
683 ;; allowed `line' to be a function that computed the actual 683 compilation-warning-face
684 ;; error location. Let's do our best. 684 compilation-error-face]
685 `(,(car item) 685 (or type 2))))))
686 (0 (compilation-compat-error-properties 686
687 (funcall ',line (list* (match-string ,file) 687 ,@(when line
688 default-directory 688 `((,line compilation-line-face nil t)))
689 ',(nthcdr 4 item)) 689 ,@(when end-line
690 ,(if col `(match-string ,col))))) 690 `((,end-line compilation-line-face nil t)))
691 (,file compilation-error-face t)) 691
692 692 ,@(when col
693 `(,(nth 0 item) 693 `((,col compilation-column-face nil t)))
694 694 ,@(when end-col
695 ,@(when (integerp file) 695 `((,end-col compilation-column-face nil t)))
696 `((,file ,(if (consp type) 696
697 `(compilation-face ',type) 697 ,@(nthcdr 6 item)
698 (aref [compilation-info-face 698 (,(or (nth 5 item) 0)
699 compilation-warning-face 699 (compilation-error-properties ',file ,line ,end-line
700 compilation-error-face] 700 ,col ,end-col ',(or type 2)
701 (or type 2)))))) 701 ',fmt)
702 702 append)))) ; for compilation-message-face
703 ,@(when line 703 compilation-error-regexp-alist)
704 `((,line compilation-line-face nil t))) 704
705 ,@(when end-line 705 compilation-mode-font-lock-keywords))
706 `((,end-line compilation-line-face nil t)))
707
708 ,@(when col
709 `((,col compilation-column-face nil t)))
710 ,@(when end-col
711 `((,end-col compilation-column-face nil t)))
712
713 ,@(nthcdr 6 item)
714 (,(or (nth 5 item) 0)
715 (compilation-error-properties ',file ,line ,end-line
716 ,col ,end-col ',(or type 2)
717 ',fmt)
718 append))))) ; for compilation-message-face
719 compilation-error-regexp-alist)
720
721 compilation-mode-font-lock-keywords)))
722 706
723 707
724 ;;;###autoload 708 ;;;###autoload
725 (defun compile (command &optional comint) 709 (defun compile (command &optional comint)
726 "Compile the program including the current buffer. Default: run `make'. 710 "Compile the program including the current buffer. Default: run `make'.
1042 Note that all messages not positively identified as warning or 1026 Note that all messages not positively identified as warning or
1043 info, are considered errors." 1027 info, are considered errors."
1044 :type '(choice (const :tag "Warnings and info" 2) 1028 :type '(choice (const :tag "Warnings and info" 2)
1045 (const :tag "Info" 1) 1029 (const :tag "Info" 1)
1046 (const :tag "None" 0)) 1030 (const :tag "None" 0))
1047 :group 'compilation) 1031 :group 'compilation
1032 :version "21.4")
1048 1033
1049 (defcustom compilation-skip-visited nil 1034 (defcustom compilation-skip-visited nil
1050 "*Compilation motion commands skip visited messages if this is t. 1035 "*Compilation motion commands skip visited messages if this is t.
1051 Visited messages are ones for which the file, line and column have been jumped 1036 Visited messages are ones for which the file, line and column have been jumped
1052 to from the current content in the current compilation buffer, even if it was 1037 to from the current content in the current compilation buffer, even if it was
1053 from a different message." 1038 from a different message."
1054 :type 'boolean 1039 :type 'boolean
1055 :group 'compilation) 1040 :group 'compilation
1041 :version "21.4")
1056 1042
1057 ;;;###autoload 1043 ;;;###autoload
1058 (defun compilation-mode () 1044 (defun compilation-mode ()
1059 "Major mode for compilation log buffers. 1045 "Major mode for compilation log buffers.
1060 \\<compilation-mode-map>To visit the source for a line-numbered error, 1046 \\<compilation-mode-map>To visit the source for a line-numbered error,
1127 (defun compilation-setup (&optional minor) 1113 (defun compilation-setup (&optional minor)
1128 "Prepare the buffer for the compilation parsing commands to work." 1114 "Prepare the buffer for the compilation parsing commands to work."
1129 (make-local-variable 'compilation-current-error) 1115 (make-local-variable 'compilation-current-error)
1130 (make-local-variable 'compilation-error-screen-columns) 1116 (make-local-variable 'compilation-error-screen-columns)
1131 (setq compilation-last-buffer (current-buffer)) 1117 (setq compilation-last-buffer (current-buffer))
1132 (if (and minor font-lock-defaults)
1133 (font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
1134 (set (make-local-variable 'font-lock-defaults)
1135 '(compilation-mode-font-lock-keywords t)))
1136 (set (make-local-variable 'font-lock-extra-managed-props) 1118 (set (make-local-variable 'font-lock-extra-managed-props)
1137 '(directory message help-echo mouse-face debug)) 1119 '(directory message help-echo mouse-face debug))
1138 (set (make-local-variable 'compilation-locs) 1120 (set (make-local-variable 'compilation-locs)
1139 (make-hash-table :test 'equal :weakness 'value)) 1121 (make-hash-table :test 'equal :weakness 'value))
1140 ;; lazy-lock would never find the message unless it's scrolled to 1122 ;; lazy-lock would never find the message unless it's scrolled to
1141 ;; jit-lock might fontify some things too late. 1123 ;; jit-lock might fontify some things too late.
1142 (set (make-local-variable 'font-lock-support-mode) nil) 1124 (set (make-local-variable 'font-lock-support-mode) nil)
1143 (set (make-local-variable 'font-lock-maximum-size) nil) 1125 (set (make-local-variable 'font-lock-maximum-size) nil)
1144 (if minor 1126 (let ((fld font-lock-defaults))
1145 (if font-lock-mode 1127 (if (and minor fld)
1146 (font-lock-fontify-buffer) 1128 (font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
1147 (turn-on-font-lock)) 1129 (setq font-lock-defaults '(compilation-mode-font-lock-keywords t)))
1148 ;; maybe defer font-lock till after derived mode is set up 1130 (if minor
1149 (run-mode-hooks 'compilation-turn-on-font-lock))) 1131 (if font-lock-mode
1132 (if fld
1133 (font-lock-fontify-buffer)
1134 (font-lock-change-mode)
1135 (turn-on-font-lock))
1136 (turn-on-font-lock))
1137 ;; maybe defer font-lock till after derived mode is set up
1138 (run-mode-hooks 'compilation-turn-on-font-lock))))
1150 1139
1151 ;;;###autoload 1140 ;;;###autoload
1152 (define-minor-mode compilation-shell-minor-mode 1141 (define-minor-mode compilation-shell-minor-mode
1153 "Toggle compilation shell minor mode. 1142 "Toggle compilation shell minor mode.
1154 With arg, turn compilation mode on if and only if arg is positive. 1143 With arg, turn compilation mode on if and only if arg is positive.
1484 (next-error n)) 1473 (next-error n))
1485 1474
1486 (defcustom compilation-context-lines next-screen-context-lines 1475 (defcustom compilation-context-lines next-screen-context-lines
1487 "*Display this many lines of leading context before message." 1476 "*Display this many lines of leading context before message."
1488 :type 'integer 1477 :type 'integer
1489 :group 'compilation) 1478 :group 'compilation
1479 :version "21.4")
1490 1480
1491 (defsubst compilation-set-window (w mk) 1481 (defsubst compilation-set-window (w mk)
1492 ;; Align the compilation output window W with marker MK near top. 1482 ;; Align the compilation output window W with marker MK near top.
1493 (set-window-start w (save-excursion 1483 (set-window-start w (save-excursion
1494 (goto-char mk) 1484 (goto-char mk)