[Top][All Lists]

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

Re: distinguish .h files

From: Tassilo Horn
Subject: Re: distinguish .h files
Date: Thu, 21 Oct 2010 17:21:01 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

Andrea Crotti <> writes:

Hi Andrea,

>> I guess, that restriction is made for performance reasons.  This one
>> ignores the restriction and will even work if the first class is
>> declared after gigabytes of introductory text:
>> (defun th-c++-header-file-p ()
>>   "Return non-nil, if in a C++ header."
>>   (and (string-match "\\.h$"
>>                   (or (buffer-file-name)
>>                       (buffer-name)))
>>        (save-excursion
>>       (save-restriction
>>         (widen)
>>         (re-search-forward "\\_<class\\_>" nil t)))))
> Yes well but the limit is not so wrong.

No, at least not for ancient computers.

> I mean I prefer to manually (eventually because if I only read I don't
> care so much) switch the mode instead of waiting 10 seconds for
> getting the file open.

I've just tried the worst case I can produce on my computer (core duo
with 2.1 GHz) by opening a 660kb C-header file.  That's worst case
because it's the largest header I could find and because it is plain C
and not C++, so the function above will search the whole buffer.  But
still I cannot perceive any hang or latency...

But the better way is to use the original function definition and
enlarge `magic-mode-regexp-match-limit' to some higher value like 50000
or so...


reply via email to

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