Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Folding tags in emacs nxml-mode

Tags:

The interwebs are full of ancient doctrines for folding code in the Glorious Emacs Editor. Among them are folding.el, outline-minor-mode, and fold-dwim.el. Alas, my poor unenlightened mind cannot write the necessary elisp configuration.

Please help a mortal fold tags in nxml-mode, preferably with TAB. If relevant, I use viper and vimpulse.

like image 851
Natan Yellin Avatar asked Jun 23 '11 09:06

Natan Yellin


3 Answers

Its called outlining in nxml-mode, its in section 5 of the nxml-mode documentation. Which begins ...

5 Outlining


nXML mode allows you to display all or part of a buffer as an outline, in a similar way to Emacs' outline mode. An outline in nXML mode is based on recognizing two kinds of element: sections and headings. There is one heading for every section and one section for every heading. A section contains its heading as or within its first child element. A section also contains its subordinate sections (its subsections). The text content of a section consists of anything in a section that is neither a subsection nor a heading.

https://www.gnu.org/software/emacs/manual/html_mono/nxml-mode.html#Outlining

like image 98
hpavc Avatar answered Nov 03 '22 23:11

hpavc


There finally is an answer at https://emacs.stackexchange.com/questions/2884/the-old-how-to-fold-xml-question, using hideshow.

If and when the emacs.stackexchange gets out of its beta stage, this question might become obsolete.

like image 23
quazgar Avatar answered Nov 03 '22 22:11

quazgar


If you only need to edit unspecified xml, I suggest using web-mode instead of nxml-mode. It supports node folding.

Emacs seems to open .xml files in nxml-mode by default. I guess nxml-mode is useful for working with xml validated against a schema. However, if you just want to edit some un-specified xml with convenient tools, it seems that web-mode may be a better choice.

I found this question searching for a way to do the latter, so I thought I'd share.

like image 38
Shon Avatar answered Nov 03 '22 21:11

Shon