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

Re: Emacs refuses to default to using nXML mode on HTML files

Expand Messages
  • jjramsey_6x9eq42
    ... the ... I just added this to my /~.emacs: ;; Avoid determining the mode by contents of file. ;; Emacs is too smart for its own good. (setq magic-mode-alist
    Message 1 of 10 , Jan 1, 2005
      --- In emacs-nxml-mode@yahoogroups.com, drkm <darkman_spam@y...>
      wrote:
      > David Abrahams <dave@b...> writes:
      >
      > > James J. Ramsey wrote:
      >
      > >> I already have this line in ~/.emacs:
      >
      > >> (setq auto-mode-alist (cons '("\\.html\\'" .
      > >> nxml-mode) auto-mode-alist))
      >
      > >> Somehow it's being overridden, and I don't know why.
      > >> When I start up Emacs and load an XHTML file,
      > >> sgml-mode gets applied to the file by default.
      > >> Autoloading nxml-mode doesn't help. (It's already
      > >> autoloaded by rng-auto.el, anyway.) If I type "M-x
      > >> nxml-mode", I can get nxml-mode to be applied to the
      > >> file; Emacs just won't do it by default.
      >
      > >> Any idea what's going on?
      >
      > > I had a similar problem recently.
      >
      > And your Emacsen are more recently than 2004-11-03. Right ?
      >
      > 2004-11-03 Daniel Pfeiffer <occitan@e...>
      >
      > * files.el (xml-based-modes): Delete var.
      > (magic-mode-alist): New more general var.
      > (set-auto-mode): Use it.
      >
      > `magic-mode-alist' is used before `auto-mode-alist' to look for a
      > regexp in the buffer to decide the mode to be used. Exactly like
      the
      > code Vincent proposed :
      >
      > (add-hook 'hack-local-variables-hook
      > (lambda ()
      > (save-excursion
      > (when (search-forward-regexp "^<\\?xml" 6 0)
      > (nxml-mode)
      > ))))
      >
      > becoming :
      >
      > (push '("\\`<\\?xml" . nxml-mode) magic-mode-alist)

      I just added this to my /~.emacs:

      ;; Avoid determining the mode by contents of file.
      ;; Emacs is too smart for its own good.
      (setq magic-mode-alist nil)

      A blunt solution, but it works.
    • drkm
      ... ~/.emacs :-) ... Yes. But: - it removes all entries from `magic-mode-alist , not only those regarding `html-mode , `sgml-mode and `xml-mode . After
      Message 2 of 10 , Jan 2, 2005
        "jjramsey_6x9eq42" <jjramsey_6x9eq42@...> writes:

        > I just added this to my /~.emacs:

        ~/.emacs :-)

        > ;; Avoid determining the mode by contents of file.
        > ;; Emacs is too smart for its own good.
        > (setq magic-mode-alist nil)

        > A blunt solution, but it works.

        Yes. But:

        - it removes all entries from `magic-mode-alist', not only those
        regarding `html-mode', `sgml-mode' and `xml-mode'. After
        removing these entries, the value remains :

        (("%![^V]" . ps-mode)
        ("# xmcd " . conf-unix-mode))

        - it doesn't benefit from this variable. In my configuration, I
        have :

        (push '("<\\?xml" . nxml-mode) magic-mode-alist)

        to launch nXML for files beginning by "<?xml".

        Note I wrote "<\\?xml", and not "\\`<\\?xml", as I wrote in my
        previous message. The match from `magic-mode-alist' is anchored at
        the beginning of the buffer, but it's not documented.

        --drkm
      • jjramsey_6x9eq42
        ... I know. That s why it s a blunt solution.
        Message 3 of 10 , Jan 2, 2005
          --- In emacs-nxml-mode@yahoogroups.com, drkm <darkman_spam@y...> wrote:
          > "jjramsey_6x9eq42" <jjramsey_6x9eq42@y...> writes:
          >
          > > I just added this to my /~.emacs:
          >
          > ~/.emacs :-)
          >
          > > ;; Avoid determining the mode by contents of file.
          > > ;; Emacs is too smart for its own good.
          > > (setq magic-mode-alist nil)
          >
          > > A blunt solution, but it works.
          >
          > Yes. But:
          >
          > - it removes all entries from `magic-mode-alist', not only those
          > regarding `html-mode', `sgml-mode' and `xml-mode'.

          I know. That's why it's a blunt solution.
        Your message has been successfully submitted and would be delivered to recipients shortly.