Emacs: Does HideShow work in xml-mode (sgml-mode)?

I use hideshow.el in my cc-mode buffers to collapse sections of a file that I am not looking at.

It would be nice to be able to do this in an XML document. I am using emacs 22.2.1 and the built-in sgml mode for xml editing. I did not get hideshow for working with XML. I mean, I turn on the secondary mode, but the keystrokes do not work. Oh, besides, I got an XML comment to collapse. But there are no elements.

Has anyone done this successfully?
Recommendations?


EDIT . I am sure this will work if I add the sgml-mode element to hs-special-modes-alist. I will need a regex for the starting block. Has anyone done this?


I did not go into nxml mode. Do I need to? Does it "fold" or hide?

+6
xml emacs
source share
1 answer

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))) 
+8
source share

All Articles