emacs是否为html模式提供隐藏显示

emacs是否为html模式提供隐藏显示,html,emacs,elisp,Html,Emacs,Elisp,emacs是否具有html的隐藏显示代码折叠功能?我在使用org模式时有它,但似乎在nXML/html端找不到它。我为mhtml模式编写了这篇文章,它工作得非常好,它可以按标签折叠html以及嵌入的CSS和JS。只需将它添加到emacs配置文件中,您就可以开始了 ;; When called this automatically detects the submode at the current location. ;; It will then either forward to end o

emacs是否具有html的隐藏显示代码折叠功能?我在使用org模式时有它,但似乎在nXML/html端找不到它。

我为mhtml模式编写了这篇文章,它工作得非常好,它可以按标签折叠html以及嵌入的CSS和JS。只需将它添加到emacs配置文件中,您就可以开始了

;; When called this automatically detects the submode at the current location.
;; It will then either forward to end of tag(HTML) or end of code block(JS/CSS).
;; This will be passed to hs-minor-mode to properly navigate and fold the code.
(defun mhtml-forward (arg)
  (interactive "P")
  (pcase (get-text-property (point) `mhtml-submode)
    (`nil (sgml-skip-tag-forward 1))
    (submode (forward-sexp))))

;; Adds the tag and curly-brace detection to hs-minor-mode for mhtml.
(add-to-list 'hs-special-modes-alist
             '(mhtml-mode
               "{\\|<[^/>]*?"
               "}\\|</[^/>]*[^/]>"
               "<!--"
               mhtml-forward
               nil))
;;调用此选项时,将自动检测当前位置的子模式。
;; 然后,它将转发到标记结尾(HTML)或代码块结尾(JS/CSS)。
;; 这将被传递到hs次要模式,以正确导航和折叠代码。
(解除mhtml前进(arg)
(交互式“P”)
(pcase(获取文本属性(点)`mhtml子模式)
(`nil(sgml跳过前向标记1))
(子模式(正向sexp)))
;; 将标记和花括号检测添加到mhtml的hs次要模式。
(添加到列表“hs特殊模式列表”
'(mhtml模式
"{\\|]*?"
"}\\|]*[^/]>"

“如果你在做html,我强烈建议你使用web模式,而不是内置html模式,内置html模式中有代码折叠功能。hideshow库还有hs特殊模式列表,可以通过定义开始和结束的自定义函数添加到列表中,例如,使用regexp。