1. Greg Newman
  2. emacs


emacs / config.org

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

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

** Requires
   :ID:       740102DF-6648-4475-AAC7-70BA719F2B17
#+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)

  ;; Slime configuration
  (setq inferior-lisp-program "/usr/local/bin/sbcl") ; your Lisp system
     (add-to-list 'load-path "~/.slime")  ; your SLIME directory
     (require 'slime)

  (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 http://github.com/febuiles/dotemacs/tree/master/temp_files.el
  (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 tramp-default-method "ssh")

  (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 "greg.org"))
               (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
  ; http://xahlee.org/emacs/emacs_html.html
  (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)

  (global-set-key (kbd "M-RET") 'ns-toggle-fullscreen)

** Smex
   :ID:       493DBB10-F3EB-4B6B-BDCA-3AFB4721C4D6
#+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
   :ID:       CBAA8DA5-354D-42C9-A61B-9C9CCEB46EC2
#+begin_src emacs-lisp
(set-default-font "Bitstream Vera Sans Mono-12")

;; color theme
(require 'color-theme)

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

** Highlight Line
   :ID:       90C3F79D-6A4F-4192-A105-78C5BCF49D17
#+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
   :ID:       A9AB81CF-8414-44C1-8819-99AEB2E3768C
#+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
   :ID:       F9550B3D-79B1-4CB7-86C4-516680E0D4EE
#+begin_src emacs-lisp
(require 'browse-kill-ring)
** Lorem Ipsum
   :ID:       BAE663A0-06B0-4EDB-9055-182409F94333
#+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")))
** Textmate
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/vendor/textmate.el")
(require 'textmate)
** PeepOpen
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/vendor/")
(require 'peepopen)
** Shell
   :ID:       EA8D1DFE-7F22-461F-8A5C-109F57F2920C
#+begin_src emacs-lisp
;; multi-term
(require 'multi-term)
(setq multi-term-program "/bin/bash") 
** XeLaTex
#+begin_src emacs-lisp
;;set xetex mode in tex/latex
(add-hook 'LaTeX-mode-hook (lambda()
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(setq TeX-command-default "XeLaTeX")
(setq TeX-save-query nil)
(setq TeX-show-compilation t)))
** Restructured Text
   :ID:       F10D7F4E-64F5-4437-BAE8-790F34C8F614
#+begin_src emacs-lisp
(setq auto-mode-alist
      (append '(("\\.txt$" . rst-mode)
                ("\\.rst$" . rst-mode)
                ("\\.rest$" . rst-mode)) auto-mode-alist))
** Quiting Emacs
   :ID:       DD878440-AB0B-479A-B7B8-6B999D6075B3
#+begin_src emacs-lisp
(setq confirm-kill-emacs
      (lambda (e)
         "Really exit Emacs (automatically exits in 5 secs)? " 5 t)))