views:

291

answers:

2

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?

+2  A: 

Answering my own question... I am using something like this. Seems to work.

(add-to-list 'hs-special-modes-alist
             '(sgml-mode
               "<!--\\|<[^/>]*[^/]>"                    ;; regexp for start block
               "-->\\|</[^/>]*[^/]>"                    ;; regexp for end block

               "<!--"                                   ;; regexp for comment start. (need this??)
               sgml-skip-tag-forward
               nil))
Cheeso
A: 

nxml-mode is much faster than other xml editing modes. I use it for many years and very happy with it

Alex Ott