summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2004-11-11 04:52:27 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2004-11-11 04:52:27 +0000
commit32a0479a9d9bffd3c1a8e29b5e682669ce38073a (patch)
tree123e427977f0751afaf6f1a1fcb3ba604268b997 /lisp/files.el
parent32e2fb042912d91fdb27290fb2c1ec76b45582a1 (diff)
downloademacs-32a0479a9d9bffd3c1a8e29b5e682669ce38073a.tar.gz
(magic-mode-alist): Reduce backtracking in the HTML regexp.
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el
index bfbf0cf39d0..a9a63019997 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1866,10 +1866,14 @@ regular expression. The mode is then determined as the mode associated
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)