Here goes my mighty dot-emacs file. The mighty key-bindings are courtesy of Andre Polonsky – thanks for that mate!!

(menu-bar-mode -1)
(toggle-scroll-bar -1)
(tool-bar-mode -1)
(blink-cursor-mode 0) ; don't blink cursor

(transient-mark-mode t) ; make the current 'selection' visible
(delete-selection-mode t) ; delete the selection area with a keypress
(setq search-highlight t ; highlight when searching...
query-replace-highlight t) ; ...and replacing
(fset 'yes-or-no-p 'y-or-n-p) ; enable one letter y/n answers to yes/no

;; don't show startup messages
(setq inhibit-startup-message t
inhibit-startup-echo-area-message t)

;; set frame title / icon title using filename or buffername and current date
;; little trick to replace /home/foo with ~ (www.emacswiki.org/cgi-bin/wiki/ShadyTrees)
(defun djcb-title-format ()
(if buffer-file-name
(replace-regexp-in-string "\\\\" "/"
(replace-regexp-in-string (regexp-quote (getenv "HOME")) "~"
(convert-standard-filename buffer-file-name)))

frame-title-format '(:eval (concat (url-get-normalized-date) " " (djcb-title-format)))
icon-title-format '(:eval (concat "emacs:" (djcb-title-format))))

;; Backups
(setq make-backup-files t ; do make backups
backup-by-copying t ; and copy them ...
backup-directory-alist '(("." . "~/.emacs.d/backup/")) ; ... here
version-control t
kept-new-versions 2
kept-old-versions 5
delete-old-versions t)

;; full-screen mode
;; based on http://www.emacswiki.org/cgi-bin/wiki/WriteRoom
;; toggle full screen with custom keybinding; require 'wmctrl'
;; http://stevenpoole.net/blog/goodbye-cruel-word/
(defun djcb-full-screen-toggle ()
(shell-command "wmctrl -r :ACTIVE: -b toggle,fullscreen"))

(defun djcb-maximize-screen-toggle ()
(shell-command "wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz"))

;; change caps- to hyper-key
(shell-command "xmodmap -e 'remove lock = Caps_Lock' && xmodmap -e 'keycode 66 = Hyper_L' && xmodmap -e 'add mod3 = Hyper_L'")

;; org-mode / remember-mode
;; we use org-mode as the backend for remember
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))

(setq org-directory "~/.emacs.d/org/")
(setq org-default-notes-file (concat org-directory "/notes.org")
org-agenda-files (list (expand-file-name org-directory)
(concat (expand-file-name org-directory) "/todo.org"))
org-agenda-include-diary t)

;; org-latex.el
(autoload 'org-export-as-latex-batch "org-export-latex")
(autoload 'org-export-as-latex-to-buffer "org-export-latex"
"Call `org-exort-as-latex` with output to a temporary buffer" t)
(autoload 'org-replace-region-by-latex "org-export-latex"
"Replace the region from BEG to END with its LaTeX export." t)
(autoload 'org-export-region-as-latex "org-export-latex"
"Convert region from BEG to END in `org-mode' buffer to LaTeX." t)
(autoload 'org-export-as-latex "org-export-latex"
"Export current buffer to a LaTeX file." t)

;; start with my todo-list
(find-file "~/.emacs.d/org/todo.org")

;; Custom Colors from Dirk Binnema
; (set-background-color "black")
; (set-foreground-color "lightblue")
; (set-face-foreground 'font-lock-string-face "#123467") ;
; (set-face-foreground 'font-lock-comment-face "#aaaaaa") ;
; (make-face-italic 'font-lock-comment-face)
; (set-face-foreground 'font-lock-keyword-face "lemonchiffon") ;
; (make-face-bold 'font-lock-keyword-face)
; (set-face-foreground 'font-lock-string-face "#ffffff") ;
; (set-face-foreground 'font-lock-preprocessor-face "red") ;
; (set-face-foreground 'font-lock-constant-face "green") ;
; (set-face-foreground 'font-lock-type-face "lightblue")
; (make-face-bold 'font-lock-type-face)
; (set-face-foreground 'font-lock-function-name-face "darkcyan")
; (set-face-foreground 'font-lock-variable-name-face "darkgreen")
; (set-face-foreground 'font-lock-warning-face "yellow")
; (set-face-underline 'font-lock-warning-face "red")
(set-face-background 'region "#777777")

(set-face-foreground 'mode-line "#777777")
(set-face-background 'mode-line "#333333")

;; The Sane Emacs Keybindings

; I included the bindings directly into my .emacs, so the load-file is no longer necessary
;(load-file "~/.emacs.d/bindings.el")

;; auxiliary functions

(defun DefGlobKey (k b)
(define-key global-map (read-kbd-macro k) b) )
(defun DefSrchKey (k b)
(define-key isearch-mode-map (read-kbd-macro k) b) )

(defun other-other-window ()
(other-window -1))
(defun yank-push ()
(yank-pop -1))
(defun move-n-lines (n)
(scroll-up n))

(setq scroll-preserve-screen-position t)

(defun scroll-one-left ()
(scroll-left -1))
(defun scroll-one-right ()
(scroll-right -1))
(defun scroll-one-up ()
(move-n-lines -1))
(defun scroll-one-down ()
(move-n-lines 1))
(defun page-up ()
(move-n-lines (- 1 (window-height))))
(defun page-down ()
(move-n-lines (- (window-height) 1)))

;; basic movement

(DefGlobKey "H-j" 'backward-char)
(DefGlobKey "H-l" 'forward-char)
(DefGlobKey "H-i" 'previous-line)
(DefGlobKey "H-k" 'next-line)
(DefGlobKey "H-u" 'beginning-of-line)
(DefGlobKey "H-o" 'end-of-line)

(DefGlobKey "H-M-j" 'backward-word)
(DefGlobKey "H-M-l" 'forward-word)
(DefGlobKey "H-M-i" 'backward-paragraph)
(DefGlobKey "H-M-k" 'forward-paragraph)
(DefGlobKey "H-M-u" 'page-up)
(DefGlobKey "H-M-o" 'page-down)

(DefGlobKey "H-J" 'scroll-one-left)
(DefGlobKey "H-L" 'scroll-one-right)
(DefGlobKey "H-I" 'scroll-one-up)
(DefGlobKey "H-K" 'scroll-one-down)
(DefGlobKey "H-U" 'beginning-of-buffer)
(DefGlobKey "H-O" 'end-of-buffer)

(DefGlobKey "H-." 'isearch-forward)
(DefGlobKey "H-m" 'isearch-backward)
(DefGlobKey "H-M-." 'isearch-forward-regexp)
(DefGlobKey "H-M-m" 'isearch-backward-regexp)

(DefGlobKey "H-M-," 'recenter)

;; basic editing

(DefGlobKey "H-æ" 'advertised-undo)
(DefGlobKey "H-M-æ" 'redo)
(DefGlobKey "H-ø" 'backward-delete-char-untabify)
(DefGlobKey "H-M-ø" 'delete-char)
(DefGlobKey "H-p" 'kill-whole-line)
(DefGlobKey "H-M-p" 'kill-line)

(DefGlobKey "H-" 'set-mark-command)
(DefGlobKey "H-M-" 'exchange-point-and-mark)
(DefGlobKey "H-M-å" 'mark-paragraph)
(DefGlobKey "H-å" 'mark-whole-buffer)

(DefGlobKey "H-M-h" 'kill-region)
(DefGlobKey "H-h" 'kill-ring-save)
(DefGlobKey "H-y" 'yank)
(DefGlobKey "H-M-y" 'yank-pop)
(DefGlobKey "H-Y" 'yank-push)
(DefGlobKey "H-n" 'replace-string)
(DefGlobKey "H-M-n" 'replace-regexp)

(DefGlobKey "H-_" 'fill-region)

;; basic control

(DefGlobKey "H-q" 'save-buffer)
(DefGlobKey "H-M-q" 'write-file)
(DefGlobKey "H-w" 'find-file)
(DefGlobKey "H-r" 'switch-to-buffer)
(DefGlobKey "H-M-r" 'next-buffer)
(DefGlobKey "H-e" 'kill-this-buffer)
(DefGlobKey "H-M-e" 'save-buffers-kill-emacs)

(DefGlobKey "M-E" 'kill-this-buffer)
(DefGlobKey "M-J" 'previous-buffer)
(DefGlobKey "M-L" 'next-buffer)

(DefGlobKey "H-M-s" 'ess-eval-buffer-and-go)
(DefGlobKey "H-s" 'ess-eval-region-and-go)
(DefGlobKey "H-t" 'tex-compile)
(DefGlobKey "H-a" 'term)
(DefGlobKey "H-A" 'shell)

(DefGlobKey "H-F" 'djcb-maximize-screen-toggle)
(DefGlobKey "H-f" 'djcb-full-screen-toggle)
(DefGlobKey "H-M-z" 'split-window-horizontally)
(DefGlobKey "H-z" 'split-window-vertically)
(DefGlobKey "H-x" 'delete-window)
(DefGlobKey "H-M-x" 'delete-other-windows)
(define-key global-map [H-tab] 'other-window)
(define-key global-map [H-M-tab] 'other-other-window)

;; search mode

(DefSrchKey "H-m" 'isearch-repeat-backward)
(DefSrchKey "H-." 'isearch-repeat-forward)
(DefSrchKey "H-M-m" 'isearch-repeat-backward)
(DefSrchKey "H-M-." 'isearch-repeat-forward)
(DefSrchKey "H-," 'isearch-query-replace)
(DefSrchKey "H-M-," 'isearch-query-replace-regexp)

(DefSrchKey "H-/" 'isearch-complete)
(DefSrchKey "H-M-/" 'isearch-toggle-case-fold)
(DefSrchKey "H-?" 'isearch-toggle-regexp)

(DefSrchKey "H-n" 'isearch-cancel)
(DefSrchKey "H-M-n" 'isearch-exit)

;; other features

;(DefGlobKey "H-f" 'describe-key)
;(DefGlobKey "H-M-f" 'describe-function)

;; I do not use Lisp yet, but constantly get into the evaluation queue, so I comment away these
;(DefGlobKey "H-" 'eval-defun)
;(DefGlobKey "H-M-" 'eval-region)


One thought on “.emacs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s