;;; .emacs configuration file
;;; MH 25.10.04
;; show umlaute (ISO 8859)
(set-language-environment "Latin-1")
;;(set-input-method "latin-1-prefix") ;; or "latin-1-postfix"
;; show line and column numbers
(line-number-mode t)
(column-number-mode t)
;; don't beep
(setq visible-bell t)
;; show time
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(display-time)
;; show matching parentheses
(require 'paren)
(setq show-paren-mode t)
;; turn on syntax highlighting
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
;; some keyboard defs
(global-set-key [C-right] 'forward-word)
(global-set-key [C-left] 'backward-word)
(global-set-key [M-C-right] 'forward-list)
(global-set-key [M-C-left] 'backward-list)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [C-home] 'beginning-of-buffer)
(global-set-key [C-end] 'end-of-buffer)
(global-set-key [Delete] 'delete-char)
(global-set-key [Backspace] 'backward-delete-char-untabify)
;; show header-files in c++-mode:
(setq auto-mode-alist
(cons '("\\.h\\'" . c++-mode) auto-mode-alist))
;; compile function
(defun save-compile()
"Save current buffer and compile."
(interactive)
(save-buffer)
(compile compile-command)
(end-of-buffer-other-window 0))
(defun is-cxx()
"Return t, iff current buffer is a C++ source file."
(string-match ".*\\.\\C$" buffer-file-name))
;; function to indent:
(defun indent-whole-buffer()
"Indent whole buffer (using indent-region)."
(interactive)
(normal-mode)
(save-excursion
(mark-whole-buffer)
(if (is-cxx)
(call-interactively 'untabify))
(call-interactively 'indent-region))
(message "%s" "Indented whole buffer."))
;; function to compile:
(defun cxx-compile()
"If current buffer is a C++ source file (.C),
compile it using the command \"(g)make \"."
(interactive)
(if (is-cxx)
(progn (setq compile-command
(concat
(if (file-executable-p "/usr/sepp/bin/gmake") "g" nil)
"make "
(substring buffer-file-name 0 -2)))
(save-buffer)
(compile compile-command))
(message "%s" "This is not a C++ source file.")))
;; use stroustrup style of indentation
(defun my-c-mode-common-hook ()
;; use Stroustrup style for all C, C++, and Objective-C code
;; (c-set-style "stroustrup")
(c-set-style "gnu")
;; other customizations can go here
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;; some keydefs
(global-set-key [f6] 'indent-whole-buffer)
(global-set-key [f7] 'previous-error)
(global-set-key [f8] 'next-error)
(global-set-key [f9] 'cxx-compile)
(global-set-key [f10] 'goto-line)
;;; EOF