I use hideshow.el in my cc-mode buffers to collapse sections of the file I'm not looking at.
It would be nice to be able to do that in an XML doc. I use emacs 22.2.1 and the built-in sgml-mode for xml editing. I haven't gotten hideshow to work with the 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. 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. I'd need a regexp for start-block. Has anyone done this?
I haven't moved to nxml-mode. 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)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With