;; -*- emacs-lisp -*-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; $Id: keys.el,v 1.13 2004/03/09 21:53:21 ole Exp $
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; global and mode local key definitions
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; kludge fo cvs emacs

(global-set-key [(control x) (control c)]
                (lambda () (interactive) (save-some-buffers) (kill-emacs)))


;; set undo to Ctrl-Z.
(global-set-key [(control z)] 'advertised-undo)
(global-set-key [(control meta z)] 'suspend-console)

(if (fboundp 'switch-to-other-buffer)
    (global-set-key [f2] 'switch-to-other-buffer)
  (global-set-key [f2] "\C-xb\C-m")
)

(global-set-key [f11] 'advertised-undo)
(global-set-key [(control f11)] 'indent-region)
(global-set-key [(meta f11)] "\C-u\C-x\C-i")
(global-set-key [(control meta f11)] "\C-U-4\C-x\C-i")

(global-set-key [f12] 'kill-current-buffer)
(global-set-key [(control f12)] 'kill-current-buffer-and-window)

;; toggle macros 
(defun start-or-end-kbd-macro ()
  ;; A doc string.  This is optional.
  "Start defining a keyboard macro, or stop if we're already defining."
  (interactive)
  (if defining-kbd-macro
      (end-kbd-macro)
    (start-kbd-macro nil)))

;; The macros used to have their place in the function keys, but I
;; find that I use them significantly less than the really basic
;; things on the function keys.  When using a macro, you call the
;; macro much more than define it, so the setup below makes some
;; sense.

(global-set-key [(shift kp-multiply)] 'start-or-end-kbd-macro)
(global-set-key [kp-multiply] 'call-last-kbd-macro) ;; C-x e

;; programmer friendly mapping for german keybords
(define-key key-translation-map [(meta Odiaeresis)] "{")
(define-key key-translation-map [(meta Adiaeresis)] "}")
(define-key key-translation-map [(meta odiaeresis)] "[")
(define-key key-translation-map [(meta adiaeresis)] "]")
(define-key key-translation-map [(meta Ö)] "{")
(define-key key-translation-map [(meta Ä)] "}")
(define-key key-translation-map [(meta ö)] "[")
(define-key key-translation-map [(meta ä)] "]")

;; This nicely parallels M-*, which pops the tag stack.  See below for
;; how to set up tags.
(global-set-key [(control *)] 'find-tag-at-point)

;; Note that you can use a "lambda" expression (an anonymous function)
;; in place of a function name.  This function would be called
;; `pop-local-mark' and lets you repeatedly cycle back through recent
;; marks (marks are set whenever you begin a selection, begin a
;; successful search, are about to jump to the beginning or end of the
;; buffer, etc.).
(global-set-key [kp-enter] (lambda () (interactive) (set-mark-command t)))
(global-set-key [(shift kp-enter)] 'repeat-complex-command)
(global-set-key [pause] 'repeat-complex-command) ;; useful on Windows-style kbds
(global-set-key [(control kp-enter)] 'eval-expression)