Function: mhtml-mode

mhtml-mode is an autoloaded, interactive and byte-compiled function defined in mhtml-mode.el.gz.

Signature

(mhtml-mode)

Documentation

Major mode based on html-mode, but works with embedded JS and CSS.

Code inside a <script> element is indented using the rules from js-mode; and code inside a <style> element is indented using the rules from css-mode.

In addition to any hooks its parent mode might have run, this mode runs the hook mhtml-mode-hook, as the final or penultimate step during initialization.

Probably introduced at or before Emacs version 26.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/mhtml-mode.el.gz
;;;###autoload
(define-derived-mode mhtml-mode html-mode
  '((sgml-xml-mode "XHTML+" "HTML+") (:eval (mhtml--submode-lighter)))
  "Major mode based on `html-mode', but works with embedded JS and CSS.

Code inside a <script> element is indented using the rules from
`js-mode'; and code inside a <style> element is indented using
the rules from `css-mode'."
  (setq-local indent-line-function #'mhtml-indent-line)
  (setq-local syntax-propertize-function #'mhtml-syntax-propertize)
  (setq-local font-lock-fontify-region-function
              #'mhtml--submode-fontify-region)
  (setq-local hs-block-start-regexp "{\\|<[^/>]*?")
  (setq-local hs-block-end-regexp "}\\|</[^/>]*[^/]>")
  (setq-local hs-forward-sexp-function #'mhtml-forward)

  ;; Attach this to both pre- and post- hooks just in case it ever
  ;; changes a key binding that might be accessed from the menu bar.
  (add-hook 'pre-command-hook #'mhtml--pre-command nil t)
  (add-hook 'post-command-hook #'mhtml--pre-command nil t)

  ;; Make any captured variables buffer-local.
  (mhtml--mark-buffer-locals mhtml--css-submode)
  (mhtml--mark-buffer-locals mhtml--js-submode)

  (mhtml--mark-crucial-buffer-locals mhtml--css-submode)
  (mhtml--mark-crucial-buffer-locals mhtml--js-submode)
  (setq mhtml--crucial-variables (delete-dups mhtml--crucial-variables))

  ;: Hack
  (js--update-quick-match-re)

  ;; Setup the appropriate js-mode value of auto-fill-function.
  (setf (mhtml--submode-crucial-captured-locals mhtml--js-submode)
        (push (cons 'auto-fill-function
                    (if (and (boundp 'auto-fill-function) auto-fill-function)
                        #'js-do-auto-fill
                      nil))
              (mhtml--submode-crucial-captured-locals mhtml--js-submode)))

  ;; This mode might be using CC Mode's filling functionality.
  (c-foreign-init-lit-pos-cache)
  (add-hook 'before-change-functions #'c-foreign-truncate-lit-pos-cache nil t)

  ;; This is sort of a prog-mode as well as a text mode.
  (run-mode-hooks 'prog-mode-hook))