emacs /

#+TITLE: Config Main
#+OPTIONS: toc:nil num:nil ^:nil

* Main Config
Support for anything minor and requires that should be global

** Requires
#+begin_src emacs-lisp
  (require 'yasnippet)
  (require 'uniquify)
  (require 'grep-o-matic)
  (require 'mercurial)
  (require 'auto-complete)
  (require 'dpaste)
  (require 'flymake)
  (require 'dpastede)
  (require 'font-lock)
  (require 'gist)
  (require 'growl)
  (require 'nav)
  (require 'saveplace)
  (require 'textile-mode)
  (require 'vernacular-time)
  (require 'todochiku)
  (blink-cursor-mode nil)
  ;; IDO rules
  (require 'ido)
  (ido-mode t)
  (setq ido-enable-flex-matching t)
  (toggle-scroll-bar -1)
  ;; no splash screen
  (setq inhibit-startup-message t)
  ;; use UTF-8
  (prefer-coding-system 'utf-8)
  ; Lines shouldn't be longer than 79 chars
  (setq fill-column 72)
  ;; allow remote editing through transmit
  (setq backup-by-copying t) 
  ;; make pretty
  (global-font-lock-mode 1)
  ;; remove the beeping, it drives me nuts
  (setq ring-bell-function 'ignore)
  ;; shows current selected region
  (setq-default transient-mark-mode t)
  ;; indent via spaces not tabs
  (setq-default indent-tabs-mode nil)
  ;; titlebar = buffer unless filename
  (setq frame-title-format '(buffer-file-name "%f" ("%b")))
  ;; show paired parenthasis
  (show-paren-mode 1)
  ;; TAB => 4*'\b'
  (setq default-tab-width 4)
  ;; line numbers
  (global-linum-mode 1)
  (setq column-number-mode  t)
  ;; turn off tool bar, and menu bar
  (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
  (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
  ;; log the time of the things I have done
  (setq-default org-log-done t) 
  ;; get rid of yes-or-no questions - y or n is enough
  (defalias 'yes-or-no-p 'y-or-n-p)
  (setq uniquify-buffer-name-style 'reverse)
  (setq uniquify-separator "|")
  (setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
  (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers
  ;; disable line wrap
  (setq default-truncate-lines nil)
  ;; make side by side buffers function the same as the main window
  (setq truncate-partial-width-windows nil)
  ;; bury the buffer
  (global-set-key [f8] 'bury-buffer)
  ;; ibuffer key
  (global-set-key (kbd "C-;") 'ibuffer)
  ;; windmove bindings
  (when (fboundp 'windmove-default-keybindings)
  ;; Place Backup Files in Specific Directory
  ;; Enable backup files.
  (setq make-backup-files t)
  ;; Enable versioning with default values (keep five last versions, I think!)
  (setq version-control t)
  ;; Save all backup file in this directory.
  (setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
  ; stolen from
  (defvar user-temporary-file-directory
    (concat temporary-file-directory user-login-name "/"))
  (make-directory user-temporary-file-directory t)
  (setq backup-by-copying t)
  (setq backup-directory-alist
        `(("." . ,user-temporary-file-directory)
          (,tramp-file-name-regexp nil)))
  (setq auto-save-list-file-prefix
        (concat user-temporary-file-directory ".auto-saves-"))
  (setq auto-save-file-name-transforms
        `((".*" ,user-temporary-file-directory t)))
  (setq delete-old-versions t)
  (setq initial-frame-alist '((top . 50) 
                              (left . 200) 
                              (width . 120) 
                              (height . 45)))
  ;; clean out buffers except shell, agenda and org
  (defun restart ()
    (let ((list (buffer-list)))
      (while list
        (let* ((buffer (car list))
               (name (buffer-name buffer)))
          (and (not (string-equal name "*shell*"))
               (not (string-equal name "*Org Agenda*"))
               (not (string-equal name ""))
               (kill-buffer buffer)))
        (setq list (cdr list)))))
  ;; SavePlace
  (setq save-place-file "~/saveplace") ;; keep my ~/ clean
  (setq-default save-place t)                   ;; activate it for all buffers
  ; CSS color values colored by themselves
  (defvar hexcolour-keywords
     (0 (put-text-property
         (match-beginning 0)
         (match-end 0)
         'face (list :background 
                     (match-string-no-properties 0)))))))
  (defun hexcolour-add-to-font-lock ()
  (font-lock-add-keywords nil hexcolour-keywords))
  (add-hook 'css-mode-hook 'hexcolour-add-to-font-lock)
  ;; Change modifier key to meta
  (setq mac-command-modifier 'meta)

** Smex
#+begin_src emacs-lisp
(require 'smex)

(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
(global-set-key (kbd "C-c M-x") 'smex-update-and-run)
;; This is your old M-x.
(global-set-key (kbd "C-c C-x M-x") 'execute-extended-command)

** Colors
#+begin_src emacs-lisp
;; color theme
(require 'color-theme)

(load-file "~/.emacs.d/src/color-theme/zenburn.el")
(set-face-background 'modeline "DarkRed")

** Highlight Line
#+begin_src emacs-lisp
(require 'highlight-current-line)
 '(highlight-current-line-globally t nil (highlight-current-line)))
 '(highlight-current-line-face ((t (:background "#333333")))))
                                        ; good: 4f2f42
                                        ; midnight blue
                                        ; saddle brown
(cond (window-system
        '(highlight-current-line-face ((t (:background "#333333")))))))

** Git
#+begin_src emacs-lisp
;; Add in git version control hooks
(require 'vc-git)
(when (featurep 'vcgit) (add-to-list 'vc-handled-backends 'git))
(require 'git)
(autoload 'git-blame-mode "git-blame"
  "Minor mode for incremental blame for git" t)
** Browse Kill Ring
#+begin_src emacs-lisp
(require 'browse-kill-ring)
** Lorem Ipsum
#+begin_src emacs-lisp
;; Add in lorem-ipsum
(require 'lorem-ipsum)
(add-hook 'sgml-mode-hook (lambda ()
			    (setq Lorem-ipsum-paragraph-separator "<br><br>\n"
				  Lorem-ipsum-sentence-separator "&nbsp;&nbsp;"
				  Lorem-ipsum-list-beginning "<ul>\n"
				  Lorem-ipsum-list-bullet "<li>"
				  Lorem-ipsum-list-item-end "</li>\n"
				  Lorem-ipsum-list-end "</ul>\n")))
** Shell
#+begin_src emacs-lisp
;; multi-term
(require 'multi-term)
(setq multi-term-program "/bin/bash") 
** Restructured Text
#+begin_src emacs-lisp
(setq auto-mode-alist
      (append '(("\\.txt$" . rst-mode)
                ("\\.rst$" . rst-mode)
                ("\\.rest$" . rst-mode)) auto-mode-alist))
** Quiting Emacs
#+begin_src emacs-lisp
(setq confirm-kill-emacs
      (lambda (e)
         "Really exit Emacs (automatically exits in 5 secs)? " 5 t)))