[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Indentation varies for .cc and .cpp
From: |
Eric Lilja |
Subject: |
Indentation varies for .cc and .cpp |
Date: |
27 Sep 2006 00:39:59 -0700 |
User-agent: |
G2/1.0 |
Hello, I'm trying to construct .emacs-file to be used in a course. The
emacs version in question is 21.4.1. I haven't written the original
.emacs file but I've made a few changes to it based on student input.
The course is a C++ course and some of the student use .cc to denote to
C++ files, some use .cpp. We want placement of {} to be aligned with
their opening clause:
if(some_condition)
{
// code here
}
for(...)
{
// code here
}
etc...emacs does this for files ending in .cpp, but for files ending in
.cc it indents the {} themselves so we get
if(some_condition)
{
// code
}
Why and how do I change this behaviour?
Here's the .emacs-file:
(setq default-major-mode 'text-mode)
(setq require-final-newline 1)
(setq inhibit-startup-message t)
(put 'downcase-region 'disabled nil)
(setq version-control t)
(setq backup-by-copying t)
(setq backup-by-copying-when-linked t)
(setq backup-by-copying-when-mismatch t)
(setq kept-new-versions 99)
(setq kept-old-versions 0)
(setq delete-auto-save-files t)
(setq trim-versions-without-asking t)
(global-set-key "\C-X\C-s"
'(lambda () (interactive) (save-buffer 16)))
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(set-language-environment "Latin-1")
(set-terminal-coding-system 'latin-1)
(setq scroll-bar-mode-explicit t)
(set-scroll-bar-mode 'right)
(set-background-color "White")
(set-foreground-color "Black")
(set-cursor-color "Black")
(custom-set-variables)
(custom-set-faces
'(font-lock-comment-face ((((class color) (background light))
(:italic t :foreground
"Firebrick"))))
'(font-lock-function-name-face ((((class color) (background light))
(:bold t
:foreground "Blue"))))
'(font-lock-keyword-face ((((class color) (background light))
(:bold t :foreground
"Black"))))
'(font-lock-string-face ((((class color) (background light))
(:italic t :foreground
"ForestGreen"))))
'(font-lock-type-face ((((class color) (background light))
(:foreground "Blue"))))
'(font-lock-variable-name-face ((((class color) (background light))
(:foreground
"Black"))))
'(font-lock-reference-face ((((class color) (background light))
(:foreground
"ForestGreen")))))
(transient-mark-mode t)
(show-paren-mode 1)
(setq next-line-add-newlines nil)
(setq line-number-mode t)
(setq column-number-mode t)
(setq-default indent-tabs-mode nil)
(setq c-basic-offset 3)
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
(display-time)
(if (eq window-system 'x)
(pc-selection-mode))
(if (string-match "^21" emacs-version)
(progn
(tool-bar-mode -1)
(blink-cursor-mode -1)))
(setq foo (global-key-binding "\C-m"))
(global-set-key "\C-m" (global-key-binding "\C-j"))
(global-set-key "\C-j" foo)
(global-set-key [f4] 'menu-bar-mode)
(global-set-key [f5] 'toggle-truncate-lines)
(add-to-list 'auto-mode-alist '("\\.h$" . c++-mode))
;;(setq c-default-style "stroustrup")
(setq c-default-style "ellemtel")
I stripped out comments in swedish manually so they don't distract,
hope I didn't remove any non-comments by mistake (a command to that
gratefully accepted).
/ E
- Indentation varies for .cc and .cpp,
Eric Lilja <=