From: Oleksandr Gavenko <gavenko@bifit.com.ua>
To: help-gnu-emacs@gnu.org
Subject: Re: distinguish .h files
Date: Thu, 21 Oct 2010 15:56:30 +0300 [thread overview]
Message-ID: <i9pd9n$5nk$2@dough.gmane.org> (raw)
In-Reply-To: <i9pd3v$5nk$1@dough.gmane.org>
On 21.10.2010 15:53, Oleksandr Gavenko wrote:
> On 21.10.2010 13:37, Tassilo Horn wrote:
>> 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---
>>
> 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'.")
next prev parent reply other threads:[~2010-10-21 12:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 15:37 distinguish .h files Andrea Crotti
2010-10-20 15:48 ` Lennart Borgman
2010-10-21 9:23 ` Oleksandr Gavenko
2010-10-21 10:37 ` Tassilo Horn
2010-10-21 10:43 ` Tassilo Horn
2010-10-21 11:04 ` Andrea Crotti
2010-10-21 12:53 ` Oleksandr Gavenko
2010-10-21 12:56 ` Oleksandr Gavenko [this message]
2010-10-21 12:56 ` Andrea Crotti
2010-10-21 13:31 ` Oleksandr Gavenko
2010-10-21 13:42 ` Andrea Crotti
[not found] ` <mailman.1.1287669068.3931.help-gnu-emacs@gnu.org>
2010-10-21 13:58 ` Pascal J. Bourguignon
2010-10-21 13:46 ` Tassilo Horn
2010-10-21 14:47 ` Andrea Crotti
2010-10-21 15:21 ` Tassilo Horn
[not found] ` <mailman.0.1287653038.19033.help-gnu-emacs@gnu.org>
2010-10-21 10:15 ` Pascal J. Bourguignon
[not found] <mailman.0.1287589050.20659.help-gnu-emacs@gnu.org>
2010-10-20 15:55 ` Richard Riley
2010-10-20 16:46 ` Juhapekka Tolvanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='i9pd9n$5nk$2@dough.gmane.org' \
--to=gavenko@bifit.com.ua \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.