[Top][All Lists]

[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:53:26 +0300
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20101013 Thunderbird/3.1.5

On 21.10.2010 13:37, Tassilo Horn wrote:
Oleksandr Gavenko<>  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)
         (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.

reply via email to

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