From xemacs-m  Sat Mar 22 21:36:45 1997
Received: from alphatech.com (erebus.alphatech.com [198.112.236.2])
	by xemacs.org (8.8.5/8.8.5) with SMTP id VAA02352
	for <xemacs-beta@xemacs.org>; Sat, 22 Mar 1997 21:36:40 -0600 (CST)
Received: from venus.alphatech.com by alphatech.com (4.1/SMI-4.1)
	id AA23885; Sat, 22 Mar 97 22:31:59 EST
Received: from pochacco.alphatech.com by venus.alphatech.com (4.1/SMI-4.1)
	id AA00315; Sat, 22 Mar 97 22:40:15 EST
Received: by pochacco.alphatech.com (SMI-8.6/SMI-SVR4)
	id WAA05074; Sat, 22 Mar 1997 22:29:38 -0500
Date: Sat, 22 Mar 1997 22:29:38 -0500
Message-Id: <199703230329.WAA05074@pochacco.alphatech.com>
Mime-Version: 1.0
From: greg@alphatech.com (Greg Klanderman)
To: xemacs-beta@xemacs.org (XEmacs beta list)
Subject: patches to compile.el
Reply-To: greg@alphatech.com
Content-Type: text/plain; charset=US-ASCII



While downloading 19.15b103 (we have a really slow connection) I
decided to hack up a bunch of changes to compile.el.  These are wrt
b93, but the b103 version is identical.

The changes accomplish four things:

  - a new variable, compilation-mouse-motion-initiate-parsing, which
    controls whether mouse motion in the compilation buffer should
    initiate parsing.  there have been several requests for this
    including Barry's and my own.  Even Mly, who added the code has
    this to say 

                ;; #### Does it suck too badly to have mouse-movement
                ;; #### over a buffer parse errors in that buffer??

    I say "yes".

  - when parsing, the code tries to be careful when given a limiting
    line or number of errors to finish parsing all errors for the
    current file, so that all marks get set before you modify it.
    however, there was a bug in this when mouse motion initiated the
    parsing (not that that will get me anymore, due to #1). fixed

  - sped-up parsing by making the messages less frequent.  on 
    "grep defun packages/*.el", time goes from 45 sec to 4.  nice!
    thanks to Kyle, who noted speeding up the VM summary a similar way.

  - first cut at integrating changes sent by Michael McNamara
    (mac@silicon-sorcery.com) for picking subsets of the regexps.
    There is a new variable `compilation-error-regexp-systems-list' to
    choose the systems to support, default is 'all.  all that's needed
    is to set this before compile.el gets loaded.  there is also a new
    function `compilation-build-compilation-error-regexp-alist', and
    there is a new variable `compilation-error-regexp-alist-alist'
    used to build `compilation-error-regexp-alist'.  check it out and
    let me know what you think.  customize-ation is left as an
    exercise for someone who knows it.

sorry this is so late for 19.15, its ok if they don't make it

Greg

now to build b103...
then I'll look at fixing isearch history tomorrow

Steve- can we uncomment the code to get at the minibuffer prompt so a
hack (assuming fixed width font) can be written to better implement
resize-minibuffer-count-window-lines? (i don't use icomplete..)


-----

--- /local/mstar/.backups/!local!mstar!software!xemacs!install!lib!xemacs-19.15-b93!lisp!packages!compile.el.~1~	Sun Feb  2 00:05:50 1997
+++ /local/mstar/software/xemacs/install/lib/xemacs-19.15-b93/lisp/packages/compile.el	Sat Mar 22 21:58:36 1997
@@ -109,7 +109,57 @@
 
 (defvar compilation-num-errors-found)
 
-(defvar compilation-error-regexp-alist
+(defvar compilation-error-regexp-systems-list 'all
+  "This is either the symbol `all', or a list of systems for which
+compilation error regexps should be included in
+`compilation-error-regexp-alist'.  
+
+The list of known systems is:
+  gnu:      but of course
+  lcc:      Lucid compilers
+  ada:      Ada compilers
+  of:       Using tool that says line xx of foo.c
+  comma:    Using tool that says \"foo.c\", line 12
+  4bsd:     Using 4bsd
+  msft:     Using microsoft
+  borland:  Using Borland
+  mips:     Using Mips
+  sgi:      Using SGI
+  cray:     Using Cray
+  ibm:      IBM C compilers
+  aix:      the operating system
+  ultrix:   the operating system
+
+See also the variable `compilation-error-regexp-alist-alist'.")
+
+(defun compilation-filter-list (pred lst)
+  "Filter LST with predicate PRED.  A new list containing only
+those elements for which the predicate is non-nil is returned.
+
+Surely this must already exist somewhere else?!?"
+  (let ((result nil))
+    (while lst
+      (if (funcall pred (car lst))
+          (setq result (cons (car lst) result)))
+      (setq lst (cdr lst)))
+    (nreverse result)))
+
+(defun compilation-build-compilation-error-regexp-alist ()
+  (interactive)
+  (setq compilation-error-regexp-alist
+        (mapcar
+         'cdr
+         (compilation-filter-list
+          '(lambda (elt)
+             (let ((syslst (if (listp (car elt))
+                               (car elt)
+                             (list (car elt)))))
+               (or (not (listp compilation-error-regexp-systems-list))
+                   (intersection syslst
+                                 compilation-error-regexp-systems-list))))
+          compilation-error-regexp-alist-alist))))
+
+(defvar compilation-error-regexp-alist-alist
   '(
     ;; NOTE!  See also grep-regexp-alist, below.
 
@@ -125,52 +175,60 @@
     ;; We'll insist that the number be followed by a colon or closing
     ;; paren, because otherwise this matches just about anything
     ;; containing a number with spaces around it.
-    ("\
+    (4bsd
+     ("\
 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
-:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
+:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5))
 
     ;; Microsoft C/C++:
     ;;  keyboard.c(537) : warning C4005: 'min' : macro redefinition
     ;;  d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
-    ("\\(\\([a-zA-Z]:\\)?[^:( \t\n-]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" 1 3)
+    (msft
+     ("\\(\\([a-zA-Z]:\\)?[^:( \t\n-]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" 1 3))
 
     ;; Borland C++:
     ;;  Error ping.c 15: Unable to open include file 'sys/types.h'
     ;;  Warning ping.c 68: Call to function 'func' with no prototype
-    ("\\(Error\\|Warning\\) \\([a-zA-Z]?:?[^:( \t\n]+\\)\
- \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 2 3)
+    (borland
+     ("\\(Error\\|Warning\\) \\([a-zA-Z]?:?[^:( \t\n]+\\)\
+ \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 2 3))
 
     ;; 4.3BSD lint pass 2
     ;; 	strcmp: variable # of args. llib-lc(359)  ::  /usr/src/foo/foo.c(8)
-    ("[^\n]*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$"
-     1 2)
+    (4bsd
+     ("[^\n]*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$"
+      1 2))
 
     ;; 4.3BSD lint pass 3
     ;; 	bloofle defined( /users/wolfgang/foo.c(4) ), but never used
     ;; This used to be
     ;; ("[ \t(]+\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2)
     ;; which is regexp Impressionism - it matches almost anything!
-    ("[^\n]*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
+    (4bsd
+     ("[^\n]*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2))
 
     ;; MIPS lint pass<n>; looks good for SunPro lint also
     ;;  TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomon.c due to truncation
-    ("[^ \n]+ (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
-    ;;  name defined but never used: LinInt in cmap_calc.c(199)
-    ("[^\n]*in \\([^(\n]+\\)(\\([0-9]+\\))$" 1 2)
+    (mips
+     ("[^ \n]+ (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
+     ;;  name defined but never used: LinInt in cmap_calc.c(199)
+     ("[^\n]*in \\([^(\n]+\\)(\\([0-9]+\\))$" 1 2))
 
     ;; Ultrix 3.0 f77:
     ;;  fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol
     ;; Some SGI cc version:
     ;;  cfe: Warning 835: foo.c, line 2: something
-    ("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3)
+    ((sgi ultrix)
+     ("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3))
     ;;  Error on line 3 of t.f: Execution error unclassifiable statement    
     ;; Unknown who does this:
     ;;  Line 45 of "foo.c": bloofle undefined
     ;; Absoft FORTRAN 77 Compiler 3.1.3
     ;;  error on line 19 of fplot.f: spelling error?
     ;;  warning on line 17 of fplot.f: data type is undefined for variable d
-    ("\\(\\|[^\n]* on \\)[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
-of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2)
+    (of
+     ("\\(\\|[^\n]* on \\)[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
+of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2))
 
     ;; Apollo cc, 4.3BSD fc:
     ;;	"foo.f", line 3: Error: syntax error near end of statement
@@ -184,55 +242,77 @@
     ;;  "foo.adb", line 2(11): warning: file name does not match ...
     ;; IBM AIX xlc compiler:
     ;;  "src/swapping.c", line 30.34: 1506-342 (W) "/*" detected in comment.
-    ("[^\n]*\"\\([^,\" \n\t]+\\)\", lines? \
-\\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4)
+    (comma
+     ("[^\n]*\"\\([^,\" \n\t]+\\)\", lines? \
+\\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4))
 
     ;; MIPS RISC CC - the one distributed with Ultrix:
     ;;	ccom: Error: foo.c, line 2: syntax error
     ;; DEC AXP OSF/1 cc
     ;;  /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah 
-    ("[^\n]*rror: \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 1 3)
+    ((mips ultrix)
+     ("[^\n]*rror: \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 1 3))
 
     ;; IBM AIX PS/2 C version 1.1:
     ;;	****** Error number 140 in line 8 of file errors.c ******
-    ("[^\n]*in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
+    (aix
+     ("[^\n]*in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1))
     ;; IBM AIX lint is too painful to do right this way.  File name
     ;; prefixes entire sections rather than being on each line.
 
     ;; Lucid Compiler, lcc 3.x
     ;; E, file.cc(35,52) Illegal operation on pointers
-    ("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3)
+    (lcc
+     ("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3))
 
     ;; GNU messages with program name and optional column number.
-    ("[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
-\\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4)
+    (gnu
+     ("[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
+\\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4))
+
+    ;; ("grammar.y", line 2162) error: symbol input_identfiers is used,
+    ;; but is not defined as a token and has no rules
+    (gnu
+     ("\n\(\"\\([^\"]+\\)\", line \\([0-9]+\\)\) error:" 1 2))
 
     ;; GNU messages with program name and optional column number
     ;; and a severity letter after that.  nsgmls makes them.
-    ("[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
-\\([0-9]+\\):\\(\\([0-9]+\\):\\)?[A-Za-z]:" 1 2 4)
+    (gnu
+     ("[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
+\\([0-9]+\\):\\(\\([0-9]+\\):\\)?[A-Za-z]:" 1 2 4))
 
     ;; jwz:
     ;; IRIX 5.2
     ;; cfe: Warning 712: foo.c, line 2: illegal combination of pointer and ...
-    ("[^\n]* \\([^ \n,\"]+\\), line \\([0-9]+\\):" 1 2)
+    (sgi
+     ("[^\n]* \\([^ \n,\"]+\\), line \\([0-9]+\\):" 1 2))
     ;; IRIX 5.2
     ;; cfe: Warning 600: xfe.c: 170: Not in a conditional directive while ...
-    ("[^\n]*: \\([^ \n,\"]+\\): \\([0-9]+\\):" 1 2)
+    (sgi
+     ("[^\n]*: \\([^ \n,\"]+\\): \\([0-9]+\\):" 1 2))
 
     ;; Cray C compiler error messages
-    ("\\(cc\\| cft\\)-[0-9]+ c\\(c\\|f77\\): ERROR \\([^,\n]+, \\)* File = \\([^,\n]+\\), Line = \\([0-9]+\\)" 4 5)
+    (cray
+     ("\\(cc\\| cft\\)-[0-9]+ c\\(c\\|f77\\): ERROR \\([^,\n]+, \\)* File = \\([^,\n]+\\), Line = \\([0-9]+\\)" 4 5))
 
     ;; 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)
+    (ibm
+     ("\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) : " 1 2 3))
 
     ;; Sun ada (VADS, Solaris):
     ;;  /home3/xdhar/rcds_rc/main.a, line 361, char 6:syntax error: "," inserted
-    ("\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3)
+    (ada
+     ("\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3))
     )
+  "Alist of (system regexp-alist) for building
+`compilation-error-regexp-alist'.  SYSTEM is either a system identifier,
+or a list of system identifiers.  See the variable 
+`compilation-error-regexp-systems-list'")
+
+(defvar compilation-error-regexp-alist nil
  "Alist that specifies how to match errors in compiler output.
 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
 If REGEXP matches constrained to the beginning of the line, the
@@ -243,7 +323,13 @@
 to try; %s in the string is replaced by the text matching the
 FILE-IDX'th subexpression.  Note previously REGEXP was not constrained
 to the beginning of the line, so old patterns without leading `^' or `\\n'
-may now require a leading `.*'.")
+may now require a leading `.*'.
+
+Note that this now gets set by the function 
+`compilation-build-compilation-error-regexp-alist' using the 
+value of the variable `compilation-error-regexp-alist-alist'")
+
+(compilation-build-compilation-error-regexp-alist)
 
 (defvar compilation-read-command t
   "If not nil, M-x compile reads the compilation command to use.
@@ -333,6 +419,10 @@
 (put 'compilation-mode 'font-lock-defaults
      '(compilation-font-lock-keywords t))
 
+(defvar compilation-mouse-motion-initiate-parsing t
+  "When set to a non-nil value, mouse motion over the compilation/grep output
+buffer may initiate parsing of the error messages or grep hits")
+
 
 ;;;###autoload
 (defun compile (command)
@@ -712,8 +802,9 @@
   (set (make-local-variable 'compilation-directory-stack) nil)
   (setq compilation-last-buffer (current-buffer))
   ;; XEmacs change: highlight lines, install menubar.
-  (require 'mode-motion)
-  (setq mode-motion-hook 'compilation-mode-motion-hook)
+  (when compilation-mouse-motion-initiate-parsing
+    (require 'mode-motion)
+    (setq mode-motion-hook 'compilation-mode-motion-hook))
   (make-local-variable 'mouse-track-click-hook)
   (add-hook 'mouse-track-click-hook 'compile-mouse-maybe-goto-error)
   )
@@ -1507,7 +1598,8 @@
 	regexp enter-group leave-group error-group
 	alist subexpr error-regexp-groups
 	(found-desired nil)
-	(compilation-num-errors-found 0))
+	(compilation-num-errors-found 0)
+        (message-freq (max 1 (/ (count-lines (point-min) (point-max)) 50))))
 
     ;; Don't reparse messages already seen at last parse.
     (goto-char compilation-parsing-end)
@@ -1746,15 +1838,17 @@
 	    (t
 	     (error "compilation-parse-errors: known groups didn't match!")))
 
-      (message "Parsing error messages...%d (%.0f%% of buffer)"
-	       compilation-num-errors-found
-	       ;; Use floating-point because (* 100 (point)) frequently
-	       ;; exceeds the range of Emacs Lisp integers.
-	       (/ (* 100.0 (point)) (point-max)))
-
-      (and limit-search (>= (point) limit-search)
-	   ;; The user wanted a specific error, and we're past it.
-	   (setq found-desired t)))
+      (when (= (% compilation-num-errors-found message-freq) 0)
+        (message "Parsing error messages...%d (%.0f%% of buffer)"
+                 compilation-num-errors-found
+                 ;; Use floating-point because (* 100 (point)) frequently
+                 ;; exceeds the range of Emacs Lisp integers.
+                 (/ (* 100.0 (point)) (point-max))))
+
+;      (and limit-search (>= (point) limit-search)
+;	   ;; The user wanted a specific error, and we're past it.
+;	   (setq found-desired t))
+      )
     (setq compilation-parsing-end (if found-desired
 				      (point)
 				    ;; We have searched the whole buffer.

