help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple editor required


From: Peter Lee
Subject: Re: simple editor required
Date: Tue, 03 Jun 2003 15:06:27 GMT
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (windows-nt)

>>>> On Tue, 03 Jun 2003 13:51:57 GMT, "Paul Edwards" <kerravon@nosppaam.w3.to> 
>>>> said:

    Paul> ... didn't stop this auto-file-association from happening?
    Paul> I basically don't want emacs to do any junk like that, I'm
    Paul> not interested in its assumptions, I'm after basic editting
    Paul> functions, rather than by default being launched into its
    Paul> weird ideas of what C code should look like (which is
    Paul> probably a style used by less than 10% of C programmers).

There are several styles provided by emacs (see c-default-style and
c-set-style).  You can also create your own style, or you can simply
change an existing style to suit your needs (which is what I do).

(defun my-c-mode-common-hook ()
  (turn-on-font-lock)
  (c-set-offset 'substatement-open 0)
  (c-set-offset 'arglist-intro 1)
  (c-set-offset 'defun-open 4)
  (c-set-offset 'defun-block-intro 0)
  (c-set-offset 'statement 0)
  (c-set-offset 'substatement-open 4)
  (c-set-offset 'statement-block-intro 0)
  (c-set-offset 'substatement 4)
  (c-set-offset 'statement-cont 4)
  (c-set-offset 'label -4)
  (c-set-offset 'topmost-intro-cont 4)
  (c-set-offset 'brace-list-intro 0)
  (c-set-offset 'class-open 4)
  (c-set-offset 'class-close 4)
  (c-set-offset 'topmost-intro '-)
  (c-set-offset 'brace-list-open 4)
  (c-set-offset 'access-label '--)
  (c-set-offset 'func-decl-cont 0)
  (c-set-offset 'case-label 0)
  (c-set-offset 'statement-case-intro 4)
  (c-set-offset 'statement-case-open 4)
  (c-set-offset 'inline-open '+)
  (c-toggle-auto-hungry-state 1)
  (local-set-key [?\C-c ?\C-i] 'c-includes-current-file)
  (define-abbrev local-abbrev-table "ifx" "" 'my-skeleton-c-if)
  (define-abbrev local-abbrev-table "forx" "" 'my-skeleton-c-for)
  (define-abbrev local-abbrev-table "whilex" "" 'my-skeleton-c-while)
  (define-abbrev local-abbrev-table "switchx" "" 'my-skeleton-c-switch))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)


If you really do want text mode for c files then specify it with the
auto-mode-alist:

(setq auto-mode-alist
      (append '(("\\.c$"    . text-mode)
                ("\\.cc$"   . text-mode)
                ("\\.C$"    . text-mode)
                ("\\.CC$"   . text-mode)
                ("\\.h$"    . text-mode)
                ("\\.H$"    . text-mode))
      auto-mode-alist))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]