Variable: mhtml-ts-mode-abbrev-table
mhtml-ts-mode-abbrev-table is a variable defined in
mhtml-ts-mode.el.gz.
Value
#<obarray n=1>
Documentation
Abbrev table for mhtml-ts-mode.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/mhtml-ts-mode.el.gz
;;;###autoload
(define-derived-mode mhtml-ts-mode html-ts-mode
'("HTML+" (:eval (let ((lang (treesit-language-at (point))))
(cond ((eq lang 'html) "")
((eq lang 'javascript) "JS")
((eq lang 'css) "CSS")))))
"Major mode for editing HTML with embedded JavaScript and CSS.
Powered by tree-sitter."
(if (not (and
(treesit-ensure-installed 'html)
(treesit-ensure-installed 'javascript)
(treesit-ensure-installed 'css)))
(error "Tree-sitter parsers for HTML isn't available. You can
install the parsers with M-x `mhtml-ts-mode-install-parsers'")
;; When an language is embedded, you should initialize some variable
;; just like it's done in the original mode.
;; Comment.
(setq-local comment-multi-line t)
(setq-local comment-setup-function #'mhtml-ts-mode--comment-setup)
;; Font-lock.
;; There are two ways to handle embedded code:
;; 1. Use a single parser for all the embedded code in the buffer. In
;; this case, the embedded code blocks are concatenated together and are
;; seen as a single continuous document to the parser.
;; 2. Each embedded code block gets its own parser. Each parser only sees
;; that particular code block.
;; If you go with 2 for a language, the local parsers are created and
;; destroyed automatically by Emacs. So don't create a global parser for
;; that embedded language here.
;; Create the parsers, only the global ones.
;; jsdoc is a local parser, don't create a parser for it.
(treesit-parser-create 'css)
(treesit-parser-create 'javascript)
;; Multi-language modes must set the primary parser.
(setq-local treesit-primary-parser (treesit-parser-create 'html))
(setq-local treesit-range-settings mhtml-ts-mode--range-settings)
;; jsdoc is not mandatory for js-ts-mode, so we respect this by
;; adding jsdoc range rules only when jsdoc is available.
(when (treesit-ensure-installed 'jsdoc)
(setq-local c-ts-common--comment-regexp
js--treesit-jsdoc-comment-regexp))
(setq-local prettify-symbols-alist mhtml-ts-mode--prettify-symbols-alist)
;; Indent.
;; Since `mhtml-ts-mode' inherits indentation rules from `html-ts-mode', `js-ts-mode'
;; and `css-ts-mode', if you want to change the offset you have to act on the
;; *-offset variables defined for those languages.
;; JavaScript and CSS must be indented relative to their code block.
;; This is done by inserting a special rule before the normal
;; indentation rules of these languages.
;; The value of `mhtml-ts-mode--js-css-indent-offset' changes based on
;; `mhtml-ts-mode-tag-relative-indent' and can be used to indent
;; JavaScript and CSS code relative to the HTML that contains them,
;; just like in mhtml-mode.
(setq-local treesit-simple-indent-rules
(mhtml-ts-mode--treesit-indent-rules))
;; Navigation.
;; This is for which-function-mode.
;; Since mhtml-ts-mode is derived from html-ts-mode, which sets
;; the value of `treesit-defun-type-regexp', you have to reset it to nil
;; otherwise `imenu' and `which-function-mode' will not work.
(setq-local treesit-defun-type-regexp nil)
;; This is for finding defun name, it's used by IMenu as default
;; function no specific functions are defined.
(setq-local treesit-defun-name-function #'mhtml-ts-mode--defun-name)
;; Define what are 'thing' for treesit.
;; 'Thing' is a symbol representing the thing, like `defun', `sexp', or
;; `sentence'.
;; As an alternative, if you want just defun, you can define a `treesit-defun-type-regexp'.
(setq-local treesit-thing-settings mhtml-ts-mode--treesit-thing-settings)
;; Font-lock.
;; In a multi-language scenario, font lock settings are usually a
;; concatenation of language rules. As you can see, it is possible
;; to extend/modify the default rule or use a different set of
;; rules. See `php-ts-mode--custom-html-font-lock-settings' for more
;; advanced usage.
(setq-local treesit-font-lock-settings (mhtml-ts-mode--treesit-font-lock-settings))
;; Tells treesit the list of features to fontify.
(setq-local treesit-font-lock-feature-list mhtml-ts-mode--treesit-font-lock-feature-list)
;; Imenu
;; Setup Imenu: if no function is specified, try to find an object
;; using `treesit-defun-name-function'.
(setq-local treesit-aggregated-simple-imenu-settings
mhtml-ts-mode--treesit-aggregated-simple-imenu-settings)
(setq-local treesit-aggregated-outline-predicate
mhtml-ts-mode--treesit-aggregated-outline-predicate)
(treesit-major-mode-setup)
;; This is sort of a prog-mode as well as a text mode.
(run-mode-hooks 'prog-mode-hook)
;; Flymake
(add-hook 'flymake-diagnostic-functions #'mhtml-ts-mode-flymake-mhtml nil 'local)))