From owner-freebsd-questions Fri Dec 1 15:42:05 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id PAA05019 for questions-outgoing; Fri, 1 Dec 1995 15:42:05 -0800 Received: from rocky.sri.MT.net (rocky.sri.MT.net [204.182.243.10]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id PAA05008 for ; Fri, 1 Dec 1995 15:41:56 -0800 Received: (from nate@localhost) by rocky.sri.MT.net (8.6.12/8.6.12) id QAA27427; Fri, 1 Dec 1995 16:44:10 -0700 Date: Fri, 1 Dec 1995 16:44:10 -0700 From: Nate Williams Message-Id: <199512012344.QAA27427@rocky.sri.MT.net> To: Chuck Robey Cc: FreeBSD Questions Subject: Re: xemacs In-Reply-To: References: Sender: owner-questions@FreeBSD.org Precedence: bulk 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