From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrea Crotti Newsgroups: gmane.emacs.help Subject: Re: c-style-alist Date: Sat, 25 Sep 2010 13:54:57 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1285415758 19977 80.91.229.12 (25 Sep 2010 11:55:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 25 Sep 2010 11:55:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 25 13:55:57 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 1OzTMD-0006G7-3P for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Sep 2010 13:55:57 +0200 Original-Received: from localhost ([127.0.0.1]:39820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OzTMC-0006S3-Km for geh-help-gnu-emacs@m.gmane.org; Sat, 25 Sep 2010 07:55:56 -0400 Original-Received: from [140.186.70.92] (port=45529 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OzTLb-0006O3-Jq for help-gnu-emacs@gnu.org; Sat, 25 Sep 2010 07:55:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OzTLW-0001db-Dr for help-gnu-emacs@gnu.org; Sat, 25 Sep 2010 07:55:19 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:59786) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OzTLW-0001dL-4P for help-gnu-emacs@gnu.org; Sat, 25 Sep 2010 07:55:14 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OzTLP-0005ye-Oj for help-gnu-emacs@gnu.org; Sat, 25 Sep 2010 13:55:07 +0200 Original-Received: from p508a2e2a.dip.t-dialin.net ([80.138.46.42]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 25 Sep 2010 13:55:07 +0200 Original-Received: from andrea.crotti.0 by p508a2e2a.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 25 Sep 2010 13:55:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: p508a2e2a.dip.t-dialin.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:8uza3+qOGM9qgS+HrD/+sZatG+s= 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:75007 Archived-At: Andrea Crotti writes: > Supposing I have a new language (actually NED), and I already have some > syntax highlighting. > > The only thing I want to add is a smarter indentation, and for that is > quite similar to C++. > > Looking for possible answers I found out that in > c-style-alist there is also for example python-mode, which is not a > c-mode derivatives. > > Is that is the general way to define the correct the policy of spacing? > And what if I define it as a derived mode even if it's quite different > from the original c/c++ branch? I solved making that mode a derived-mode from cc-mode. Then I created another derived-mode for c++ files used by omnetpp, but I'm struggling to make it automatically enabled. It's very very simple --8<---------------cut here---------------start------------->8--- (require 'derived) (define-derived-mode cpp-omnet-mode c++-mode "C++ Omnet mode" "Major mode for editing c++ files used with omnet++" ) (provide 'cpp-omnet-mode) --8<---------------cut here---------------end--------------->8--- and I thought I could do simply something like --8<---------------cut here---------------start------------->8--- ;; Look for the file .ini or the header inclusion (defun is-omnet-cpp-file () (if (or (file-exists-p "omnetpp.ini") (search-forward "")) (cpp-omnet-mode))) ;FIXME: Not working correctly yet, because it goes in infinite loop ;; (add-hook 'c++-mode-hook 'is-omnet-cpp-file) --8<---------------cut here---------------end--------------->8--- But it's not fine, since it will evaluate infinitely this hook. Another possibility would be to use "find-file-hook", but it doesn't really make sense because the files possible are a subset of c++ files. How can I make it non recurse keeping this? Or some other suggestions?