Oleksandr Gavenko<gavenko@bifit.com.ua> writes:
Hi Oleksandr,
Please have a look at
(info "(emacs) Choosing Modes")
Third, Emacs tries to determine the major mode by looking at the
text at the start of the buffer, based on the variable
`magic-mode-alist'. By default, this variable is `nil' (an empty
list), so Emacs skips this step; however, you can customize it in your
init file
How long start of the buffer? Which variable control this behavior?
I don't know exactly,...
--8<---------------cut here---------------start------------->8---
(defun c++-header-file-p ()
"Return non-nil, if in a C++ header."
(and (string-match "\\.h$"
(or (buffer-file-name)
(buffer-name)))
(save-excursion
(re-search-forward "\\_<class\\_>" nil t))))
(add-to-list 'magic-mode-alist
'(c++-header-file-p . c++-mode))
--8<---------------cut here---------------end--------------->8---