all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* extending c-mode
@ 2006-12-15 14:03 Laurent Deniau
  0 siblings, 0 replies; only message in thread
From: Laurent Deniau @ 2006-12-15 14:03 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-12-15 14:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-15 14:03 extending c-mode Laurent Deniau

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.