From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: distinguish .h files Date: Thu, 21 Oct 2010 12:23:31 +0300 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1287655054 14863 80.91.229.12 (21 Oct 2010 09:57:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 21 Oct 2010 09:57:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 21 11:57:32 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P8rtr-0007VO-St for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Oct 2010 11:57:32 +0200 Original-Received: from localhost ([127.0.0.1]:57589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8rOP-0006yE-9X for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Oct 2010 05:25:01 -0400 Original-Received: from [140.186.70.92] (port=43531 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8rNE-0006vD-Hq for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 05:23:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8rN8-0000Zj-R1 for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 05:23:43 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:38881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8rN8-0000ZY-KH for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 05:23:42 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P8rN3-0004Q2-OF for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 11:23:37 +0200 Original-Received: from 91.193.68.214 ([91.193.68.214]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 21 Oct 2010 11:23:37 +0200 Original-Received: from gavenko by 91.193.68.214 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 21 Oct 2010 11:23:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 30 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 91.193.68.214 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101013 Thunderbird/3.1.5 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75181 Archived-At: On 20.10.2010 18:48, Lennart Borgman wrote: > On Wed, Oct 20, 2010 at 5:37 PM, Andrea Crotti >> >> It's a bit annoying that the header files .h BUT for c++ are not >> automatically recognized (but of course understandable). >> >> I tried the following approach but it doesn't work, maybe the function >> is executed too early? >> Or what else can be the problem? >> >> --8<---------------cut here---------------start------------->8--- >> (defun is-cpp-header-file () >> "enable c++-mode when finding classes" >> (when (re-search-forward "class ") >> (c++-mode))) >> >> ;;(add-hook 'c-mode-common-hook 'is-cpp-header-file) >> --8<---------------cut here---------------end--------------->8--- > > 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?