質問

Aquamacs has a default html-helper-modeto edit .html files that has weird behaviors. I would like to switch back to regular html-mode by default.

I read that I needed to change the magic-mode-alist to do so. From what I understand from the documentation, adding this to my .emacs should do the deal:

(setq magic-mode-alist '(("\\.html" . html-mode)))

Unfortunately it does not change anything. I read elsewhere that setting it to nil should work but it did not either.

Any idea what I am missing?

Thanks in advance.

役に立ちましたか?

解決

According the page I linked, the first variable to modify is magic-mode-alist which has precedence on auto-mode-alist.

I just added a value at the beginning of the list of matches using the exact same regular expression that was in magic-mode-alist pointing to html-helper-mode:

(add-to-list 'magic-mode-alist 
    '("\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->\\s *<\\)*\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->\\s *\<\\)*\\)?[Hh][Tt][Mm][Ll]"
        . html-mode))

Works like a charm. Enjoy Aquamacs without whacky html-helper-mode.

他のヒント

magic-mode-alist looks at the contents of the file. You want to edit auto-mode-alist, which looks at filenames. See the same page you linked for a discussion of that variable.

And you don't want to just set it to a value, because it will already have some values in it. Use the function add-to-list, as follows:

(add-to-list 'auto-mode-alist '("\\.html\\'" . html-mode)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top