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 16:31:52 +0300 Message-ID: References: <87k4lb7rx1.fsf@thinkpad.tsdh.de> 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 1287668003 19668 80.91.229.12 (21 Oct 2010 13:33:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 21 Oct 2010 13:33:23 +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 15:33:21 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 1P8vGi-0004Q8-7d for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Oct 2010 15:33:20 +0200 Original-Received: from localhost ([127.0.0.1]:60590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8vGh-0006bp-Bi for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Oct 2010 09:33:19 -0400 Original-Received: from [140.186.70.92] (port=46225 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8vFW-0006P6-Dw for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 09:32:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8vFV-0008Fh-5G for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 09:32:06 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:47902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8vFU-0008FR-Vl for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 09:32:05 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P8vFO-0003sA-1K for help-gnu-emacs@gnu.org; Thu, 21 Oct 2010 15:31:58 +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 15:31:58 +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 15:31:58 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 32 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:75188 Archived-At: On 21.10.2010 15:56, Andrea Crotti wrote: > Oleksandr Gavenko writes: > >>> 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 "\\_" 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 don't get your point... > What's that useful for exactly? > Suppose header firstly have a lot of '#define', so 'class' keyword far from 'magic-mode-alist'. And .h file was opened in c-mode. I look ALT/MFS headers (not all). Usually 'class' matches near offset in 900 bytes.