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

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

Expand Messages
  • jjramsey_6x9eq42
    Jan 1, 2005
    • 0 Attachment
      --- 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.
    • Show all 10 messages in this topic