I got a situation here, that I couldn't get resolved with the maintainer of
web-mode. So I'm asking here, if anyone knows a good suggestion.
Ok, what I have here: GNU Emacs GUI (version 18.104.22.168 (x86_64-w64-mingw32) compiled from Harroogan Emacs.) Packages web-mode and header2.el. If you need more detail about header2, see right answer here on StackExchange. It's a great package, I really recommend it.
header2.el lets you define file headers for different types of file (C, shell, EmacsLisp, and so on). You can automatically insert a header when you open a new file buffer.
I ran into crashes, when I use web-mode in combination with header2.el. This is tested with an empty Emacs configuration (
When I use header2.el in combination with PHP-mode, JS-mode, and HTML-mode, I don't run into crashes and everything works fine.
First, you need to configure your emacs.d, in order to get the packages.
(setq user-emacs-directory "C:/Dropbox/Emacs/.emacs.d/") (add-to-list 'load-path "C:\\Dropbox\\Emacs\\.emacs.d\\")
Then do load the packages Web-mode and header2.
(require 'header2) (require 'web-mode)
Then you need to configure the header, and set it up to be automatic created when create a new file:
(setq php-tag "<?php \n \n") (setq html-close-tag " --> \n") (defsubst my/header-title () (insert (if (eq major-mode 'php-mode) php-tag " \n") (concat comment-start " File " (buffer-name)) (if (eq major-mode 'web-mode) html-close-tag " \n") "\n")) (setq make-header-hook '(my/header-title)) (autoload 'auto-update-file-header "header2") (add-hook 'write-file-hooks 'auto-update-file-header) (autoload 'auto-make-header "header2") (add-hook 'html-mode-hook 'auto-make-header) (add-hook 'web-mode-hook 'auto-make-header) (add-hook 'php-mode-hook 'auto-make-header) (add-hook 'js-mde-hook 'auto-make-header)
I create in Emacs a new file, called
foobar.php. I get the header automatically inserted for me. And I can type around and press
RET. Everything works fine. Same for
Then I add
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode)) to my setup. This means that when I open a HTML file, Web-mode will be enabled as a major mode.
I restart Emacs. Then I create a new file, called
.html-filetype is hooked on web-mode. When typing some characters and press
RET, this causes Emacs to freeze. Nothing is appearing in the
*Messages*-buffer. This will not happen, when I don't add the
.html extension to the
Web-mode on auto-mode-alist, and get
Notice that autoheader is not a minor mode. It's a action hook, that insert the text when you enter a major mode. So I'm puzzled why it lets unrecoverrable crashing Emacs. It's a fairly simple package, after all.
Any suggestion would be appreciated.