unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: 2 fixes for compile.el
Date: Sat, 16 Nov 2002 18:27:21 +0100	[thread overview]
Message-ID: <20021116182721.578db725.occitan@esperanto.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]

Hi,

Sorry, this time it's definite.  My post yesterday had some glitches, and while debugging them I corrected and slimmed down quite a few of the regexps.  Now I match all of the messages provided as examples except for the "horrible fc" and BSD lint 2 (both of which didn't work before either) and BSD lint 3, which still matches way too much.

While doing this it struck me that compile is a horrible cludge from prehistorical times.  Now that font lock can trivially set arbitrary properties -- and does it much better than the stop & go approach of compile!!! --, it would be best to let it do the whole parsing.

next-error and the like would then only have to scan the buffer for fileinfo text properties left for it by font lock.  I guess this would make the library a third smaller and more efficient too.

best regards
Daniel

---------------

Two more things:

- the word warning now gets found case insensitively in my new diff

- font-lock in CVS has for quite a few versions contained the line

,(+ ,c-type-names-depth 2))

which understandably causes an error for me in c-mode.  But even taking away the comma leaves the var undefined :-( (in 1.199 which is the latest that might have worked with 21.2)

---------------

Hi,

this fixes 2 things:

- warnings and errors didn't get distinguished which finally got insupportable with strict gcc 3.2

- compile buffers are hypertext but didn't have mouse hightlight

Note that the latter uses font-lock's facename as property list, which was documented in 21.2 (as delivered by SuSE 8.1), but only works when getting a newer font-lock and syntax from CVS.

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

-- 
 -- http://dapfy.bei.t-online.de/sawfish/
  --


[-- Attachment #2: ChangeLog --]
[-- Type: application/octet-stream, Size: 503 bytes --]

2002-11-16  Daniel Pfeiffer  <occitan@esperanto.org>

	* compile.el (font-lock-compile-error-face,
	font-lock-compile-warning-face): new faces
	* compile.el (compile-error-or-warning-face): new fun
	* compile.el (compilation-mode-font-lock-keywords): add previous
	* compile.el (compilation-non-error-initials): new var
	* compile.el (compilation-error-regexp-alist): added TYPE-IDX
	before FORMATS, all work except HPUX fc & 4.3BSD lint pass 2/3
	* compile.el (compilation-parse-errors): strip TYPE-IDX

[-- Attachment #3: compile.el.diff --]
[-- Type: application/octet-stream, Size: 9289 bytes --]

222a223,227
> (defvar compilation-non-error-initials '(?w ?W ?i)
>   "These initial letters indicate a warning rather than an error.
> They are compared to the first letter matched by TYPE-IDX in
> `compilation-error-regexp-alist', if TYPE-IDX was given.")
> 
227,229c232
<     ;; 4.3BSD grep, cc, lint pass 1:
<     ;; 	/usr/src/foo/foo.c(8): warning: w may be used before set
<     ;; or GNU utilities:
---
>     ;; GNU utilities:
231,232d233
<     ;; or HP-UX 7.0 fc:
<     ;; 	foo.f          :16    some horrible error message
246,247c247,248
< \\([a-zA-Z]?:?[^:( \t\n]*[^:( \t\n0-9][^:( \t\n]*\\)[:(][ \t]*\\([0-9]+\\)\
< \\([) \t]\\|:\\(\\([0-9]+:\\)\\|[0-9]*[^:0-9]\\)\\)" 2 3 6)
---
> \\([a-zA-Z]?:?[^:( \t\n]*[^:( \t\n0-9][^:( \t\n]*\\):[ \t]*\\([0-9]+\\)\
> \\([) \t]\\|:\\(\\([0-9]+\\):\\|[0-9]*[^:0-9]\\)\\) *\\(warning\\|W:\\)?" 2 3 6 7)
252,255d252
<     ("\\([a-zA-Z][-a-zA-Z._0-9]+\\): ?\
< \\([0-9]+\\)\\.\\([0-9]+\\)\
< -\\([0-9]+\\)\\.\\([0-9]+\\)\
< :" 1 2 3) ;; When ending points are supported, add line = 4 and col = 5.
257,265d253
<     ("\\([a-zA-Z][-a-zA-Z._0-9]+\\): ?\
< \\([0-9]+\\)\\.\\([0-9]+\\)\
< -\\([0-9]+\\)\
< :" 1 2 3) ;; When ending points are supported, add line = 2 and col = 4.
<     ;;  foo.c:8-45.3: error message
<     ("\\([a-zA-Z][-a-zA-Z._0-9]+\\): ?\
< \\([0-9]+\\)\
< -\\([0-9]+\\)\\.\\([0-9]+\\)\
< :" 1 2 nil) ;; When ending points are supported, add line = 2 and col = 4.
267,269c255
<     ("\\([a-zA-Z][-a-zA-Z._0-9]+\\): ?\
< \\([0-9]+\\)\\.\\([0-9]+\\)\
< :" 1 2 3)
---
>     ;;  foo.c:8-45.3: error message
272,274c258,273
< \\([0-9]+\\)\
< -\\([0-9]+\\)\
< :" 1 2 nil);; When ending points are supported, add line = 3.
---
> \\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?\
> \\(-\\([0-9]+\\)\\)?\\(\\.\\([0-9]+\\)\\)?\
> :" 1 2 4)
> 
>     ;; 4.3BSD grep, cc, lint pass 1:
>     ;; 	/usr/src/foo/foo.c(8): warning: w may be used before set
>     ;; or IBM C/C++ Tools 2.01:
>     ;;  foo.c(2:0) : informational EDC0804: Function foo is not referenced.
>     ;;  foo.c(3:8) : warning EDC0833: Implicit return statement encountered.
>     ;;  foo.c(5:5) : error EDC0350: Syntax error.
>     ("\\([^( \n\t]+\\)(\\([0-9]+\\)\\(:\\([0-9]+\\)\\)?) *: \\([iwe]\\)?" 1 2 4 5)
> 
>     ;; The first monster rule matched this, but wrongly
>     ;; HP-UX 7.0 fc:
>     ;; 	foo.f          :16    some horrible error message
> 
286c285
< : \\(error\\|warning\\) C[0-9]+:" 1 3)
---
> : \\(error\\|warning\\) C[0-9]+:" 1 3 nil 4)
295c294
<  \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 4 5)
---
>  \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 4 5 nil 1)
301c300,301
<     ("^==[0-9]+==[^(]+\(([^:]+):([0-9]+)" 1 2)
---
>     ;; (too bad he tried Perl regexps, which emacs doesn't understand :-)
>     ("==[0-9]+==[^(]+(\\([^:]+\\):\\([0-9]+\\))" 1 2)
305,306c305,306
<     (".*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$"
<      1 2)
---
>     ;; this doesn't match the above message
>     ;;(".*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$" 1 2)
313c313,314
<     (".*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
---
>     ;; and this still does:
>     ;;(".*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
325c326
<     ("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3)
---
>     ("\\(cfe\\|fort\\): \\([^:\n]*\\): \\([^ \n]*\\), line \\([0-9]+\\):" 3 4 nil 2)
333c334
< of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2)
---
> of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil 1)
346c347
< \\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4)
---
> \\([0-9]+\\)\\(\\([\(.]\\|pos \\)\\([0-9]+\\)\)?\\)?[:;., (-][^a-zA-Z]*(?\\(W)\\|warning\\)?" 1 2 5 6)
350,351d350
<    ("^File \"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)," 1 2)
< 
354c353
<    ("^File \"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)[-0-9]*, characters? \\([0-9]+\\)" 1 2 3)
---
>     ("File \"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)\\([-0-9]*, characters? \\([0-9]+\\)\\)?" 1 2 4)
360c359
<     ("[a-z0-9/]+: \\([eE]rror\\|[wW]arning\\): \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 2 4)
---
>     ("[a-z0-9/]+: \\([eE]rror\\|[wW]arning\\): \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 2 4 nil 1)
380c379
<     ("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3)
---
>     ("\\([EW]\\), \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 2 3 4 1)
391,396d389
<     ;; IBM C/C++ Tools 2.01:
<     ;;  foo.c(2:0) : informational EDC0804: Function foo is not referenced.
<     ;;  foo.c(3:8) : warning EDC0833: Implicit return statement encountered.
<     ;;  foo.c(5:5) : error EDC0350: Syntax error.
<     ("\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) : " 1 2 3)
< 
400c393
<     ("\"\\(.*\\)\",\\([0-9]+\\)\\s-+\\(Error\\|Warning\\)\\[[0-9]+\\]:" 1 2)
---
>     ("\"\\(.*\\)\",\\([0-9]+\\)\\s-+\\(Error\\|Warning\\)\\[[0-9]+\\]:" 1 2 nil 3)
423,424c416
<     (".*: ERROR File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
<     (".*: WARNING File = \\(.+\\), Line = \\([0-9]+\\)" 1 2)
---
>     (".*: \\(ERROR\\|WARNING\\) File = \\(.+\\), Line = \\([0-9]+\\)" 2 3 nil 1)
434,435d425
<     ("Error:.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
<      3 1 2)
438,439c428,429
<     ("Warning:.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
<      3 1 2)
---
>     ("\\(Error\\|Warning\\):.*\n.* line \\([0-9]+\\) char \\([0-9]+\\) of file://\\(.+\\)"
>      4 2 3 1)
443c433
< Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
---
> Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX TYPE-IDX FILE-FORMAT...])
446a437
> If TYPE-IDX is given, compare TYPE-IDX'th subexpression with `compilation-non-error-initials'.
597a589,620
> (defface font-lock-compile-error-face
>   '((((type tty) (class color)) (:foreground "red"))
>     (((class color) (background light)) (:foreground "Red" :weight bold))
>     (((class color) (background dark)) (:foreground "Pink" :weight bold))
>     (t (:inverse-video t :weight bold)))
>   "Font Lock mode face used to highlight compiler errors."
>   :group 'font-lock-highlighting-faces)
> 
> (defface font-lock-compile-warning-face
>   '((((type tty) (class color)) (:foreground "cyan" :weight bold))
>     (((class color) (background light)) (:foreground "Purple" :weight bold))
>     (((class color) (background dark)) (:foreground "Cyan" :weight bold))
>     (t (:weight bold)))
>   "Font Lock mode face used to highlight compiler warnings."
>   :group 'font-lock-highlighting-faces)
> 
> (defun compile-error-or-warning-face (type)
>   "Choose face for whether we're highlighting an error or warning."
>   `(face ,(if type
> 	      (if (and (setq type (match-string type))
> 		       (> (length type) 0)
> 		       (memq (aref type 0) compilation-non-error-initials))
> 		  'font-lock-compile-warning-face
> 		'font-lock-compile-error-face)
> 	    (save-match-data
> 	      (save-excursion
> 		(beginning-of-line)
> 		(if (let ((case-fold-search t)) (looking-at ".*warning"))
> 		    'font-lock-compile-warning-face
> 		  'font-lock-compile-error-face))))
>     mouse-face highlight))
> 
600,629c623,648
<   (nconc
<    ;;
<    ;; Compiler warning/error lines.
<    (mapcar (function
< 	    (lambda (item)
< 	      ;; Prepend "^", adjusting FILE-IDX and LINE-IDX accordingly.
< 	      (let ((file-idx (nth 1 item))
< 		    (line-idx (nth 2 item))
< 		    (col-idx (nth 3 item))
< 		    keyword)
< 		(when (numberp col-idx)
< 		  (setq keyword
< 			(cons (list (1+ col-idx) 'font-lock-type-face nil t)
< 			      keyword)))
< 		(when (numberp line-idx)
< 		  (setq keyword
< 			(cons (list (1+ line-idx) 'font-lock-variable-name-face)
< 			      keyword)))
< 		(when (numberp file-idx)
< 		  (setq keyword
< 			(cons (list (1+ file-idx) 'font-lock-warning-face)
< 			      keyword)))
< 		(cons (concat "^\\(" (nth 0 item) "\\)") keyword))))
< 	   compilation-error-regexp-alist)
<    (list
<     ;;
<     ;; Compiler output lines.  Recognize `make[n]:' lines too.
<     '("^\\([A-Za-z_0-9/\.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
<       (1 font-lock-function-name-face) (3 font-lock-comment-face nil t)))
<    ))
---
>   `(;; Compiler warning/error lines.
>     ,@(mapcar (lambda (item)
> 		(let ((file-idx (nth 1 item))
> 		      (line-idx (nth 2 item))
> 		      (col-idx (nth 3 item))
> 		      (type-idx (nth 4 item))
> 		      keyword)
> 		  (when (numberp col-idx)
> 		    (setq keyword
> 			  `((,(1+ col-idx) font-lock-type-face nil t))))
> 		  (when (numberp line-idx)
> 		    (setq keyword
> 			  `((,(1+ line-idx) font-lock-variable-name-face)
> 			    ,@keyword)))
> 		  (when (numberp file-idx)
> 		    (setq keyword
> 			  `((,(1+ file-idx)
> 			     (compile-error-or-warning-face ,(if (numberp type-idx)
> 								 (1+ type-idx))))
> 			    ,@keyword)))
> 		  ;; Prepend "^", adjusting FILE-IDX and LINE-IDX accordingly.
> 		  (cons (concat "^\\(" (nth 0 item) "\\)") keyword)))
> 	      compilation-error-regexp-alist)
>       ;; Compiler output lines.  Recognize `make[n]:' lines too.
>       ("^\\([A-Za-z_0-9/\.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
>        (1 font-lock-function-name-face) (3 font-lock-comment-face nil t))))
2162c2181
< 			  (cons filename (cons default-directory (cdr alist))))
---
> 			  (cons filename (cons default-directory (cddr alist))))

             reply	other threads:[~2002-11-16 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-16 17:27 Daniel Pfeiffer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-11-16 21:12 2 fixes for compile.el Daniel Pfeiffer
2002-11-16 21:51 Daniel Pfeiffer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021116182721.578db725.occitan@esperanto.org \
    --to=occitan@esperanto.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).