.emacs

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; aczutro ;;;;;

;;;;; package integration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
   '("melpa" . "http://melpa.milkbox.net/packages/")
   t
   );add-to-list
  );when

(if (boundp 'package-integration)
    t
  (progn
    (add-to-list 'load-path "/home/aczutro/.elisp")
    ;; (require 'wc-mode)
    (require 'word-count)
    (require 'emacs-goodies-el)
    (require 'windmove)
    ;; (require 'psvn)
    ;; (require 'buffer-move)

    ;; (add-to-list 'load-path "/user/aac/.bin/.emacs/share/emacs/24.3/lisp/p4")
    ;; (require 'p4)

    ;; (require 'git)
    ;; (require 'git-blame)

    ;;    ;;;; get cedet: git clone http://git.randomsample.de/cedet.git
    ;;    (setq cedet-root-path (file-name-as-directory (expand-file-name "/home/aczutro/.elisp/cedet")))
    ;;    (add-to-list 'Info-default-directory-list "/home/aczutro/.elisp/cedet/doc/info")
    ;;    (add-to-list 'load-path "/home/aczutro/.elisp/cedet")
    ;;    (load-file "/home/aczutro/.elisp/cedet/cedet-devel-load.el")
    ;;    ;; (add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode t)
    ;;    ;; (add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode t)
    ;;    ;; (add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode t)
    ;;    (semantic-mode 1)
    ;;    ;; (global-ede-mode 1)

    ;; (require 'semantic/analyze)
    ;; (provide 'semantic-analyze)
    ;; (provide 'semantic-ctxt)
    ;; (provide 'semanticdb)
    ;; (provide 'semanticdb-find)
    ;; (provide 'semanticdb-mode)
    ;; (provide 'semantic-load)
    
    ;; (add-to-list 'load-path "/user/aac/.bin/.emacs/share/emacs/24.3/lisp/ecb")
    ;; (require 'ecb-autoloads)
    
    (print "finished package integration")
    (setq package-integration t)
    );progn
  );if

;;;;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(Man-notify-method (quote pushy))
 '(browse-url-browser-function (quote browse-url-generic))
 '(browse-url-generic-program "google-chrome")
 '(bs-attributes-list
   (quote
    (("" 1 1 left-fringe-width bs--get-marked-string)
     ("M" 1 1 left bs--get-modified-string)
     ("R" 2 2 left bs--get-readonly-string)
     ("Buffer" bs--get-name-length 10 left bs--get-name)
     ("" 1 1 left " ")
     ("Mode" 12 12 right bs--get-mode-name)
     ("" 2 2 left "  ")
     ("File" 12 12 left bs--get-file-name)
     ("" 2 2 left "  "))))
 '(bs-max-window-height 40)
 '(case-fold-search t)
 '(column-number-mode t)
 '(compilation-start-hook (quote (next-error-follow-minor-mode)))
 '(compile-command "make ")
 '(current-language-environment "Latin-1")
 '(default-input-method "latin-1-prefix")
 '(default-major-mode (quote text-mode) t)
 '(delete-selection-mode nil)
 '(dired-listing-switches "-Dago")
 '(display-time-24hr-format t)
 '(display-time-day-and-date t)
 '(display-time-default-load-average nil)
 '(display-time-mail-directory nil)
 '(display-time-mail-file (quote none))
 '(display-time-mode nil)
 '(ecb-auto-expand-directory-tree (quote first))
 '(ecb-compilation-buffer-names (quote (("\\*[cC]ompilation.*\\*" . t) ("*Compile-log*"))))
 '(ecb-compile-window-height nil)
 '(ecb-compile-window-temporally-enlarge (quote after-selection))
 '(ecb-history-make-buckets (quote never))
 '(ecb-history-sort-ignore-case nil)
 '(ecb-history-sort-method nil)
 '(ecb-key-map
   (quote
    ("C-c ,"
     (t "fh" ecb-history-filter)
     (t "fs" ecb-sources-filter)
     (t "fm" ecb-methods-filter)
     (t "fr" ecb-methods-filter-regexp)
     (t "ft" ecb-methods-filter-tagclass)
     (t "fc" ecb-methods-filter-current-type)
     (t "fp" ecb-methods-filter-protection)
     (t "fn" ecb-methods-filter-nofilter)
     (t "fl" ecb-methods-filter-delete-last)
     (t "ff" ecb-methods-filter-function)
     (t "p" ecb-nav-goto-previous)
     (t "n" ecb-nav-goto-next)
     (t "lc" ecb-change-layout)
     (t "lr" ecb-redraw-layout)
     (nil "<f9>" ecb-toggle-ecb-windows)
     (nil "C-x <f9>" ecb-toggle-layout)
     (t "s" ecb-window-sync)
     (t "r" ecb-rebuild-methods-buffer)
     (t "a" ecb-toggle-auto-expand-tag-tree)
     (t "x" ecb-expand-methods-nodes)
     (t "h" ecb-show-help)
     (t "gl" ecb-goto-window-edit-last)
     (t "g1" ecb-goto-window-edit1)
     (t "g2" ecb-goto-window-edit2)
     (t "gc" ecb-goto-window-compilation)
     (t "gd" ecb-goto-window-directories)
     (t "gs" ecb-goto-window-sources)
     (t "gm" ecb-goto-window-methods)
     (t "gh" ecb-goto-window-history)
     (t "ga" ecb-goto-window-analyse)
     (t "gb" ecb-goto-window-speedbar)
     (t "md" ecb-maximize-window-directories)
     (t "ms" ecb-maximize-window-sources)
     (t "mm" ecb-maximize-window-methods)
     (t "mh" ecb-maximize-window-history)
     (t "ma" ecb-maximize-window-analyse)
     (t "mb" ecb-maximize-window-speedbar)
     (t "e" eshell)
     (t "o" ecb-toggle-scroll-other-window-scrolls-compile)
     (t "\\" ecb-toggle-compile-window)
     (t "/" ecb-toggle-compile-window-height)
     (t "," ecb-cycle-maximized-ecb-buffers)
     (t "." ecb-cycle-through-compilation-buffers)
     (nil "C-c <f9>" ecb-deactivate))))
 '(ecb-kill-buffer-clears-history (quote auto))
 '(ecb-layout-name "left")
 '(ecb-options-version "2.40")
 '(ecb-show-sources-in-directories-buffer (quote ("left7" "left13" "left14" "left15" "left")))
 '(ecb-source-path (quote (("/home/aczutro" "HOME"))))
 '(ecb-sources-sort-ignore-case nil)
 '(ecb-tip-of-the-day nil)
 '(ecb-toggle-layout-sequence (quote ("left14" "left9" "left")))
 '(ecb-windows-height 0.27)
 '(ecb-windows-width 0.27)
 '(eshell-visual-commands
   (quote
    ("vi" "screen" "top" "less" "more" "lynx" "ncftp" "pine" "tin" "trn" "elm" "w3m")))
 '(file-name-shadow-mode t)
 '(file-name-shadow-tty-properties (quote (invisible t intangible t)))
 '(fill-column 79)
 '(font-lock-maximum-decoration t)
 '(glasses-face (quote bold))
 '(glasses-separator "")
 '(global-font-lock-mode t nil (font-lock))
 '(grep-command "egrep -nHi ")
 '(grep-find-command "find . -type f -print0 | xargs -0 -e egrep -nHi ")
 '(grep-find-template
   "find . <X> -type f <F> -print0 | xargs -0 -e egrep <C> -nHi <R>")
 '(grep-highlight-matches t)
 '(grep-template "egrep <C> -nHi <R> <F>")
 '(indent-tabs-mode nil)
 '(inhibit-startup-screen t)
 '(line-move-visual nil)
 '(load-home-init-file t t)
 '(make-backup-files nil)
 '(org-confirm-elisp-link-function nil)
 '(org-cycle-global-at-bob t)
 '(org-cycle-include-plain-lists t)
 '(org-display-custom-times t)
 '(org-export-headline-levels 9)
 '(org-export-html-style
   "<style type=\"text/css\">
  html {
	font-family: sansserif, sans-serif, sans, arial, helvetica;
	font-size: 12pt;
  }
  .title { text-align: center; }
  .todo  { color: red; }
  .done { color: green; }
  .timestamp { color: black; font-weight:bold }
  .timestamp-kwd { color: CadetBlue }
  .tag { background-color:white; color:red; font-weight:bold ; font-style:italic ; padding-left:3px; padding-right:3px; }
  .target { background-color: lavender; }
  pre {
	border: 1pt solid #AEBDCC;
	background-color: #F3F5F7;
	padding: 5pt;
	font-family: courier, monospace;
  }
  table { border-collapse: collapse; }
  td, th {
	vertical-align: top;
        text-align: right;
	<!--border: 1pt solid #ADB9CC;-->
  }
</style>")
 '(org-export-with-toc 3)
 '(org-file-apps
   (quote
    ((auto-mode . emacs)
     ("\\.x?html?\\'" . emacs)
     ("\\.pdf\\'" . "acroread %s"))))
 '(org-latex-classes
   (quote
    (("article" "\\documentclass[11pt]{article}"
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
      ("\\paragraph{%s}" . "\\paragraph*{%s}")
      ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
     ("report" "\\documentclass[11pt]{report}"
      ("\\chapter{%s}" . "\\chapter*{%s}")
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
     ("book" "\\documentclass[11pt]{book}"
      ("\\part{%s}" . "\\part*{%s}")
      ("\\chapter{%s}" . "\\chapter*{%s}")
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))))
 '(org-link-frame-setup
   (quote
    ((vm . vm-visit-folder)
     (gnus . gnus)
     (file . find-file))))
 '(org-return-follows-link t)
 '(org-time-stamp-custom-formats (quote ("<%a %d %b %Y>" . "<%a %d %b %Y %H:%M>")))
 '(package-selected-packages (quote (magit)))
 '(pop-up-frames nil)
 '(pop-up-windows nil)
 '(safe-local-variable-values (quote ((mmm-classes . here-doc) (TeX-master . "main"))))
 '(same-window-buffer-names
   (quote
    ("*shell*" "*mail*" "*inferior-lisp*" "*ielm*" "*scheme*" "*w3m*" "*svn-diff*" "*svn-info*" "*svn-log*")))
 '(scroll-conservatively 1)
 '(scroll-margin 0)
 '(scroll-preserve-screen-position t)
 '(show-paren-mode t nil (paren))
 '(speedbar-frame-parameters
   (quote
    ((minibuffer)
     (width . 20)
     (border-width . 0)
     (menu-bar-lines . 0)
     (tool-bar-lines . 0)
     (unsplittable)
     (left-fringe . 0))))
 '(speedbar-select-frame-method 0)
 '(svn-status-fancy-file-state-in-modeline nil)
 '(svn-status-hide-unknown t)
 '(svn-status-hide-unmodified t)
 '(svn-status-short-mod-flag-p nil)
 '(svn-status-use-header-line nil)
 '(transient-mark-mode t)
 '(truncate-lines t)
 '(w3m-home-page "about://bookmark/")
 '(w3m-key-binding (quote info))
 '(w3m-tab-width 8)
 '(w3m-use-header-line-title t)
 '(w3m-use-tab nil))

;; (setq display-buffer-alist '(("\\*svn-.*\\*" display-buffer-in-satellite)))

(setq semanticdb-default-save-directory	"/home/aczutro/.emacs.d/semantic"
      resize-mini-windows		nil
      )

(setq stack-trace-on-error nil)

(put 'upcase-region		'disabled nil)
(put 'downcase-region		'disabled nil)
(put 'dired-find-alternate-file	'disabled nil)
(put 'scroll-left		'disabled nil)
(put 'narrow-to-region		'disabled nil)
(put 'narrow-to-page		'disabled nil)

(setq split-hor-large	73)
(setq split-hor-small	27)
(setq split-ver-large	5)
(setq split-ver-small	1)





;;;;; faces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(diff-added ((t (:foreground "blue"))))
 '(diff-file-header ((((class color) (background light)) (:foreground "yellow" :weight bold))))
 '(diff-header ((((class color) (background light)) (:foreground "green" :weight bold))))
 '(diff-refine-change ((((class color) (background light)) (:background "white" :weight bold))) t)
 '(diff-removed ((t (:foreground "red"))))
 '(ediff-current-diff-A ((t (:foreground "red" :weight bold))))
 '(ediff-current-diff-B ((t (:foreground "blue" :weight bold))))
 '(ediff-even-diff-A ((t (:foreground "white"))))
 '(ediff-even-diff-B ((t (:foreground "white"))))
 '(ediff-fine-diff-A ((t (:background "white" :foreground "red" :weight bold))))
 '(ediff-fine-diff-B ((t (:background "white" :foreground "blue" :weight bold))))
 '(ediff-odd-diff-A ((t (:foreground "white"))))
 '(ediff-odd-diff-B ((t (:foreground "white"))))
 '(highlight-current-line-face ((t (:background "white"))))
 '(magit-branch-local ((t (:foreground "magenta" :weight bold))))
 '(magit-diff-added ((t (:foreground "blue"))))
 '(magit-diff-added-highlight ((t (:background "white" :foreground "blue"))))
 '(magit-diff-base ((t (:background "#ffffcc"))))
 '(magit-diff-context ((t nil)))
 '(magit-diff-context-highlight ((t (:background "white"))))
 '(magit-diff-file-heading ((t (:foreground "yellow" :weight bold))))
 '(magit-diff-file-heading-highlight ((t (:background "white" :foreground "yellow" :weight normal))))
 '(magit-diff-hunk-heading ((t (:foreground "green"))))
 '(magit-diff-hunk-heading-highlight ((t (:background "white" :foreground "green"))))
 '(magit-diff-removed ((t (:foreground "red"))))
 '(magit-diff-removed-highlight ((t (:background "white" :foreground "red"))))
 '(magit-hash ((t (:foreground "cyan"))))
 '(show-ws-hard-space ((t (:background "yellow"))))
 '(show-ws-tab ((t (:background "cyan"))))
 '(show-ws-trailing-whitespace ((t (:background "red"))))
 '(svn-status-directory-face ((((type tty) (class color)) (:foreground "blue" :weight bold))))
 '(svn-status-marked-face ((((type tty) (class color)) (:foreground "green" :weight bold))))
 '(w3m-header-line-location-content ((((class color) (background light)) (:background "yellow" :foreground "black" :inverse-video t :underline nil :weight bold))))
 '(w3m-header-line-location-title ((((class color) (background light)) (:foreground "black" :inverse-video t :underline nil :weight bold)))))





;;;;; hooks and modes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-hook 'c-mode-hook			(lambda () (hs-minor-mode 1)))
(add-hook 'c++-mode-hook		(lambda () (hs-minor-mode 1)))
(add-hook 'c-initialization-hook	(lambda ()
                                          ;(define-key c-mode-base-map (kbd "{")		'.c-brace)
                                          (define-key c-mode-base-map (kbd "C-m")	'c-context-line-break)
                                          (define-key c-mode-base-map (kbd "C-c <f9>")	'.ecb-activate)
                                          (define-key c-mode-base-map (kbd "C-c C-i")	'.c-for-loop)
                                          (define-key c-mode-base-map (kbd "C-c C-t")	'.c-for-it-loop)
                                          ))
(add-hook 'cperl-mode-hook	'perl-mode)
(add-hook 'perl-mode-hook		(lambda ()
                                          (define-key perl-mode-map (kbd "` {")		'.perl-brace)
                                          (define-key perl-mode-map (kbd "` `")		'self-insert-command)
                                          (define-key perl-mode-map (kbd "` s")		'clp-diag-set)
                                          (define-key perl-mode-map (kbd "` i")		'clp-diag-inst)
                                          (define-key perl-mode-map (kbd "` e")		'clp-diag-ehb)
                                          (define-key perl-mode-map (kbd "` j")		'clp-diag-jump)
                                          (define-key perl-mode-map (kbd "` b")		'clp-diag-label)
                                          (define-key perl-mode-map (kbd "` f f")	'clp-diag-if)
                                          (define-key perl-mode-map (kbd "` f t")	'clp-diag-if-then-else)
                                          (define-key perl-mode-map (kbd "` f e")	'clp-diag-if-then-else-if)
                                          (define-key perl-mode-map (kbd "` f r")	'clp-diag-if-error)
                                          (define-key perl-mode-map (kbd "` l w")	'clp-diag-loop-while)
                                          (define-key perl-mode-map (kbd "` l f")	'clp-diag-loop-for)
                                          (define-key perl-mode-map (kbd "` t")		'clp-diag-trap-handle)
                                          (define-key perl-mode-map (kbd "` v")		'clp-diag-verbose)
                                          (define-key perl-mode-map (kbd "` ~")		'clp-diag-comment)
                                          (define-key perl-mode-map (kbd "` c")		'clp-diag-internal-comment)
                                          ))
(add-hook 'gud-mode-hook		(lambda ()
                                          (global-set-key (kbd "C-x C-a C-a")	'igud-mode)
                                          (global-set-key (kbd "C-x C-a C-m")	'gud-many-windows)
                                          (define-key gud-mode-map		(kbd "<f8>")	'gdb-set-window-stack)
                                          (define-key gdb-frames-mode-map	(kbd "<f8>")	'gdb-set-window-breakpoints)
                                          (define-key gdb-breakpoints-mode-map	(kbd "<f8>")	'gdb-set-window-main)
                                          (define-key gud-mode-map		(kbd "<f7>")	'gdb-set-window-breakpoints)
                                          (define-key gdb-frames-mode-map	(kbd "<f7>")	'gdb-set-window-main)
                                          (define-key gdb-breakpoints-mode-map	(kbd "<f7>")	'gdb-set-window-stack)
                                          ))
(add-hook 'latex-mode-hook		(lambda ()
                                          (turn-on-auto-fill)
                                          (define-key tex-mode-map (kbd "C-c m")	'.tex-maths)
                                          (define-key tex-mode-map (kbd "C-c k")	'.tex-label)
                                          (define-key tex-mode-map (kbd "C-c r")	'.tex-ref)
                                          (define-key tex-mode-map (kbd "C-c p")	'.tex-pageref)
                                          (define-key tex-mode-map (kbd "C-c c")	'.tex-cite)
                                          (define-key tex-mode-map (kbd "C-c e")	'.tex-emph)
                                          (define-key tex-mode-map (kbd "C-c i")	'.tex-emphindex)
                                          (define-key tex-mode-map (kbd "C-c ]")	'.tex-heading-forward)
                                          (define-key tex-mode-map (kbd "C-c [")	'.tex-heading-backward)
                                          ))
(add-hook 'compilation-mode-hook	(lambda ()
                                          (define-key compilation-mode-map (kbd "k")	'kill-compilation)
                                          ))

(add-hook 'text-mode-hook		'turn-on-auto-fill)

(add-to-list 'auto-mode-alist	'("\\.org$" . org-mode))


(defun clear-keymap (arg)
  "clear all keybindings in keymap ARG"
  (suppress-keymap arg t)
  (define-key arg (kbd "RET")	'undefined)
  (define-key arg (kbd "SPC")	'undefined)
  (define-key arg (kbd "TAB")	'undefined)
  (define-key arg (kbd "DEL")	'undefined)
  (define-key arg (kbd "LFD")	'undefined)
  (define-key arg (kbd "ESC")	'undefined)
  (define-key arg (kbd "NUL")	'undefined)
  (define-key arg (kbd "C-a")	'undefined)
  (define-key arg (kbd "C-b")	'undefined)
  (define-key arg (kbd "C-c")	'undefined)
  (define-key arg (kbd "C-d")	'undefined)
  (define-key arg (kbd "C-e")	'undefined)
  (define-key arg (kbd "C-f")	'undefined)
  (define-key arg (kbd "C-g")	'undefined)
  (define-key arg (kbd "C-h")	'undefined)
  (define-key arg (kbd "C-i")	'undefined)
  (define-key arg (kbd "C-j")	'undefined)
  (define-key arg (kbd "C-k")	'undefined)
  (define-key arg (kbd "C-l")	'undefined)
  (define-key arg (kbd "C-m")	'undefined)
  (define-key arg (kbd "C-n")	'undefined)
  (define-key arg (kbd "C-o")	'undefined)
  (define-key arg (kbd "C-p")	'undefined)
  (define-key arg (kbd "C-q")	'undefined)
  (define-key arg (kbd "C-r")	'undefined)
  (define-key arg (kbd "C-s")	'undefined)
  (define-key arg (kbd "C-t")	'undefined)
  (define-key arg (kbd "C-u")	'undefined)
  (define-key arg (kbd "C-v")	'undefined)
  (define-key arg (kbd "C-w")	'undefined)
  (define-key arg (kbd "C-x")	'undefined)
  (define-key arg (kbd "C-y")	'undefined)
  (define-key arg (kbd "C-z")	'undefined)
  );defun


(setq iresize-mode-map (make-keymap))
(clear-keymap iresize-mode-map)
(define-key iresize-mode-map (kbd "h")		'(lambda () (interactive) (describe-minor-mode 'iresize-mode)))
(define-key iresize-mode-map (kbd "1")		'shrink-window-horizontally)
(define-key iresize-mode-map (kbd "2")		'enlarge-window-horizontally)
(define-key iresize-mode-map (kbd "9")		'shrink-window)
(define-key iresize-mode-map (kbd "0")		'enlarge-window)
(define-key iresize-mode-map (kbd "q")		'iresize-mode)
(define-minor-mode iresize-mode
  "interactively resize window\n\n\\{iresize-mode-map}"
  :initial-value nil
  :lighter " IResize"
  :keymap iresize-mode-map
  );define-minor-mode


(setq igud-mode-map (make-keymap))
(suppress-keymap igud-mode-map t)
(define-key igud-mode-map (kbd "h")	'(lambda () (interactive) (describe-minor-mode 'igud-mode)))
(define-key igud-mode-map (kbd "m")	'gud-many-windows)
(define-key igud-mode-map (kbd "b")	'gud-break)
(define-key igud-mode-map (kbd "t")	'gud-tbreak)
(define-key igud-mode-map (kbd "d")	'gud-remove)
(define-key igud-mode-map (kbd "r")	'gud-run)
(define-key igud-mode-map (kbd "f")	'gud-finish)
(define-key igud-mode-map (kbd "c")	'gud-cont)
(define-key igud-mode-map (kbd "u")	'gud-until)
(define-key igud-mode-map (kbd "j")	'gud-jump)
(define-key igud-mode-map (kbd "n")	'gud-next)
(define-key igud-mode-map (kbd "s")	'gud-step)
(define-key igud-mode-map (kbd "p")	'gud-print)
(define-key igud-mode-map (kbd "1")	'gud-up)
(define-key igud-mode-map (kbd "2")	'gud-down)
(define-key igud-mode-map (kbd "q")	'igud-mode)
(define-minor-mode igud-mode
  "provides a comfortable keymap for programme debugging while in source buffers\n\n\\{igud-mode-map}"
  :initial-value nil
  :lighter " iGUD"
  :keymap igud-mode-map
  );define-minor-mode


(setq lockscreen-mode-map (make-keymap))
(clear-keymap lockscreen-mode-map)
(define-key lockscreen-mode-map (kbd "u n l o c k")	'(lambda () (interactive) (kill-buffer (current-buffer))))
(define-minor-mode lockscreen-mode
  "lockscreen mode"
  :initial-value nil
  :keymap lockscreen-mode-map
  (goto-char (point-min))
  );define-minor-mode


(setq typographic-mode-map (make-keymap))
(define-key typographic-mode-map	(kbd "\"")		'typographic-insert-quote)
(define-key typographic-mode-map	(kbd "'")		'typographic-insert-single-quote)
(define-key typographic-mode-map	(kbd "C-c h e l p")	'(lambda () (interactive) (describe-minor-mode 'typographic-mode)))
(define-key typographic-mode-map	(kbd "C-c e n")		'typographic-english)
(define-key typographic-mode-map	(kbd "C-c d e 1")	'typographic-german-1)
(define-key typographic-mode-map	(kbd "C-c d e 2")	'typographic-german-2)
(define-key typographic-mode-map	(kbd "C-c e s")		'typographic-spanish)
(define-minor-mode typographic-mode
  "insert typographically correct quotes when ' or \" are pressed\n\n\\{typographic-mode-map}"
  :initial-value nil
  :lighter " “·”"
  :keymap typographic-mode-map
  );define-minor-mode





;;;;; commands and functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defalias 'afm		'auto-fill-mode)
(defalias 'cm		'conf-mode)
(defalias 'ctr		'copy-to-register)
(defalias 'reload	'revert-buffer)
(defalias 'sblame	'svn-status-blame)
(defalias 'sdiff	'svn-file-show-svn-diff)
(defalias 'srevert	'svn-file-revert)
(defalias 'yes-or-no-p	'y-or-n-p)


(defun clone-any-buffer (filename)
  "clone the current buffer writing it into FILENAME and open it; the current buffer is not closed"
  (interactive "Fclone to file: ")
  (save-restriction
    (widen)
    (write-region (point-min) (point-max) filename nil nil nil 'confirm)
    );save-restriction
  (find-file filename)
  );

(defun avail-width () "return the total width available for windows" (frame-width))

(defun avail-height () "return the total height available for windows"
  (- (frame-height)
     (+ (window-height (minibuffer-window))
        (if menu-bar-mode 1 0)
        );+
     );-
  );defun

(defun split-window-ratio (a b)
  "if not split, split window vertically; then, make height ratio A:B"
  (interactive "NA: \nNB: ")
  (let* ((avail-height (avail-height))
         (ziel-height (/ (* avail-height a) (+ a b)))
         (cur-height (window-height))
         );(
    (if (= avail-height cur-height)
        (split-window-vertically ziel-height)
      (enlarge-window (- ziel-height cur-height))
      );if
    );let*
  );defun

(defun hsplit-window-ratio (a b)
  "if not split, split window horizontally; then, make width ratio A:B"
  (interactive "NA: \nNB: ")
  (let* ((avail-width (avail-width))
         (ziel-width (/ (* avail-width a) (+ a b)))
         (cur-width (window-width))
         );(
    (if (= avail-width cur-width)
        (split-window-horizontally ziel-width)
      (enlarge-window-horizontally (- ziel-width cur-width))
      );if
    );let*
  );defun

(defun split-window-mirror ()
  "mirror the window height"
  (interactive)
  (let* ((avail-height (avail-height))
         (cur-height (window-height))
         );(
    (if (= avail-height cur-height)
        t
      (enlarge-window (- avail-height (* 2 cur-height)))
      );if
    );let*
  );defun

(defun hsplit-window-mirror ()
  "mirror the window width"
  (interactive)
  (let* ((avail-width (frame-width))
         (cur-width (window-width))
         );(
    (if (= avail-width cur-width)
        t
      (enlarge-window-horizontally (- avail-width (* 2 cur-width)))
      );if
    );let*
  );defun

(defun cross-split ()
  "splits the frame into four windows of equal size"
  (interactive)
  (hsplit-window-ratio 1 1)
  (split-window-ratio 1 1)
  (let ((left-p (windmove-find-other-window 'right))
        (bottom-p (windmove-find-other-window 'up))
        );(
    (if left-p
        (print "I'm left")
      (print "I'm right")
      )
    (if bottom-p
        (print "I'm bottom")
      (print "I'm top")
      )
    (if left-p
        (windmove-right)
      (windmove-left)
      );if
    (split-window-ratio 1 1)
    (if left-p
        (windmove-left)
      (windmove-right)
      );if
    (if bottom-p
        (if (null (windmove-find-other-window 'up))
            (windmove-down)
          );if
      );if
    );let
  );defun

(defun cross-split-large ()
  "resizes the current window so that it uses 3/4 of frame space, vertically and horizontally"
  (interactive)
  (hsplit-window-ratio split-hor-large split-hor-small)
  (split-window-ratio split-ver-large split-ver-small)
  );defun

(defun browse ()
  "open left panel for directory browsing"
  (interactive)
  (delete-other-windows)
  (hsplit-window-ratio split-hor-small split-hor-large)
  (dired default-directory)
  (other-window 1)
  );defun

(defun ia () "insert register a" (interactive) (insert-register ?a))
(defun ib () "insert register b" (interactive) (insert-register ?b))
(defun ic () "insert register c" (interactive) (insert-register ?c))

(defun reset-pos-registers ()
  "empty all position registers"
  (interactive)
  (setq pos-register	1001
        cycle-register	nil
        last-register	nil
        );setq
  );defun
(reset-pos-registers)

(defun record-current-position (arg)
  "record the current position in a circular list; with prefix argument, delete all saved positions"
  (interactive "P")
  (if arg
      (reset-pos-registers)
    (progn
     (point-to-register pos-register)
     (setq last-register	pos-register
           pos-register		(+ pos-register 1)
           cycle-register	(if cycle-register cycle-register 1001)
           );setq
     );progn
    );if
  );defun

(defun goto-last-position ()
  "jump to the last recorded or jumped-to position"
  (interactive)
  (if last-register
      (jump-to-register last-register)
    (error "no saved positions")
    );if
  );defun

(defun cycle-registers-forward ()
  "cycle through positions currently saved in registers"
  (interactive)
  (if cycle-register
      (progn
       (jump-to-register cycle-register)
       (setq last-register cycle-register)
       (let ((next-cycle-register (+ cycle-register 1)))
         (setq cycle-register (if (= next-cycle-register pos-register)
                                  1001
                                next-cycle-register
                                );if
               );setq
         );let
       );progn
    (error "no saved positions")
    );if
  );defun

(defun cycle-registers-backwards ()
  "cycle through positions currently saved in registers"
  (interactive)
  (if (< pos-register 1004)
      (cycle-registers-forward)
    (if cycle-register
        (let* ((pot-prev-cycle-register (if (= cycle-register 1001) (- pos-register 2) (- cycle-register 2)))
               (prev-cycle-register (if (< pot-prev-cycle-register 1001) (- pos-register 1) pot-prev-cycle-register))
               (next-cycle-register (+ prev-cycle-register 1))
               );(
          (jump-to-register prev-cycle-register)
          (setq last-register	prev-cycle-register
                cycle-register	(if (= next-cycle-register pos-register)
                                    1001
                                  next-cycle-register
                                  );if
                );setq
          );let*
      (error "no saved positions")
      );if
    );if
  );defun

(defun print-lockscreen (arg ind)
  (if (> arg 0)
      (let* ((colours (list
                       '(bold :foreground "magenta")
                       '(bold :foreground "red")
                       '(bold :foreground "yellow")
                       '(bold :foreground "green")
                       '(bold :foreground "blue")
                       '(bold :foreground "cyan")
                       '(bold :foreground "white")
                       );list
                      );colours
             (number-of-colours	(- (list-length colours) 1))
             );(
        (insert
         (propertize
          (concat
           (make-string (- (window-width) 1) ?·)
           "\n"
           );concat
          'face
          (nth ind colours)
          );propertize
         );insert
        (print-lockscreen
         (- arg 1)
         (if (= ind number-of-colours) 0 (+ ind 1))
         );print-lockscreen
        );let*
    );if
  );defun
(defun lockscreen ()
  "lock the screen"
  (interactive)
  (delete-other-windows)
  (switch-to-buffer "* screen locked * type `unlock´ to quit *")
  (if (= (buffer-size) 0) (print-lockscreen (- (window-height) 1) 0))
  (lockscreen-mode)
  );defun

(defun move-line (arg)
  "move current line up or down ARG lines"
  (let* ((zielcolumn	(current-column))
         (beg		(progn (move-beginning-of-line 1) (point)))
         (end		(progn (forward-line 1) (point)))
         (cnt		(car (list (buffer-substring beg end) (delete-region beg end))))
         );(
    (forward-line arg)
    (insert cnt (if (string-equal (substring cnt -1) "\n") "" "\n"))
    (forward-line -1)
    (move-to-column zielcolumn)
    );let*
  );defun
(defun move-line-down () "move current line up" (interactive) (move-line 1))
(defun move-line-up () "move current line down" (interactive) (move-line -1))

(defun other-frame-back () "go to other frame (inverse order)" (interactive) (other-frame -1))
(defun other-window-back () "go to other frame (inverse order)" (interactive) (other-window -1))

(defun current-line ()
  "Return the vertical position of point."
  (+
   (count-lines (window-start) (point))
   (if (= (current-column) 0) 0 -1)
   );+
  );defun
(defun scroll-vi-style (arg)
  "scroll whole screen up or down by ARG lines"
  (let
      ((zielcolumn (current-column))
       (zielline (current-line))
       );(
    (forward-line arg)
    (move-to-column zielcolumn)
    (recenter zielline)
    );let
  );defun
(defun scroll-down-vi-style () "scroll down whole screen" (interactive) (scroll-vi-style 1))
(defun scroll-up-vi-style () "scroll up whole screen" (interactive) (scroll-vi-style -1))

(defun start-server (arg)
  "start emacs server with name ARG"
  (interactive "sEnter emacs-server name: ")
  (setq server-name arg)
  (server-start)
  );defun

(defun .shell-command-buffer-name (arg)
  "returns the name of the buffer in which .shell-command is to put the output of command ARG"
  (concat "*" arg "*")
  );defun
(defun .shell-command (arg)
  "like shell command, but with some customisations"
  (interactive "sShell command: ")
  (let ((ziel-buffer (get-buffer-create (.shell-command-buffer-name arg)))
        );(
    (shell-command arg ziel-buffer)
    (if (get-buffer ziel-buffer)
        (progn
         (if (= (buffer-size ziel-buffer) 0)
             (kill-buffer ziel-buffer)
           (progn
            (pop-to-buffer ziel-buffer)
            (ansi-color-apply-on-region 1 (+ (buffer-size) 1))	; requires (autoload 'ansi-color-apply-on-region "ansi-color")
            (toggle-read-only 1)
            );progn
           );if
         );progn
      );if
    );let
  );defun

(defun get-string-from-file (arg one-line)
  "return file ARG's content as a string; if ONE-LINE is non-nil, concatenate all lines into one single line"
  (with-temp-buffer
    (insert-file-contents arg)
    (if one-line (replace-string "\n" " "))
    (buffer-string)
    );with-temp-buffer
  );defun

(defun utags ()
  "update tags table"
  (interactive)
  (let ((sources-file (concat default-directory ".tags-sources"))
        (tags-target (concat default-directory ".TAGS"))
        );(
    (if (file-readable-p sources-file)
        (progn
         (shell-command
          (concat "etags "
                  (get-string-from-file sources-file t)
                  " -o "
                  tags-target
                  );concat
          );.shell-command
         (visit-tags-table tags-target)
         );progn
      (error "cannot find or read file `%s´ containing list of source files" sources-file)
      );if
    );let
  );defun

(defun mark-this-window-as-satellite ()
  "mark the current window as the satellite window"
  (interactive)
  (mapc (lambda (win) (set-window-parameter win 'satellite nil))
        (window-list)
        );mapc
  (set-window-parameter nil 'satellite t)
  (message "window %s is now the satellite window" (selected-window))
  );defun

(defun get-satellite-window ()
  "find and return the satellite window or nil if non exists"
  (find-if (lambda (win) (window-parameter win 'satellite))
           (window-list)
           );find-if
  );defun

(defun display-buffer-in-satellite (buffer &optional ignore)
  "display the buffer in the satellite window, or the first window it finds if there is no satellite"
  (let ((satellite-window (or (get-satellite-window)
                              (car (window-list))
                              );or
                          );satellite-window
        );(
    (select-window satellite-window)
    (display-buffer-same-window buffer nil)
    (display-buffer-record-window 'reuse satellite-window buffer)
    satellite-window
    );let
  );defun

(defun svn (arg)
  "starts svn support; if svn support is already running, updates the main svn buffer"
  (interactive "P")
  (if arg
      (svn-status default-directory)
      (progn
        (switch-to-buffer "*svn-status*")
        (if (= (buffer-size) 0)
            (svn-status default-directory)
          (svn-status-update)
          );if
        );progn
    );if
  );defun

(defun .term (arg)
  "starts a terminal; if one is already running, brings it to the front;\n with prefix argument, renames existing term buffers and starts a new one"
  (interactive "P")
  (if arg
      (let ((cur-buffer (current-buffer))
            );(
        (if (get-buffer "*terminal*")
            (progn
              (switch-to-buffer "*terminal*")
              (rename-uniquely)
              (switch-to-buffer cur-buffer)
              );progn
          );if
        (term (if (getenv "SHELL")
                  (getenv "SHELL")
                "/bin/bash"
                );if
              );term
        );let
    (if (get-buffer "*terminal*")
        (switch-to-buffer "*terminal*")
      (term (if (getenv "SHELL")
                (getenv "SHELL")
              "/bin/bash"
              );if
            );term
      );if
    );if
  );defun

(defun .eshell (arg)
  "starts an eshell; if one is already running, brings it to the front;\n with prefix argument, renames existing eshell buffers and starts a new one"
  (interactive "P")
  (if arg
      (let ((cur-buffer (current-buffer))
            );(
        (if (get-buffer "*eshell*")
            (progn
              (switch-to-buffer "*eshell*")
              (rename-uniquely)
              (switch-to-buffer cur-buffer)
              );progn
          );if
        (eshell)
        );let
    (if (get-buffer "*eshell*")
        (switch-to-buffer "*eshell*")
      (eshell)
      );if
    );if
  );defun

(defun nstep ()
  "open new buffer for notes"
  (interactive)
  (switch-to-buffer "*NEXT STEPS*")
  (if (= (buffer-size) 0)
      (insert "# -*- mode: org; -*-\n#+STARTUP: showall\n\n* NEXT STEPS\n  - ")
    );if
  (normal-mode)
  );defun

(defun gdb-set-window-locals		() (gdb-set-window-buffer (gdb-locals-buffer-name)))
(defun gdb-set-window-breakpoints	() (interactive) (switch-to-buffer (gdb-breakpoints-buffer-name)))
(defun gdb-set-window-main		() (interactive) (switch-to-buffer gud-comint-buffer))
;(defun gdb-set-window-memory		() (interactive) (switch-to-buffer (gdb-memory-buffer-name)))
(defun gdb-set-window-stack		() (interactive) (switch-to-buffer (gdb-stack-buffer-name)))

(defun gud-many-windows-custom () "customise the many-windows arrangement used by gdba"
  ;(gdb-display-memory-buffer)
  (delete-other-windows)
  (split-window-ratio 4 1)
  (hsplit-window-ratio split-hor-small split-hor-large)
  (gdb-set-window-locals)
  (other-window 1)
  (switch-to-buffer (gud-find-file gdb-main-file))
  (other-window 1)
  (gdb-set-window-main)
  );defun
(defun gud-many-windows (arg)
  "make or restore the many-windows arrangement used by gdba; with prefix argument, make single-window environment"
  (interactive "P")
  (gdb-many-windows (if arg 0 1))
  (if gdb-many-windows
      (gud-many-windows-custom)
    );if
  );defun
(defadvice gdb-setup-windows
  (after mkmcc-gdb-setup-windows-advice first nil activate)
  (interactive)
  (gud-many-windows-custom)
  );defadvice

(defun enhance-frame-name ()
  "renames the currently active frame to something derived from the server name; if no server is running, does nothing"
  (interactive)
  (let* ((orig-name (cdr (assq 'name (frame-parameters (selected-frame)))))
         (new-name (if (string-equal "F" (substring orig-name 0 1))
                       (concat " <"
                               (if (boundp 'server-name)
                                   (concat server-name " " (substring orig-name 1))
                                 orig-name
                                 );if
                               ">"
                               );concat
                     orig-name
                     );if
                   );new-name
         );(
    (set-frame-name new-name)
    );let*
  );defun
(defadvice make-frame-command
  (after rename-frame-upon-making first nil activate)
  (interactive)
  (enhance-frame-name)
  );defadvice

;; redefines yank-pop \M-y to use browse-kill-ring
(defadvice yank-pop (around kill-ring-browse-maybe (arg))
  "If last action was not a yank, run `browse-kill-ring' instead."
  (if (eq last-command 'yank) ad-do-it (browse-kill-ring))
  );defadvice
(ad-activate 'yank-pop)

(defun ..diff (arg1 arg2 force-binary)
  "enhanced diff mode, backend"
  (let* ((diff-com	(concat (if force-binary "diff -adu " "diff ") arg1 " " arg2))
         (diff-buffer	(.shell-command-buffer-name diff-com))
         );(
    (.shell-command diff-com)
    (if (get-buffer diff-buffer)
        (progn
         (switch-to-buffer diff-buffer)
         (diff-mode)
         (toggle-read-only)
         );progn
      );if
    );let*
  );defun
(defun .diff (arg)
  "enhanced diff mode"
  (interactive "P")
  (let ((arg1 (read-file-name "File 1: "))
        (arg2 (if (or arg (not buffer-file-name))
                  (read-file-name "File 2: ")
                buffer-file-name
                );if
              );arg2
        );(
    (..diff arg1 arg2 nil)
    );let
  );defun
(defun .diff-a (arg)
  "enhanced diff mode"
  (interactive "P")
  (let ((arg1 (read-file-name "File 1: "))
        (arg2 (if (or arg (not buffer-file-name))
                  (read-file-name "File 2: ")
                buffer-file-name
                );if
              );arg2
        );(
    (..diff arg1 arg2 t)
    );let
  );defun

(defun .c-brace-backend (region-begin region-end comment-start comment-end)
  "insert {} around region"
  (let* ((reg (car (list (buffer-substring region-begin region-end) (delete-region region-begin region-end))))
         (end (progn (delete-horizontal-space) (c-indent-line-or-region) (point)))
         (beg (progn (move-beginning-of-line 1) (c-indent-line-or-region) (point)))
         (str (buffer-substring beg end))
         );(
    (progn
     (goto-char end)
     (insert "{" (if (string-equal reg "") "\n\n\n\n" "\n\n") "} " comment-start " end " str " " comment-end)
     (c-indent-line-or-region)
     (if (string-equal reg "")
         (progn
          (forward-line -2)
          (c-indent-line-or-region)
          );progn
       (progn
        (forward-line -1)
        (insert reg)
        (c-indent-line-or-region end (progn
                                       (goto-char end)
                                       (c-go-list-forward)
                                       (point)
                                       );progn
                                 );c-indent-line-or-region
        );progn
       );if
     );progn
    );let*
  );defun

(defun .c-brace (arg)
  "insert a {} /* end ... */ block; if set, around a region\n\nif called with a prefix argument, just insert a normal {"
  (interactive "P")
  (if arg
      (insert "{")
    (if (use-region-p)
        (.c-brace-backend (region-beginning) (region-end) "/*" "*/")
      (.c-brace-backend (point) (point) "/*" "*/")
      );if
    );if
  );defun

(defun .perl-brace (arg)
  "insert a {} # end ... block; if set, around a region\n\nif called with a prefix argument, just insert a normal {"
  (interactive "P")
  (if arg
      (insert "{")
    (if (use-region-p)
        (.c-brace-backend (region-beginning) (region-end) "#" "")
      (.c-brace-backend (point) (point) "#" "")
      );if
    );if
  );defun

(defun .c-for-loop (a b c)
  "insert a for loop"
  (interactive "Mindex type (long): \nMindex name (i): \nMupper limit: ")
  (let ((aa (if (string-equal a "") "long" a))
        (bb (if (string-equal b "") "i" b))
        (cc (if (string-equal c "") (error "empty argument") c))
        );(
    (insert (concat "for(" aa " " bb " = 0; " bb " < " cc "; " bb "++)"))
    (c-indent-line-or-region)
    );let
  );defun

(defun .c-for-it-loop (a b c)
  "insert a for loop"
  (interactive "Mindex type (vector<long>): \nMindex name (IT): \nMcontainer: ")
  (let ((aa (if (string-equal a "") "vector<long>" a))
        (bb (if (string-equal b "") "IT" b))
        (cc (if (string-equal c "") (error "empty argument") c))
        );(
    (insert (concat "for(" aa "::iterator " bb " = " cc "begin(); " bb " != " cc "end(); " bb "++)"))
    (c-indent-line-or-region)
    );let
  );defun

(defun copy-lines-count (beg end)
  "count number of lines in region and copy to kill ring"
  (interactive "r")
  (let ((nlines (int-to-string (count-lines beg end))))
    (message nlines)
    (kill-new nlines)
    );let
  );defun

(defun recenter-top-bottom (arg)
  "move current line to window center, center-top, top, and bottom, successively;\n\nif called with prefix argument, behave like `recenter'"
  (interactive "P")
  (if arg
      (recenter arg)
    (let ((target-zero	(current-line))
          (target-one	(/ (window-height) 2))
          (target-two	(/ (window-height) 4))
          (target-three	0)
          (target-four	(- (window-height) 2))
          (target-five	(/ (* 3 (window-height)) 4))
          );(
      (cond 
        ((= target-zero target-one)	(recenter target-two))
        ((= target-zero target-two)	(recenter target-three))
        ((= target-zero target-three)	(recenter target-four))
        ((= target-zero target-four)	(recenter target-five))
        (t				(recenter target-one))
        );cond
      );let
    );if
  );defun

(defun .tex-maths ()
  "Insert $$ and position point"
  (interactive)
  (insert "$$")
  (goto-char (- (point) 1))
  );defun

(defun .tex-label ()
  "Insert \label{} and position point"
  (interactive)
  (insert "\\label{}")
  (goto-char (- (point) 1))
  );defun

(defun .tex-ref ()
  "Insert ~\ref{} and position point"
  (interactive)
  (insert "~\\ref{}")
  (goto-char (- (point) 1))
  );defun

(defun .tex-pageref ()
  "Insert ~\pageref{} and position point"
  (interactive)
  (insert "~\\pageref{}")
  (goto-char (- (point) 1))
  );defun

(defun .tex-cite ()
  "Insert ~\cite{} and position point"
  (interactive)
  (insert "~\\cite{}")
  (goto-char (- (point) 1))
  );defun

(defun .tex-emph ()
  "Insert \emph{} and position point"
  (interactive)
  (insert "\\emph{}")
  (goto-char (- (point) 1))
  );defun

(defun .tex-emphindex ()
  "Insert \emphindex{} and position point"
  (interactive)
  (insert "\\emphindex{}")
  (goto-char (- (point) 1))
  );defun

(defun .eval (beg end)
  "evaluate region and copy evaluation output to kill ring"
  (interactive "r")
  (let ((tmp-buffer (get-buffer-create "*.eval*"))
        );(
    
    (eval-region beg end tmp-buffer)
    (set-buffer tmp-buffer)
    (kill-region 2 (buffer-size tmp-buffer))
    (kill-buffer tmp-buffer)
    );let
  );defun

(defun .tex-heading-forward ()
  "Advance to next heading definition"
  (interactive)
  (move-end-of-line nil)
  (search-forward-regexp "^.\\(chapter\\|section\\|subsection\\|subsubsection\\)" (point-max) t)
  (move-beginning-of-line nil)
  );defun

(defun .tex-heading-backward ()
  "Advance to next heading definition"
  (interactive)
  (move-beginning-of-line nil)
  (search-backward-regexp "^.\\(chapter\\|section\\|subsection\\|subsubsection\\)" (point-min) t)
  (move-beginning-of-line nil)
  );defun

(defun .ecb-activate ()
  (interactive)
  ;; (if ecb-minor-mode
  ;;     (setq display-buffer-alist '(("\\*svn-.*\\*" display-buffer-in-satellite)))
  ;;   (setq display-buffer-alist nil)
  ;;   );if
  (ecb-activate)
  );defun

(defun typographic-english () (interactive)
  (setq typographic-open-quote		"“")
  (setq typographic-close-quote		"”")
  (setq typographic-open-single		"‘")
  (setq typographic-close-single	"’")
  );defun

(defun typographic-german-1 () (interactive)
  (setq typographic-open-quote		"„")
  (setq typographic-close-quote		"“")
  (setq typographic-open-single		"’")
  (setq typographic-close-single	"’")
  );defun

(defun typographic-german-2 () (interactive)
  (setq typographic-open-quote		"»")
  (setq typographic-close-quote		"«")
  (setq typographic-open-single		"’")
  (setq typographic-close-single	"’")
  );defun

(defun typographic-spanish () (interactive)
  (setq typographic-open-quote		"—")
  (setq typographic-close-quote		"—")
  (setq typographic-open-single		"«")
  (setq typographic-close-single	"»")
  );defun

(defun typographic-insert-quote (arg)
  "Insert the appropriate typographic quote marks.
Inserts the value of `typographic-open-quote' or `typographic-close-quote'
depending on the context.  With prefix argument, always
inserts \" characters."
  (interactive "*P")
  (if arg 
      (insert "\"")
    (insert (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\s))
		typographic-open-quote
              typographic-close-quote
              );if
            );insert
    );if
  );defun

(defun typographic-insert-single-quote (arg)
  "Insert the appropriate typographic quote marks.
Inserts the value of `typographic-open-single' or `typographic-close-single'
depending on the context.  With prefix argument, always
inserts \" characters."
  (interactive "*P")
  (if arg 
      (insert "'")
    (insert (if (memq (char-syntax (preceding-char)) '(?\( ?> ?\s))
		typographic-open-single
              typographic-close-single
              );if
            );insert
    );if
  );defun

(defun open-with ()
  "open current buffer's file with a command"
  (interactive)
  (if buffer-file-name
      (let ((external-app (read-string "Open buffer with: " "gedit")))
        (.shell-command (concat external-app " " buffer-file-name))
        );let
    (error "buffer not associated to file")
    );
  );

(defun my-notes ()
  "open or switch to my notes"
  (interactive)
  (if (get-buffer "*notes*")
      (progn
       (switch-to-buffer "*notes*")
       (find-file (buffer-file-name))
       (toggle-read-only 1)
       );progn
    (let ((notes-file (read-file-name "Load notes file: ")))
      (find-file notes-file)
      (rename-buffer "*notes*")
      (toggle-read-only 1)
      );let
    );if
  );defun


;;;;; my clips ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(global-unset-key (kbd "C-x C-c"))
(global-unset-key (kbd "C-x <left>"))
(global-unset-key (kbd "C-x <right>"))
(global-unset-key (kbd "C-x C-<left>"))
(global-unset-key (kbd "C-x C-<right>"))
(global-unset-key (kbd "C-x C-<down>"))
(global-unset-key (kbd "C-x C-<up>"))

(global-set-key (kbd "M-v")		'(lambda () (interactive) (error "Tis not Windows, you bastard!")))
(global-set-key (kbd "C-v")		'(lambda () (interactive) (error "Tis not Windows, you bastard!")))

(global-set-key (kbd "C-x C-j")		'clone-any-buffer)
(global-set-key (kbd "M-z")		'.shell-command)
(global-set-key (kbd "C-x <f8>")	'dired-jump)
(global-set-key (kbd "C-x <f9>")	'magit-status)
(global-set-key (kbd "C-x <f10>")	'my-notes)
(global-set-key (kbd "C-x <f11>")	'.eshell)
(global-set-key (kbd "C-x &")		'call-last-kbd-macro)
(global-set-key (kbd "M-=")		'copy-lines-count)
(global-set-key (kbd "C-c <f9>")	'.ecb-activate)
(global-set-key (kbd "C-x l")		'goto-line)
(global-set-key (kbd "C-x <f12>")	'iresize-mode)
(global-set-key (kbd "C-x \"")		'typographic-mode)
(global-set-key (kbd "C-c l")		'org-store-link)
(global-set-key (kbd "C-x C-c C-x C-c")	'save-buffers-kill-emacs)
(global-set-key (kbd "M-<down>")	'scroll-down-vi-style)
(global-set-key (kbd "M-<up>")		'scroll-up-vi-style)
(global-set-key (kbd "M-n")		'scroll-down-vi-style)
(global-set-key (kbd "M-p")		'scroll-up-vi-style)
(global-set-key (kbd "M-s")		'set-selective-display)
(global-set-key (kbd "C-x C-b")		'switch-to-buffer)
(global-set-key (kbd "C-x b")		'switch-to-buffer)
(global-set-key (kbd "C-x C-q")		'toggle-read-only)

(global-set-key (kbd "C-x c")		'record-current-position)
(global-set-key (kbd "C-x j")		'goto-last-position)
(global-set-key (kbd "C-x C-n")		'cycle-registers-forward)
(global-set-key (kbd "C-x C-p")		'cycle-registers-backwards)

(global-set-key (kbd "C-x <f2>")	'diff-buffer-with-file)

(global-set-key (kbd "<f2>")		'(lambda () (interactive) (revert-buffer nil t t)))
(global-set-key (kbd "<f3>")		'other-window)
(global-set-key (kbd "<f4>")		'cross-split)

(global-set-key (kbd "<f5>")		'hsplit-window-mirror)
(global-set-key (kbd "<f6>")		'split-window-mirror)
(global-set-key (kbd "<f7>")		'(lambda () (interactive) (hsplit-window-ratio 1 1)))
(global-set-key (kbd "<f8>")		'(lambda () (interactive) (hsplit-window-ratio split-hor-large split-hor-small)))

(global-set-key (kbd "<f9>")		'cross-split-large)
(global-set-key (kbd "<f11>")		'(lambda () (interactive) (split-window-ratio 1 1)))
(global-set-key (kbd "<f12>")		'(lambda () (interactive) (split-window-ratio split-ver-large split-ver-small)))

(global-set-key (kbd "C-x 6")		'hs-hide-block)
(global-set-key (kbd "C-x 7")		'hs-show-block)
(global-set-key (kbd "C-x 9")		'hs-show-all)

(global-set-key (kbd "C-x p")		'other-window-back)

(global-set-key (kbd "C-<left>")	'bs-show)
(global-set-key (kbd "C-<right>")	'bs-show)
(global-set-key (kbd "C-<up>")		'unbury-buffer)
(global-set-key (kbd "C-<down>")	'bury-buffer)

(global-set-key (kbd "S-<left>")	'windmove-left)
(global-set-key (kbd "S-<right>")	'windmove-right)
(global-set-key (kbd "S-<up>")		'windmove-up)
(global-set-key (kbd "S-<down>")	'windmove-down)
(global-set-key (kbd "<select>")	'windmove-up)

(global-set-key (kbd "C-x <left>")	'buf-move-left)
(global-set-key (kbd "C-x <right>")	'buf-move-right)
(global-set-key (kbd "C-x <up>")	'buf-move-up)
(global-set-key (kbd "C-x <down>")	'buf-move-down)

(global-set-key (kbd "C-^ C-w")		'kill-rectangle)
(global-set-key (kbd "C-^ C-y")		'yank-rectangle)
(global-set-key (kbd "C-^ C-k")		'delete-rectangle)
(global-set-key (kbd "C-^ C-o")		'open-rectangle)
(global-set-key (kbd "C-^ C-q")		'copy-rectangle-to-register)
(global-set-key (kbd "C-^ C-s")		'string-rectangle)
(global-set-key (kbd "C-^ C-i")		'string-insert-rectangle)

(define-prefix-command 'C-h-C-y-map)
(global-set-key (kbd "C-h C-y")		'C-h-C-y-map)
(global-set-key (kbd "C-h C-u")		'other-frame-back)
(global-set-key (kbd "C-h C-j")		'other-frame)
(global-set-key (kbd "C-h C-y C-c")	'make-frame-command)
(global-set-key (kbd "C-h C-y C-k")	'delete-frame)
(global-set-key (kbd "C-h C-y C-a")	'set-frame-name)
(global-set-key (kbd "C-h C-y C-n")	'select-frame-by-name)

(global-set-key (kbd "M-r")		'move-line-down)
(global-set-key (kbd "M-t")		'move-line-up)
(global-set-key (kbd "C-t")		'join-line)

(global-set-key (kbd "M-g c")		'compile)
(global-set-key (kbd "M-g r")		'recompile)
(global-set-key (kbd "M-g k")		'kill-compilation)

(define-prefix-command 'smerge-map)
(global-set-key (kbd "M-o")		'smerge-map)
(global-set-key (kbd "M-o M-m")		'smerge-keep-mine)
(global-set-key (kbd "M-o M-o")		'smerge-keep-other)
(global-set-key (kbd "M-o M-a")		'smerge-keep-all)
(global-set-key (kbd "M-o M-p")		'smerge-prev)
(global-set-key (kbd "M-o M-n")		'smerge-next)





;;;;; menu-bar enhancements ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'easymenu)

(easy-menu-add-item global-map '("menu-bar")
                    [ "date-in-menu-bar"
                      (lambda () "Insert current time string" (interactive) (insert (format-time-string "%a %b %e %k:%M:%S %Z %Y")))
                      :key-sequence nil
                      :label (concat " "
                                     (propertize (format-time-string " %a %b %e %k:%M:%S %Z %Y ") 'face 'bold)
                                     " "
                                     );concat
                      :help "Show current time in menubar; insert current time string into active buffer"
                      ];[
                    ;file
                    );easy-menu-add-item





;;;;; inits ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(enhance-frame-name)
(typographic-english)