Date: Fri, 1 Dec 1995 16:44:10 -0700 From: Nate Williams <nate@rocky.sri.MT.net> To: Chuck Robey <chuckr@glue.umd.edu> Cc: FreeBSD Questions <FreeBSD-Questions@FreeBSD.org> Subject: Re: xemacs Message-ID: <199512012344.QAA27427@rocky.sri.MT.net> In-Reply-To: <Pine.SUN.3.91.951201165221.10429A-100000@mocha.eng.umd.edu> References: <Pine.SUN.3.91.951201165221.10429A-100000@mocha.eng.umd.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Chuck Robey writes:
> I hope there's someone out there who knows emacs.
>
> I am learning emacs unwillingly, at the behest of of the cs department,
> and I have to figure out how to set up the C language indentation to work
> in the style I like. It wants to do:
>
> funcname( parm-list )
> {
> func-body;
> }
>
> I want it to do like I do in vi, where I use tabbing only (never
> spacing), with tabs=4, and the form:
>
> funcname( parm-list )
> {
> func-body;
> }
>
> I do like the way it highlights, in color or font, the various parts of
> the code, but I want it to format MY way. Can anyone help me? I can
> find how the indentation engine works in the info docs, but I can't see
> how to change it.
Sure, here's the relevant chunks out of my .emacs. Note, I'm doing it
*MY* way, but you should be able to figure it out using this.
;;; Real indention stuff for C and C++
;;; Defining offsets for cc mode (c mode in xemacs)
(defconst my-c-style
'((c-basic-offset . 4)
(c-comment-only-line-offset . 0)
(c-tab-always-indent . nil)
(c-commit-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
; (brace-list-entry . 0)
;; some people might prefer
;; (statement . 0)
(statement . c-lineup-runin-statements)
;; some people might prefer
;; (statement-cont . +)
(statement-cont . c-lineup-math)
(substatement-open . 0)
;; (arglist-close . +)
(arglist-close . c-lineup-arglist)
))
(c-echo-syntactic-information-p . t))
"Nate's C/C++ Programming Style")
;;; Customizations for both C-mode and C++-mode
(defun my-c-mode-common-hook()
;; Add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;; Other C-mode customizations
(c-toggle-auto-hungry-state 1)
;; Both c++-mode-map and objc-mode map inherit c-mode map mods
(define-key c-mode-map "\C-m" 'newline-and-indent)
)
;; Use the newly defined programming/indent style in c-mode
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
-------------
If you need more help, see
/usr/local/lib/xemacs-19.13/lisp/modes/cc-mode.el. Hope this helps,
Nate
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199512012344.QAA27427>
