900Re: Emacs refuses to default to using nXML mode on HTML files
- Jan 1, 2005--- In firstname.lastname@example.org, drkm <darkman_spam@y...>
> David Abrahams <dave@b...> writes:the
> > 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
> code Vincent proposed :I just added this to my /~.emacs:
> (add-hook 'hack-local-variables-hook
> (lambda ()
> (when (search-forward-regexp "^<\\?xml" 6 0)
> becoming :
> (push '("\\`<\\?xml" . nxml-mode) magic-mode-alist)
;; 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.
- << Previous post in topic Next post in topic >>