Source

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
   :PROPERTIES:
   :ID:       740102DF-6648-4475-AAC7-70BA719F2B17
   :END:
#+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)
     (slime-setup)

  
  (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)
        (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)
  
  (pc-selection-mode)
  
  (setq initial-frame-alist '((top . 50) 
                              (left . 200) 
                              (width . 120) 
                              (height . 45)))
  
  ;; clean out buffers except shell, agenda and org
  (defun restart ()
    (interactive)
    (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
  '(("#[abcdef[:digit:]]\\{6\\}"
     (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)
#+end_src

** Smex
   :PROPERTIES:
   :ID:       493DBB10-F3EB-4B6B-BDCA-3AFB4721C4D6
   :END:
#+begin_src emacs-lisp
(require 'smex)
(smex-initialize)

(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)
#+end_src

** Colors
   :PROPERTIES:
   :ID:       CBAA8DA5-354D-42C9-A61B-9C9CCEB46EC2
   :END:
#+begin_src emacs-lisp
(set-default-font "Bitstream Vera Sans Mono-12")

;; color theme
(require 'color-theme)
(color-theme-initialize)

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

** Highlight Line
   :PROPERTIES:
   :ID:       90C3F79D-6A4F-4192-A105-78C5BCF49D17
   :END:
#+begin_src emacs-lisp
(require 'highlight-current-line)
 
(custom-set-variables
 '(highlight-current-line-globally t nil (highlight-current-line)))
 
(custom-set-faces
 '(highlight-current-line-face ((t (:background "#333333")))))
 
                                        ; good: 4f2f42
                                        ; midnight blue
                                        ; saddle brown
(cond (window-system
       (custom-set-faces
        '(highlight-current-line-face ((t (:background "#333333")))))))
#+end_src

** Git
   :PROPERTIES:
   :ID:       A9AB81CF-8414-44C1-8819-99AEB2E3768C
   :END:
#+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)
#+end_src
** Browse Kill Ring
   :PROPERTIES:
   :ID:       F9550B3D-79B1-4CB7-86C4-516680E0D4EE
   :END:
#+begin_src emacs-lisp
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
#+end_src
** Lorem Ipsum
   :PROPERTIES:
   :ID:       BAE663A0-06B0-4EDB-9055-182409F94333
   :END:
#+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")))
#+end_src
** Textmate
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/vendor/textmate.el")
(require 'textmate)
(textmate-mode)
#+end_src
** PeepOpen
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/vendor/")
(require 'peepopen)
#+end_src
** Shell
   :PROPERTIES:
   :ID:       EA8D1DFE-7F22-461F-8A5C-109F57F2920C
   :END:
#+begin_src emacs-lisp
;; multi-term
(require 'multi-term)
(multi-term-keystroke-setup) 
(setq multi-term-program "/bin/bash") 
#+end_src
** 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)))
#+end_src
** Restructured Text
   :PROPERTIES:
   :ID:       F10D7F4E-64F5-4437-BAE8-790F34C8F614
   :END:
#+begin_src emacs-lisp
(setq auto-mode-alist
      (append '(("\\.txt$" . rst-mode)
                ("\\.rst$" . rst-mode)
                ("\\.rest$" . rst-mode)) auto-mode-alist))
#+end_src
** Quiting Emacs
   :PROPERTIES:
   :ID:       DD878440-AB0B-479A-B7B8-6B999D6075B3
   :END:
#+begin_src emacs-lisp
(setq confirm-kill-emacs
      (lambda (e)
        (y-or-n-p-with-timeout
         "Really exit Emacs (automatically exits in 5 secs)? " 5 t)))

(server-start)
#+end_src
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.