Commits

Anonymous committed 84fced6

PR#4994: ocaml-mode doesn't work with xemacs21

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12840f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (3)

 - ocamldep now supports -absname
 
 Bug fixes:
+- PR#4762: ?? is not used at all, but registered as a lexer token
+- PR#4994: ocaml-mode doesn't work with xemacs21
 - PR#5327: (Windows) Unix.select blocks if same socket listed in first and
   third arguments
 - PR#5551: Avoid repeated lookups for missing cmi files
 - PR#5695: remove warnings on sparc code emitter
 - PR#5697: better location for warnings on statement expressions
 - PR#5698: remove harcoded limit of 200000 labels in emitaux.ml
-- PR#4762: ?? is not used at all, but registered as a lexer token
 - PR#5708: catch Failure"int_of_string" in ocamldebug
 
 Internals:
 	$(EMACS) --batch --eval '$(COMPILECMD)'
 
 clean:
-	rm -f ocamltags *~ #*# *.elc
+	rm -f ocamltags *~ \#*# *.elc
   "Syntax table in use in Caml mode buffers.")
 (if caml-mode-syntax-table
     ()
-  (setq caml-mode-syntax-table (make-syntax-table))
-  ; backslash is an escape sequence
-  (modify-syntax-entry ?\\ "\\" caml-mode-syntax-table)
-  ; ( is first character of comment start
-  (modify-syntax-entry ?\( "()1n" caml-mode-syntax-table)
-  ; * is second character of comment start,
-  ; and first character of comment end
-  (modify-syntax-entry ?*  ". 23n" caml-mode-syntax-table)
-  ; ) is last character of comment end
-  (modify-syntax-entry ?\) ")(4" caml-mode-syntax-table)
-  ; backquote was a string-like delimiter (for character literals)
-  ; (modify-syntax-entry ?` "\"" caml-mode-syntax-table)
-  ; quote and underscore are part of words
-  (modify-syntax-entry ?' "w" caml-mode-syntax-table)
-  (modify-syntax-entry ?_ "w" caml-mode-syntax-table)
-  ; ISO-latin accented letters and EUC kanjis are part of words
-  (let ((i 160))
-    (while (< i 256)
-      (modify-syntax-entry i "w" caml-mode-syntax-table)
-      (setq i (1+ i)))))
+  (let ((n (if (string-match "XEmacs" (emacs-version)) "" "n")))
+    (setq caml-mode-syntax-table (make-syntax-table))
+    ; backslash is an escape sequence
+    (modify-syntax-entry ?\\ "\\" caml-mode-syntax-table)
+    ; ( is first character of comment start
+    (modify-syntax-entry ?\( (concat "()1" n) caml-mode-syntax-table)
+    ; * is second character of comment start,
+    ; and first character of comment end
+    (modify-syntax-entry ?*  (concat ". 23" n) caml-mode-syntax-table)
+    ; ) is last character of comment end
+    (modify-syntax-entry ?\) ")(4" caml-mode-syntax-table)
+    ; backquote was a string-like delimiter (for character literals)
+    ; (modify-syntax-entry ?` "\"" caml-mode-syntax-table)
+    ; quote and underscore are part of words
+    (modify-syntax-entry ?' "w" caml-mode-syntax-table)
+    (modify-syntax-entry ?_ "w" caml-mode-syntax-table)
+    ; ISO-latin accented letters and EUC kanjis are part of words
+    (let ((i 160))
+      (while (< i 256)
+        (modify-syntax-entry i "w" caml-mode-syntax-table)
+        (setq i (1+ i))))))
 
 (defvar caml-mode-abbrev-table nil
   "Abbrev table used for Caml mode buffers.")
   "^[ A-\377]+ \"\\([^\"\n]+\\)\", [A-\377]+ \\([0-9]+\\)[-,:]"
   "Regular expression matching the error messages produced by camlc.")
 
+;; Newer emacs versions support line/char ranges
+;; We will adapt OCaml to output error messages in a compatible format.
+;; In the meantime we add the new format here in addition to the old one.
+(defconst caml-error-regexp-newstyle
+  "^File \"\\([^\"\n]+\\)\", line \\([0-9]+\\), char \\([0-9]+\\) to line \\([0-9]+\\), char \\([0-9]+\\):"
+  "Regular expression matching the error messages produced by ocamlc/ocamlopt.")
+
 (if (boundp 'compilation-error-regexp-alist)
-    (or (assoc caml-error-regexp
-               compilation-error-regexp-alist)
-        (setq compilation-error-regexp-alist
-              (cons (list caml-error-regexp 1 2)
-               compilation-error-regexp-alist))))
+    (progn
+      (or (assoc caml-error-regexp
+                 compilation-error-regexp-alist)
+          (setq compilation-error-regexp-alist
+                (cons (list caml-error-regexp 1 2)
+                      compilation-error-regexp-alist)))
+      (or (assoc caml-error-regexp-newstyle
+                 compilation-error-regexp-alist)
+          (setq compilation-error-regexp-alist
+                (cons (list caml-error-regexp-newstyle 1 '(2 . 4) '(3 . 5))
+                      compilation-error-regexp-alist)))))
 
 ;; A regexp to extract the range info