Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable html-helper-mode by default in Aquamacs to edit HTML

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.

like image 497
Mad Echet Avatar asked Dec 25 '12 17:12

Mad Echet


2 Answers

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.

like image 90
Mad Echet Avatar answered Oct 30 '22 06:10

Mad Echet


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)
like image 38
zck Avatar answered Oct 30 '22 04:10

zck