[comp.emacs] Electric c/c++/Pascal mode for GNU emacs?

heiser@ethz.UUCP (Gernot Heiser) (09/18/87)

UNIPRESS Emacs comes with what is called Electric C Mode, which  does much more
than what GNU Emacs c mode does (mainly indenting). In particular, it does cool
things like automatic command completion etc.

Of course I could hack the mocklisp into GNU elisp, but
 a) this may be violating Unipress' copyrights
 b) might be re-inventing the weel.
Writing it from scratch seems even less attractive.

My question is  therefore:  Does  anybody have anything  the like for GNU Emacs
(besides c I'm also interested in c++ and Pascal)? Please refrain  from the "my
editor  is better than  yours" stuff, we had that  on the net  last year and it
took several weeks until comp.emacs became useful again.

Thanks a lot

-- 
Gernot Heiser                      Phone:       +41 1/256 23 48
Institute for Integrated Systems   CSNET/ARPA:  heiser@ifi.ethz.ch@relay.cs.net
ETH Zuerich                        EARN/BITNET: GRIDFILE@CZHETH5A
CH-8092 Zuerich, Switzerland       EUNET/UUCP:  {seismo,...}!mcvax!ethz!heiser

karl@tut.cis.ohio-state.edu (Karl Kleinpaste) (09/25/87)

heiser@ethz.UUCP writes:
>UNIPRESS Emacs comes with what is called Electric C Mode, which does much more
>than what GNU Emacs c mode does (mainly indenting).

(Emphatically *not* an entry in "my editor is better than yours...")

If you're concerned primarily with auto-indentation, is it possible
that you haven't looked into all the c-* variables in GNU Emacs C
mode?  In particular, c-auto-newline does some fairly impressive
things with figuring your indentations out for you on the fly without
even having to ask for indentation.  (And, of course, LF in C mode
does a newline-and-indent.)  Consider the following set of c-* vars:

(setq c-argdecl-indent 0
      c-auto-newline t
      c-brace-imaginary-offset 0
      c-brace-offset 0
      c-continued-statement-offset 0
      c-indent-level 8
      c-label-offset -8
      comment-column 40)

In the office where I last worked, this set of vars was used to give a
rigid style of the form

func(arg1, arg2)
int arg1;
char arg2;
{
	register foo;
	extern FILE *fp;

	if ((char)arg1 == arg2)
	{
		func2(&foo);
		fprintf(fp, "foo is %d\n", foo);
	}
	else
	{
		exit(1);
	}
}

I only had to type a single LF during the preparation of that
fragment, after the closing paren in the first line.  The rest
auto-indented on its own following any occurrences of {, }, or ;.
Give these a try; they may do what you want without having to hack up
Unipress' C stuff.
-- 
Karl