diff lisp/files.el @ 58130:702ed45c4f39

(magic-mode-alist): Reduce backtracking in the HTML regexp.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 11 Nov 2004 04:52:27 +0000
parents 41a9a68ee897
children b80bdcafb346
line wrap: on
line diff
--- a/lisp/files.el	Wed Nov 10 22:35:21 2004 +0000
+++ b/lisp/files.el	Thu Nov 11 04:52:27 2004 +0000
@@ -1866,10 +1866,14 @@
 with that interpreter in `interpreter-mode-alist'.")
 
 (defvar magic-mode-alist
-  '(;; The < comes before the groups (but the first) to reduce backtracking.
-    ;; Is there a nicer way of getting . including \n like Perl's //s?
+  `(;; The < comes before the groups (but the first) to reduce backtracking.
     ;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
-    ("\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\)?\\s *\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*[Hh][Tt][Mm][Ll]" . html-mode)
+    (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
+	     (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
+	(concat "\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<"
+		comment-re "*"
+		"\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *" comment-re "*\\)?"
+		"[Hh][Tt][Mm][Ll]")) . html-mode)
     ;; These two must come after html, because they are more general:
     ("<\\?xml " . xml-mode)
     ("\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*!DOCTYPE " . sgml-mode)