Loading ...
Sorry, an error occurred while loading the content.

Disabling nxml-mode

Expand Messages
  • Peter Flynn
    I just upgraded a machine to Ubuntu Natty, which installed Emacs 23.2, which appears to open XML files in nxml-mode by default. My .emacs file says ... which
    Message 1 of 14 , May 7 3:27 PM
    • 0 Attachment
      I just upgraded a machine to Ubuntu Natty, which installed Emacs 23.2,
      which appears to open XML files in nxml-mode by default. My .emacs file says

      > (autoload 'xml-mode "psgml" "Major mode to edit XML files." t )
      > (setq auto-mode-alist (cons '("\\.[XxRrMmDdTt][TtMmDdSsNnEe][PpAaMmLlFfSsIi]?[EePp]*[Cc]*$" . xml-mode) auto-mode-alist))

      which has been working fine for years. It looks as if Emacs 23.2 defines
      xml-mode to point to nxml-mode, and this is somehow superseding my .emacs.

      Unfortunately I still need to use psgml's xml-mode for all my XML stuff.
      How do I disable Emacs' new behaviour?

      ///Peter
    • Jason Rumney
      ... Replace the autoload line in your .emacs with: (require nxml-mode) (require psgml) This will ensure that psgml overrides nxml s definition of xml-mode.
      Message 2 of 14 , May 7 9:35 PM
      • 0 Attachment
        Peter Flynn <peter@...> writes:

        > I just upgraded a machine to Ubuntu Natty, which installed Emacs 23.2,
        > which appears to open XML files in nxml-mode by default. My .emacs file says
        >
        >> (autoload 'xml-mode "psgml" "Major mode to edit XML files." t )
        >> (setq auto-mode-alist (cons
        >> ("\\.[XxRrMmDdTt][TtMmDdSsNnEe][PpAaMmLlFfSsIi]?[EePp]*[Cc]*$"
        >> . xml-mode) auto-mode-alist))
        >
        > which has been working fine for years. It looks as if Emacs 23.2 defines
        > xml-mode to point to nxml-mode, and this is somehow superseding my .emacs.
        >
        > Unfortunately I still need to use psgml's xml-mode for all my XML stuff.
        > How do I disable Emacs' new behaviour?

        Replace the autoload line in your .emacs with:

        (require 'nxml-mode)
        (require 'psgml)

        This will ensure that psgml overrides nxml's definition of xml-mode. If
        you leave those files to auto load, then it is always possible that nxml
        loads later, overriding psgml's xml-mode definition, or nxml loads
        first, and psgml never gets loaded because xml-mode is already defined.
      • Dave Pawson
        ... Guessing you want psgml less than nxml-mode, I simply load psgml-mode when needed, manually. Not like James to screw up psgml-mode though. wonder if it s a
        Message 3 of 14 , May 8 12:04 AM
        • 0 Attachment
          On 8 May 2011 05:35, Jason Rumney <jasonr@...> wrote:
          > Peter Flynn <peter@...> writes:

          > Replace the autoload line in your .emacs with:
          >
          > (require 'nxml-mode)
          > (require 'psgml)
          >
          > This will ensure that psgml overrides nxml's definition of xml-mode.


          Guessing you want psgml less than nxml-mode, I simply
          load psgml-mode when needed, manually.

          Not like James to screw up psgml-mode though. wonder if it's
          a recent change with all this xhtml added recently?

          Seems to work Peter?




          --
          Dave Pawson
          XSLT XSL-FO FAQ.
          Docbook FAQ.
          http://www.dpawson.co.uk
        • Peter Flynn
          ... For me it s the other way around: I need psgml for everything, and I haven t yet found a use for nxml. If I need nxml I can load it manually; for my work
          Message 4 of 14 , May 8 3:10 AM
          • 0 Attachment
            On 08/05/11 08:04, Dave Pawson wrote:
            > On 8 May 2011 05:35, Jason Rumney <jasonr@...> wrote:
            >> Peter Flynn <peter@...> writes:
            >
            >> Replace the autoload line in your .emacs with:
            >>
            >> (require 'nxml-mode)
            >> (require 'psgml)
            >>
            >> This will ensure that psgml overrides nxml's definition of xml-mode.
            >
            >
            > Guessing you want psgml less than nxml-mode, I simply
            > load psgml-mode when needed, manually.

            For me it's the other way around: I need psgml for everything, and I
            haven't yet found a use for nxml. If I need nxml I can load it manually;
            for my work the default needs to be psgml.

            > Not like James to screw up psgml-mode though. wonder if it's
            > a recent change with all this xhtml added recently?

            I don't know, except that I have seen comments that GNU made nxml the
            default in recent releases of Emacs, so It's unlikely to be James's
            fault; more likely the GNU people assumed nxml provided the same
            facilities as psgml, which of course it doesn't, not by a very long way
            (yet, I hope).

            ///Peter
          • Peter Flynn
            On 08/05/11 05:35, Jason Rumney wrote: [...] ... Perfect, many thanks. ///Peter
            Message 5 of 14 , May 8 5:49 AM
            • 0 Attachment
              On 08/05/11 05:35, Jason Rumney wrote:
              [...]
              > Replace the autoload line in your .emacs with:
              >
              > (require 'nxml-mode)
              > (require 'psgml)
              >
              > This will ensure that psgml overrides nxml's definition of xml-mode. If
              > you leave those files to auto load, then it is always possible that nxml
              > loads later, overriding psgml's xml-mode definition, or nxml loads
              > first, and psgml never gets loaded because xml-mode is already defined.

              Perfect, many thanks.

              ///Peter
            • Steinar Bang
              ... They probably made an assumption, but I m guessing that the assumption was that psgml is no longer actively maintained. Of course, neither is nxml-mode,
              Message 6 of 14 , May 8 11:10 AM
              • 0 Attachment
                >>>>> Peter Flynn <peter@...>:

                > I don't know, except that I have seen comments that GNU made nxml the
                > default in recent releases of Emacs, so It's unlikely to be James's
                > fault; more likely the GNU people assumed nxml provided the same
                > facilities as psgml,

                They probably made an assumption, but I'm guessing that the assumption
                was that psgml is no longer actively maintained.

                Of course, neither is nxml-mode, unless someone (Lennart Borgman?) has
                picked up the maintenance in the version of nxml-mode that is now in the
                emacs source?

                > which of course it doesn't, not by a very long way (yet, I hope).

                Out of curiosity: what features in psgml are you missing from nxml mode?
              • Peter Flynn
                ... DTD parsing (I m sure nxml has this, I just haven t seen it at work). C-c C-e element insertion with TAB completion according to the DTD; the population of
                Message 7 of 14 , May 8 11:46 AM
                • 0 Attachment
                  On 08/05/11 19:10, Steinar Bang wrote:
                  >>>>>> Peter Flynn<peter@...>:
                  >
                  >> I don't know, except that I have seen comments that GNU made nxml the
                  >> default in recent releases of Emacs, so It's unlikely to be James's
                  >> fault; more likely the GNU people assumed nxml provided the same
                  >> facilities as psgml,
                  >
                  > They probably made an assumption, but I'm guessing that the assumption
                  > was that psgml is no longer actively maintained.
                  >
                  > Of course, neither is nxml-mode, unless someone (Lennart Borgman?) has
                  > picked up the maintenance in the version of nxml-mode that is now in the
                  > emacs source?
                  >
                  >> which of course it doesn't, not by a very long way (yet, I hope).
                  >
                  > Out of curiosity: what features in psgml are you missing from nxml mode?

                  DTD parsing (I'm sure nxml has this, I just haven't seen it at work).

                  C-c C-e element insertion with TAB completion according to the DTD; the
                  population of such inserted elements which have required element
                  content, and the prompting for required attributes.

                  C-c C-r tag-region, C-c - remove-tag, and C-c = change-tag; C-c C-k
                  cut-element; in fact almost all the markup-management commands, point
                  movement commands, and fold/unfold.

                  The highlighting and indentation (I also use xxml-mode); I have no doubt
                  nxml-mode can do something similar, as the highlighting is just Emacs
                  fontification, and the indentation is a fairly standard requirement.

                  C-c C-q Rewrapping elements: psgml correctly rewraps and indents
                  start-tags in element content to reveal the hierarchy (although it won't
                  add newlines if you have got a start-tag following and end-tag on the
                  same line *in element content*, which is a pity; and it rewraps mixed
                  content to indent under the start-tag of the closest ancestor which is
                  in element content (that is also influenced by xxml-mode).

                  C-c C-a The attribute management panel (split screen)

                  C-c C-w Location-ladder identity

                  SGML conformance (I still have half a dozen clients using SGML).

                  As I said, I'm sure nxml-mode provides some, if not many or even all, of
                  these, but I can't yet find any comprehensive documentation, user
                  conversion guide, or examples of usage. It seems to be aimed at the
                  data-xml user, not the document-xml user: I actually write whole text
                  documents in XML, and I must have a comprehensive set of facilities for
                  doing so (refer to the table of features in my paper at Balisage in
                  2006). I may simply have missed something in nxml-mode, though...

                  ///Peter
                • Dave Pawson
                  ... C-c C-- was my last need for psgml-mode, about a week ago. remove markup around point. sgml-untag-element regards -- Dave Pawson XSLT XSL-FO FAQ. Docbook
                  Message 8 of 14 , May 8 11:26 PM
                  • 0 Attachment
                    On 8 May 2011 19:10, Steinar Bang <sb@...> wrote:

                    > Out of curiosity: what features in psgml are you missing from nxml mode?


                    C-c C-- was my last 'need' for psgml-mode, about a week ago.
                    remove markup around point.
                    sgml-untag-element

                    regards



                    --
                    Dave Pawson
                    XSLT XSL-FO FAQ.
                    Docbook FAQ.
                    http://www.dpawson.co.uk
                  • Dave Pawson
                    ... I don t think it does Peter. ... RTFM? M-q ... RTFM again :-) It s there ... Out of scope for nxml-mode. ... It s there. I even have an html version
                    Message 9 of 14 , May 8 11:30 PM
                    • 0 Attachment
                      On 8 May 2011 19:46, Peter Flynn <peter@...> wrote:

                      > DTD parsing (I'm sure nxml has this, I just haven't seen it at work).

                      I don't think it does Peter.



                      > C-c C-q Rewrapping elements:

                      RTFM? M-q


                      >
                      > C-c C-a The attribute management panel (split screen)

                      RTFM again :-) It's there

                      > SGML conformance (I still have half a dozen clients using SGML).

                      Out of scope for nxml-mode.


                      >
                      > As I said, I'm sure nxml-mode provides some, if not many or even all, of
                      > these, but I can't yet find any comprehensive documentation,

                      It's there. I even have an html version Peter. 5 mins work.
                      I'm as much a dochead as you and love nxml-mode.
                      http://www.dpawson.co.uk/relaxng/nxml/nxml-mode.html

                      Strikes me your users are becoming archaic using sgml?

                      regards

                      --
                      Dave Pawson
                      XSLT XSL-FO FAQ.
                      Docbook FAQ.
                      http://www.dpawson.co.uk
                    • Jason Rumney
                      ... Not directly, but converting DTDs to RelaxNG is very easy. (see http://relaxng.org/#conversion)
                      Message 10 of 14 , May 9 6:48 AM
                      • 0 Attachment
                        Dave Pawson <dave.pawson@...> writes:

                        > On 8 May 2011 19:46, Peter Flynn <peter@...> wrote:
                        >
                        >> DTD parsing (I'm sure nxml has this, I just haven't seen it at work).
                        >
                        > I don't think it does Peter.

                        Not directly, but converting DTDs to RelaxNG is very easy.
                        (see http://relaxng.org/#conversion)
                      • Peter Flynn
                        ... That s a show-stopper for the moment until they all convert to RNG. At the moment there are large banks of entity-dependent code. ... Must do that again.
                        Message 11 of 14 , May 9 1:24 PM
                        • 0 Attachment
                          On 09/05/11 07:30, Dave Pawson wrote:
                          > On 8 May 2011 19:46, Peter Flynn<peter@...> wrote:
                          >
                          >> DTD parsing (I'm sure nxml has this, I just haven't seen it at work).
                          >
                          > I don't think it does Peter.

                          That's a show-stopper for the moment until they all convert to RNG.
                          At the moment there are large banks of entity-dependent code.

                          > RTFM?

                          Must do that again.

                          > Out of scope for nxml-mode.
                          > Strikes me your users are becoming archaic using sgml?

                          "Conservative" is the word I would use :-) They are all planning to
                          convert, but organizational inertia means it's a slow job. They
                          originally picked SGML because it would "last forever" :-)

                          > It's there. I even have an html version Peter. 5 mins work.
                          > I'm as much a dochead as you and love nxml-mode.
                          > http://www.dpawson.co.uk/relaxng/nxml/nxml-mode.html

                          I have no idea how I missed that. I'll have to digest it...very many thanks.

                          > C-c C-- was my last 'need' for psgml-mode, about a week ago.
                          > remove markup around point.
                          > sgml-untag-element

                          That would be a pain. I use it frequently.

                          ///Peter
                        • Steinar Bang
                          ... As others have said: no it doesn t. But creating a RNG schema from a DTD using trang, is really easy. And you can persist the association between your
                          Message 12 of 14 , May 16 9:48 AM
                          • 0 Attachment
                            >>>>> Peter Flynn <peter@...>:

                            > DTD parsing (I'm sure nxml has this, I just haven't seen it at work).

                            As others have said: no it doesn't.
                            But creating a RNG schema from a DTD using trang, is really easy.

                            And you can persist the association between your DOCTYPE declaration and
                            the RNG schema you have created.

                            > C-c C-e element insertion with TAB completion according to the DTD;
                            > the population of such inserted elements which have required element
                            > content, and the prompting for required attributes.

                            nxml did go a different route here. You start typing, and then you
                            press C-RET (Control+RET) to get the stuff that expansion can offer.

                            As an example, here's how to create a DocBook document on a nxml on a
                            debian system (standard setup on debian).

                            Open the file /tmp/silly.xml

                            Select Menu XML->Set Schema->For Document Type->DocBook

                            When prompted, tell it to write this association to schemas.xml (or not,
                            but at least this will give you a look at at schemas file).

                            Then start typing:
                            < C-RET b o o C-RET > C-c C-f

                            (`C-c C-f' is "insert an end-tag for the current tag")

                            Will give you a document that looks like this:
                            <book>
                            </book>

                            If you would like to add some attributes to the top level element, add a
                            space after "book" in the start element (ie. "<book >") and place the
                            cursor on the ">" and press C-RET. This will give you the list of all
                            available attributes.

                            Typing the following with the cursor placed so
                            C-c C-x C-RET r e v SPC f RET C-RET a SPC RET
                            gives
                            <?xml version="1.0" encoding="utf-8"?>
                            <book revisionflag="added">
                            </book>

                            (just to give an example of expansion for an attribute containing an
                            enumeration).

                            Elements are inserted similarily. Put the cursor after the ">" on the
                            first line and press C-j. Then type
                            < C-RET c h SPC RET SPC C-RET i SPC RET f i r s t _ c h a p t e r " > C-c C-f

                            What you have then, is this:

                            <?xml version="1.0" encoding="utf-8"?>
                            <book revisionflag="added">
                            <chapter id="first_chapter">
                            </chapter>
                            </book>

                            The "</" in "</chapter>" is higlighted in red. So select the menu
                            XML->First Error

                            Then the cursor is moved in front of the red "</" and the minibuffer
                            says:
                            Missing element "title"

                            So you type
                            < t SPC RET > C-c C-f C-j
                            and you have

                            <?xml version="1.0" encoding="utf-8"?>
                            <book revisionflag="added">
                            <chapter id="first_chapter">
                            <title></title>
                            </chapter>
                            </book>

                            The "</" in "</chapter>" is still marked red, and First Error
                            unhelpfully says
                            Required child elements missing

                            But I know that this is because a chapter needs to have some sort of
                            content, so I do (with the cursor befor "</chapter>"
                            C-p C-e C-j < C-RET p a SPC RET > b l a h C-c C-f
                            to get:

                            <?xml version="1.0" encoding="utf-8"?>
                            <book revisionflag="added">
                            <chapter id="first_chapter">
                            <title></title>
                            <para>blah</para>
                            </chapter>
                            </book>

                            That's as far as I take this little tutorial. I hope that gave some
                            impression of how it works. Only a few commands: usual SPC and TAB for
                            completion, RET to end minibuffer prompts, and the new commands C-RET,
                            and C-c C-f. But the prompting feels natural and the document is quite
                            quick to write and tag.

                            > C-c C-r tag-region,

                            No. But
                            C-w < C-RET tag-prompt SPC RET C-y C-c C-f
                            should work.

                            > C-c - remove-tag,

                            No.

                            > and C-c = change-tag;

                            No.

                            > C-c C-k cut-element;

                            That one I really missed from psgml, so I created one myself a long time
                            ago. It has been posted to this list, I think...? Maybe in the
                            archieves?

                            > in fact almost all the markup-management commands,

                            Probably not.

                            > point movement commands,

                            If you mean navigate the tree, similar to what you do in outline mode:
                            up tag, down tag, forward tag etc., you have those, with the expected
                            bindings.

                            > and fold/unfold.

                            Those you have.

                            > The highlighting and indentation (I also use xxml-mode); I have no
                            > doubt nxml-mode can do something similar, as the highlighting is just
                            > Emacs fontification, and the indentation is a fairly standard
                            > requirement.

                            Indentation and highlighting you have.

                            > C-c C-q Rewrapping elements: psgml correctly rewraps and indents
                            > start-tags in element content to reveal the hierarchy (although it won't
                            > add newlines if you have got a start-tag following and end-tag on the
                            > same line *in element content*, which is a pity; and it rewraps mixed
                            > content to indent under the start-tag of the closest ancestor which is
                            > in element content (that is also influenced by xxml-mode).

                            Hm... I will add some text and try.

                            If I have
                            <?xml version="1.0" encoding="utf-8"?>
                            <book revisionflag="added">
                            <chapter id="first_chapter">
                            <title></title>
                            <para>blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah</para>
                            </chapter>
                            </book>

                            and do, `M-q' in the <para>, I get:

                            <?xml version="1.0" encoding="utf-8"?>
                            <book revisionflag="added">
                            <chapter id="first_chapter">
                            <title></title>
                            <para>blah blah blah blah blah blah blah blah blah blah blah blah
                            blah blah blah blah blah blah</para>
                            </chapter>
                            </book>

                            acceptable?

                            > C-c C-a The attribute management panel (split screen)

                            No, that one you don't have. But I find the C-RET works quite well, and
                            is actually faster than navigating in the split screen with the
                            attributes.

                            > C-c C-w Location-ladder identity

                            I don't know what that is, so probably not.

                            > SGML conformance (I still have half a dozen clients using SGML).

                            No, this is pure XML. No SGML conformance attempted.

                            > As I said, I'm sure nxml-mode provides some, if not many or even all,
                            > of these, but I can't yet find any comprehensive documentation,

                            My debian nxml has an info manual in emacs, so someone has put together
                            a texinfo file at some point in time.

                            > user conversion guide,

                            No, sorry.

                            > or examples of usage.

                            See the first part of my response. :-)

                            > It seems to be aimed at the data-xml user, not the document-xml user:

                            Quite the opposite. I would say that it is so oriented at expanding
                            tags as you type, that it is far better for typing something like a
                            DocBook file, than a data-xml style format. For the latter, some kind
                            of tree oriented editor would be best.

                            > I actually write whole text documents in XML, and I must have a
                            > comprehensive set of facilities for doing so (refer to the table of
                            > features in my paper at Balisage in 2006). I may simply have missed
                            > something in nxml-mode, though...

                            I haven't looked at that paper and the list there, but FWIW I have felt
                            that nxml-mode have been quite good at creating and editing DITA and
                            DocBook documents.
                          • Steinar Bang
                            ... But there is nothing stopping you from having both psgml and nxml. I use psgml for HTML editing and nxml for all xml format.
                            Message 13 of 14 , May 16 9:57 AM
                            • 0 Attachment
                              >>>>> Steinar Bang <sb@...>:

                              >>>>> Peter Flynn <peter@...>:

                              >> SGML conformance (I still have half a dozen clients using SGML).

                              > No, this is pure XML. No SGML conformance attempted.

                              But there is nothing stopping you from having both psgml and nxml. I
                              use psgml for HTML editing and nxml for all xml format.
                            • Peter Flynn
                              ... Thank you very much for that, it s very useful. ///Peter
                              Message 14 of 14 , May 16 4:51 PM
                              • 0 Attachment
                                On 16/05/11 17:48, Steinar Bang wrote:
                                >>>>>> Peter Flynn<peter@...>:
                                >
                                >> DTD parsing (I'm sure nxml has this, I just haven't seen it at work).
                                >
                                > As others have said: no it doesn't.
                                > But creating a RNG schema from a DTD using trang, is really easy.
                                >
                                > And you can persist the association between your DOCTYPE declaration and
                                > the RNG schema you have created.
                                >
                                >> C-c C-e element insertion with TAB completion according to the DTD;
                                >> the population of such inserted elements which have required element
                                >> content, and the prompting for required attributes.
                                >
                                > nxml did go a different route here. You start typing, and then you
                                > press C-RET (Control+RET) to get the stuff that expansion can offer.
                                >
                                > As an example, here's how to create a DocBook document on a nxml on a
                                > debian system (standard setup on debian).

                                Thank you very much for that, it's very useful.

                                ///Peter
                              Your message has been successfully submitted and would be delivered to recipients shortly.