Wont load automatically for .xhtml files.

Bug #382082 reported by Alexandros Prekates on 2009-05-31
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

In emacs 22.2 when i open a .xhtml file nxml mode will load. Giving
C-h v auto-mode-alist i see that there is a pair for nxhtml but below nxml.
Since i installed nxhtml mode last shouldnt be the other way around?

lborgman (lennart-borgman) wrote :

Hi Alexandros,

There is a tool for taking care of this situation in nXhtml. You can find it in the nXhtml menu:

   nXhtml - Tools - Major Mode Pripriorities

I think you can not depend on the order things have in your .emacs since for example most of nXhtml is autoloaded.

Changed in nxhtml:
importance: Undecided → Medium
status: New → Fix Released
Alexandros Prekates (aprekates) wrote :

I dont understand the raelationship between Majmodpri Mode Priorities and the
auto-mode-alist. What should i change to make a .xhtml file open in nxhtml mode?

Also in Majmodpri Mode Priorities i added at top the the nxhtml-mode
but after restarting emacs a .xhtml file still opens in nxml mode,

Alexandros Prekates (aprekates) wrote :

I made it work with adding in my ,emacs

(setq auto-mode-alist
               ;; File name ends in `.xhtml'.
               '(("\\.xhtml\\'" . nxhtml-mode))

lborgman (lennart-borgman) wrote :

Yes, that is one way to do it, but it will still depend on which packages you have loaded. For a personal solution it may of course be very good.

Lucas Gonze (lucas-gonze) wrote :

Hi lborgman, I see the customization buffer for group Majmodpri, but can't figure it which option you're referring to here. What would one set to have nxhtml-mode be used instead of html-helper?

lborgman (lennart-borgman) wrote :

Hi Lucas,

I am not sure, but I guess the problem is that html-helper somewhere changes the variables that affects which major mode Emacs chooses. You can check this by running "Apply Major Modes Priorities" from the menu.

If that fixes the problem then the variable to customize is majmodpri-sort-after-load.

Otherwise I do not know what to do so I hope it works ... ;-)

Lucas Gonze (lucas-gonze) wrote :
Download full text (8.7 KiB)

"Apply Major Modes Priorities" has no effect. Customizing majmodpri-sort-after-load has no effect.

C-h v auto-mode-alist shows that html-helper is below nxhtml-mode. Here's the complete dump:
(("\\.dz\\'" nil jka-compr)
 ("\\.g?z\\(~\\|\\.~[0-9]+~\\)?\\'" nil jka-compr)
 ("\\.bz2\\(~\\|\\.~[0-9]+~\\)?\\'" nil jka-compr)
 ("\\.Z\\(~\\|\\.~[0-9]+~\\)?\\'" nil jka-compr)
 ("\\.~?[0-9]+\\.[0-9][-.0-9]*~?\\'" nil t)
 ("\\.\\(?:orig\\|in\\|[bB][aA][kK]\\)\\'" nil t)
 ("\\.djhtml\\'" . django-html-mumamo-mode)
 ("\\.epl\\'" . embperl-html-mumamo-mode)
 ("\\.rhtml\\'" . eruby-html-mumamo-mode)
 ("\\.erb\\'" . eruby-html-mumamo-mode)
 ("\\.ghtml\\'" . genshi-html-mumamo-mode)
 ("\\.jsp\\'" . jsp-html-mumamo-mode)
 ("\\.lzx\\'" . laszlo-nxml-mumamo-mode)
 ("\\.phps\\'" . smarty-html-mumamo-mode)
 ("\\.s?html?\\(\\.[a-zA-Z_]+\\)?\\'" . html-mumamo-mode)
 ("\\.htm\\'" . html-mumamo-mode)
 ("\\.html\\'" . html-mumamo-mode)
 ("\\.xhtm\\'" . html-mumamo-mode)
 ("\\.xhtml\\'" . html-mumamo-mode)
 ("\\.htmlf\\'" . html-mumamo-mode)
 ("\\.xhtmlf\\'" . html-mumamo-mode)
 ("\\.php\\'" . html-mumamo-mode)
 ("\\.phtml\\'" . html-mumamo-mode)
 ("\\.x[ms]l\\'" . nxml-mode)
 ("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)" . nxml-mode)
 ("\\.js\\'" . javascript-mode)
 ("\\.js$" . javascript-mode)
 ("\\.html\\'" . nxhtml-mode)
 ("\\.xhtml\\'" . nxhtml-mode)
 ("\\.rnc\\'" . rnc-mode)
 ("\\.asp\\'" . asp-html-mumamo-mode)
 ("\\.ghtml\\'" . genshi-nxhtml-mumamo-mode)
 ("\\.epl\\'" . embperl-nxhtml-mumamo-mode)
 ("\\.phps\\'" . smarty-nxhtml-mumamo-mode)
 ("\\.erb\\'" . eruby-nxhtml-mumamo-mode)
 ("\\.rhtml\\'" . eruby-nxhtml-mumamo-mode)
 ("\\.djhtml\\'" . django-nxhtml-mumamo-mode)
 ("\\.asp\\'" . asp-nxhtml-mumamo-mode)
 ("\\.jsp\\'" . jsp-nxhtml-mumamo-mode)
 ("\\.phtml\\'" . nxhtml-mumamo-mode)
 ("\\.php\\'" . nxhtml-mumamo-mode)
 ("\\.xhtmlf\\'" . nxhtml-mumamo-mode)
 ("\\.htmlf\\'" . nxhtml-mumamo-mode)
 ("\\.xhtml\\'" . nxhtml-mumamo-mode)
 ("\\.xhtm\\'" . nxhtml-mumamo-mode)
 ("\\.html\\'" . nxhtml-mumamo-mode)
 ("\\.htm\\'" . nxhtml-mumamo-mode)
 ("\\.s?html?\\(\\.[a-zA-Z_]+\\)?\\'" . nxhtml-mumamo-mode)
 ("\\.s?html?\\(\\.[a-zA-Z_]+\\)?\\'" . nxhtml-mode)
 ("\\.sass$" . sass-mode)
 ("\\.cp\\'" . c++-mode)
 ("\\.\\([pP]\\([Llm]\\|erl\\|od\\)\\|al\\)\\'" . cperl-mode)
 ("\\.m$" . matlab-mode)
 ("\\.rb$" . ruby-mode)
 ("\\.php$" . php-mode)
 ("\\.applescript$" . applescript-mode)
 ("\\.css$" . css-mode)
 ("\\.shtml$" . html-helper-mode)
 ("\\.html$" . html-helper-mode)
 ("\\.sp\\'" . S-mode)
 ("\\.[qsS]\\'" . S-mode)
 ("\\.ssc\\'" . S-mode)
 ("\\.[rR]\\'" . R-mode)
 ("\\.[rR]nw\\'" . Rnw-mode)
 ("\\.[rR]profile\\'" . R-mode)
 ("NAMESPACE\\'" . R-mode)
 ("\\.omg\\'" . omegahat-mode)
 ("\\.hat\\'" . omegahat-mode)
 ("\\.lsp\\'" . XLS-mode)
 ("\\.do\\'" . STA-mode)
 ("\\.ado\\'" . STA-mode)
 ("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
 ("\\.[Ss]t\\'" . S-transcript-mode)
 ("\\.[Ss]out" . S-transcript-mode)
 ("\\.[Rr]t\\'" . R-transcript-mode)
 ("\\.[Rr]out" . R-transcript-mode)
 ("\\.drv\\'" . latex-mode)
 ("\\.vr[hi]?\\'" . vera-mode)
 ("\\.py\\'" . python-mode)
 ("\\.mixal\\'" . mixal-mode)
 ("\\.x[bdsru]?[cn]?\\'" . ld-script-mode)
 ("\\.ld[si]?\\>" . ld-script-mode)


Lucas Gonze (lucas-gonze) wrote :

I'll rephrase that as a question which is easy to answer.

Does the debug info I posted in the previous comment confirm or refute your hypothesis that html-helper somewhere changes the variables that affects which major mode Emacs chooses?

Lucas Gonze (lucas-gonze) wrote :

All right then. The lack of response explains why nxhtml is so half baked.

lborgman (lennart-borgman) wrote :

Lucas, you are right. I am short of time. You are welcome to work on it if you want to.

lborgman (lennart-borgman) wrote :

Lucas, after reading your report again all I can say is that it should work. A file with extension ".html" should be opened in html-mumamo-mode. (There is no nXhtml mode.)

Is that what you want, or?

lborgman (lennart-borgman) wrote :

Hi Lucas,

Looking at the note on http://www.emacswiki.org/emacs/HtmlHelperMode about magic-mode-alist I wonder if there is any problem with this in your case since it looks like you are still using Emacs 22.

This should be taken care of by "Major Modes Priorities" but there may be a bug there.

Could please post your magic-mode-alist?

Lucas Gonze (lucas-gonze) wrote :

(("\\(?:.\\|\n\\)\\{,200\\}xmlns:py=\"http://genshi.edgewall.org/\"" . genshi-html-mumamo-mode)
 ("<\\?xml " . nxml-mode)
 ("\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->\\s *<\\)*\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->\\s *<\\)*\\)?[Hh][Tt][Mm][Ll]" . html-helper-mode)
 ("\\(?:.\\|\n\\)\\{,200\\}xmlns:py=\"http://genshi.edgewall.org/\"" . genshi-nxhtml-mumamo-mode))

This version of Emacs is Aquamacs, which is based on Emacs 22. There is an early release of an Aquamacs based on Emacs 23. I'll give it a shot and see what difference it makes.

Lucas Gonze (lucas-gonze) wrote :

I tested against the Emacs 23-based version of Aquamacs and the problem was there.

lborgman (lennart-borgman) wrote :

Hi Lucas,

Ah, there it is! html-helper-mode adds itself to magic-mode-alist. And majmodpri.el is not taking care of that.

It is kind of a bug in html-helper-mode that it adds itself to magic-mode-alist. Just loading an elisp library should, according to the rules suggested for elisp libraries, not change how Emacs behaves.

But on the other hand majmodpri.el is written to take care of this kind of bugs so there is indeed a bug in majmodpri.el too. So now I just have to figure out how to fix this...

You can of course work around the problem by changing magic-mode-alist after html-helper-mode has been loaded, but the intention was that you should not have to do that... ;-)

I do not have time to fix it right now and I will have to think about the best way to do it. Suggestions are welcome!

Changed in nxhtml:
status: Fix Released → In Progress
lborgman (lennart-borgman) wrote :

Hi Lucas,

Looking at this a bit further I see that there is no bug in html-helper-mode since it does not add itself to magic-mode-alist. Sorry for my misunderstanding.

Are you yourself adding it or is it something in the Emacs you are installing?

I can see there are some old misunderstandings so maybe it comes from this:


I will mail Romain Francoise.

I am also closing this bug, since it does not seem to be a problem with nXhtml.

Changed in nxhtml:
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.