[英]emacs: Does HideShow work with xml-mode (sgml-mode)?
I use hideshow.el in my cc-mode buffers to collapse sections of the file I'm not looking at. 我在我的cc模式缓冲区中使用hideshow.el来折叠我不看的文件的部分。
It would be nice to be able to do that in an XML doc. 能够在XML文档中执行此操作会很高兴。 I use emacs 22.2.1 and the built-in sgml-mode for xml editing.
我使用emacs 22.2.1和内置的sgml-mode进行xml编辑。 I haven't gotten hideshow to work with the XML.
我还没有使用hideshow来处理XML。 I mean, I turn on the minor mode but the keystrokes have no effect.
我的意思是,我打开次要模式但按键没有效果。 Ooh, except, I did get an XML comment to collapse.
哦,除了我确实得到了一个XML评论崩溃。 But no elements.
但没有元素。
Has anyone done this successfully? 有人做过这个吗?
Recommendations? 建议?
EDIT : I'll bet it would work if I added an sgml-mode element to hs-special-modes-alist. 编辑 :我敢打赌,如果我将一个sgml-mode元素添加到hs-special-modes-alist中,它会起作用。 I'd need a regexp for start-block.
我需要一个用于start-block的正则表达式。 Has anyone done this?
有没有人这样做过?
I haven't moved to nxml-mode. 我没有转移到nxml模式。 Should I?
我是不是该? does it do "folding" or hiding?
它会“折叠”还是隐藏?
Answering my own question... I am using something like this. 回答我自己的问题......我正在使用这样的东西。 Seems to work.
似乎工作。
;; Fix XML folding
(add-to-list 'hs-special-modes-alist
(list 'nxml-mode
"<!--\\|<[^/>]*[^/]>"
"-->\\|</[^/>]*[^/]>"
"<!--"
'nxml-forward-element
nil))
;; Fix HTML folding
(dolist (mode '(sgml-mode
html-mode
html-erb-mode))
(add-to-list 'hs-special-modes-alist
(list mode
"<!--\\|<[^/>]*[^/]>"
"-->\\|</[^/>]*[^/]>"
"<!--"
'sgml-skip-tag-forward
nil)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.