From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Laurent Deniau Newsgroups: gmane.emacs.help Subject: extending c-mode Date: Fri, 15 Dec 2006 15:03:28 +0100 Organization: CERN News Message-ID: NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1166193756 8112 80.91.229.10 (15 Dec 2006 14:42:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2006 14:42:36 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 15 15:42:36 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GvEGd-00030a-80 for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Dec 2006 15:42:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GvEGc-0000Bc-RO for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Dec 2006 09:42:30 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!130.59.10.21.MISMATCH!kanaga.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 71 Original-NNTP-Posting-Host: pb-d-128-141-34-206.cern.ch Original-X-Trace: cernne03.cern.ch 1166191416 2093 128.141.34.206 (15 Dec 2006 14:03:36 GMT) Original-X-Complaints-To: news@@cern.ch Original-NNTP-Posting-Date: Fri, 15 Dec 2006 14:03:36 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2 X-Accept-Language: en Original-Xref: shelby.stanford.edu gnu.emacs.help:143960 Original-To: help-gnu-emacs@gnu.org 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:39568 Archived-At: Dear all, I have been through the cc-mode documentation and it seems that what I would like to do is not so obvious, at least for me, while I am sure that there is a simple way to do it with cc-mode. My problem concerns both highlight and indentation extension of the c-mode since my code is pure ISO C99 code and therefore I would like to keep the default highlights and indentation of C. I have the following valid syntax (inspired from Objective-C) which defines a multimethod: **Simple version: defmethod(ret-type, method-name, receiver, argtype) // C code ... endmethod **Advanced version: defmethod(ret-type, (method-name, alt-next-method-name), (receiver1, receiver2), (argtype1)argname1, (argtype2)argname2) // C code... endmethod **Simple uncommon version: defmethod(ret-type, (method-name), (receiver), (argtype)) // C code ... endmethod where - ret-type and argtype are C types or typedef like void, int or int* - method-name, alt-next-method-name, argname1 and argname2 are all user-defined valid C tokens, that is [A-Za-z_][A-Za-z0-9_]* - parentheses around method-name are required only if a alt-next-method-name is specified. - parentheses around receiver are required only if more than one receiver is specified. - parentheses around argtype are required only if an argname is specified. Here are the points: 1) Indentation: I would like defmethod() to behave like { and endmethod like }. 2) Highlight: I would like to color the foreground of each of the following points: - the keywords defmethod and endmethod. - method-name whether alt-next-method-name is present or not taking care of the presence of the enclosing (). - receivers whether there is 1, 2, 3 or 4 receivers taking care of the presence of the enclosing (). - argtypes whether argname is present or not taking care of the presence of the enclosing (). Since the arguments of defmethod look-like a list (at least this is how it is processed by the cpp defmethod() macro), I expect that it should be easy to process it by emacs-lisp. So, what should I put in my .emacs to make these points effective? Since I am not an expect in emacs programming (I know a bit Lisp) and I will have to extend the answer to the rest of my syntax, a clear and simple example/code would be very helpful. Any help will be very appreciated. Thanks. a+, ld.