emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c9f845a: Put files in mhtml-mode when they have <!DOCTYPE, case-i


From: Lars Ingebrigtsen
Subject: master c9f845a: Put files in mhtml-mode when they have <!DOCTYPE, case-insensitive
Date: Sat, 19 Sep 2020 13:15:58 -0400 (EDT)

branch: master
commit c9f845a53c946f28820a476de7089f486ccaf6b9
Author: Daniel Martín <mardani29@yahoo.es>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Put files in mhtml-mode when they have <!DOCTYPE, case-insensitive
    
    * lisp/files.el (magic-fallback-mode-alist): Match "DOCTYPE" in a
    case-insensitive way before putting files in mhtml-mode. See
    https://html.spec.whatwg.org/multipage/syntax.html#the-doctype for the
    standard reference.
    * test/lisp/files-tests.el (files-test-magic-mode-alist-doctype): Add
    a test (bug#43511).
---
 lisp/files.el            |  2 +-
 test/lisp/files-tests.el | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 07d66c9..98de93c 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3067,7 +3067,7 @@ If FUNCTION is nil, then it is not called.  (That is a 
way of saying
                "\\(?:!DOCTYPE[ \t\r\n]+[^>]*>[ \t\r\n]*<[ \t\r\n]*" comment-re 
"*\\)?"
                "[Hh][Tt][Mm][Ll]"))
      . mhtml-mode)
-    ("<!DOCTYPE[ \t\r\n]+[Hh][Tt][Mm][Ll]" . mhtml-mode)
+    ("<![Dd][Oo][Cc][Tt][Yy][Pp][Ee][ \t\r\n]+[Hh][Tt][Mm][Ll]" . mhtml-mode)
     ;; These two must come after html, because they are more general:
     ("<\\?xml " . xml-mode)
     (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 5b2f5fd..b73eac2 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1365,5 +1365,17 @@ See <https://debbugs.gnu.org/36401>."
   (should (equal (parse-colon-path "/foo//bar/baz")
                  '("/foo/bar/baz/"))))
 
+(ert-deftest files-test-magic-mode-alist-doctype ()
+  "Test that DOCTYPE and variants put files in mhtml-mode."
+  (with-temp-buffer
+    (goto-char (point-min))
+    (insert "<!DOCTYPE html>")
+    (normal-mode)
+    (should (eq major-mode 'mhtml-mode))
+    (erase-buffer)
+    (insert "<!doctype html>")
+    (normal-mode)
+    (should (eq major-mode 'mhtml-mode))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]