Function: markdown-ts--code-block-language-mode
markdown-ts--code-block-language-mode is a byte-compiled function
defined in markdown-ts-mode.el.gz.
Signature
(markdown-ts--code-block-language-mode LANG)
Documentation
Compute and cache a mode symbol from LANG, a symbol.
Consult the markdown-ts-code-block-modes cache, or consult
treesit-major-mode-remap-alist and major-mode-remap-alist, or brute
force mode probe. Return a valid mode symbol or nil.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/markdown-ts-mode.el.gz
(defun markdown-ts--code-block-language-mode (lang)
"Compute and cache a mode symbol from LANG, a symbol.
Consult the `markdown-ts-code-block-modes' cache, or consult
`treesit-major-mode-remap-alist' and `major-mode-remap-alist', or brute
force mode probe. Return a valid mode symbol or nil."
(if-let* ((mapped-mode (car (alist-get lang markdown-ts-code-block-modes))))
mapped-mode
(let* ((lang-string (symbol-name lang))
(lang-mode (concat lang-string "-mode"))
(mode))
(if (setq mode (alist-get lang-mode treesit-major-mode-remap-alist))
mode
(if (setq mode (alist-get lang-mode major-mode-remap-alist))
mode
(catch :mode
(dolist (mode
(list
;; Try a treesit mode using the raw string.
(concat lang-string "-ts-mode")
;; Try a conventional mode using the raw string.
lang-mode
;; Try a treesit mode using the downcased string.
(concat (downcase lang-string) "-ts-mode")
;; Try a conventional mode using the downcased string.
(concat (downcase lang-string) "-mode")))
(setq mode (intern mode))
(when (fboundp mode)
(push (list lang mode) markdown-ts-code-block-modes)
(throw :mode mode)))))))))