help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: distinguish .h files


From: Oleksandr Gavenko
Subject: Re: distinguish .h files
Date: Thu, 21 Oct 2010 15:56:30 +0300
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101013 Thunderbird/3.1.5

On 21.10.2010 15:53, Oleksandr Gavenko wrote:
On 21.10.2010 13:37, Tassilo Horn wrote:
Oleksandr Gavenko<address@hidden> 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---

I use your code to get this value (add this after 'string-match'):

(message "%s" (- (point-max) (point-min)))

I get 4000.

I get doc buffer for 'magic-mode-alist', go to source where this var defined
and search for keyword 'limit':

(defvar magic-mode-regexp-match-limit 4000
  "Upper limit on `magic-mode-alist' regexp matches.
Also applies to `magic-fallback-mode-alist'.")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]