此post建议Web模式处理JS模板文字。但是包含.emacs
的
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(require 'web-mode)
(eval-after-load "web-mode"
'(progn
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
(setq web-mode-script-padding 4)
(setq web-mode-style-padding 4)
(setq web-mode-markup-indent-offset 4)
(setq web-mode-markup-indent-offset 4)
))
当我显示代码时
<!DOCTYPE html>
<body>
<script>
function g(t) {
const n = 2, d = 3, w = 4, z = 5;
return `${d === 0 ? `X${w * z},0`
: d === n ? `Y${(w + 1) * z},0`
: `Z${(w + 1) * z},0W${d * z}L${w * z}`}M${n * z}`;
}
</script>
</body>
我得到了不正确的字体锁定: