init.el
changeset 31 27930e0310d6
parent 30 5aa1ceff049d
child 32 68b57950fa11
equal deleted inserted replaced
30:5aa1ceff049d 31:27930e0310d6
     1 ;; ~/.emacs.d/init.el (~/.emacs)
     1 ;; ~/.emacs.d/init.el (~/.emacs)
     2 ;; Luke Hoersten <[email protected]>
     2 ;; Luke Hoersten <[email protected]>
     3 
     3 
     4 ;; general
     4 ;;;; General
     5 (add-to-list 'load-path "~/.emacs.d")                  ; set default emacs load path
     5 (add-to-list 'load-path "~/.emacs.d")     ; set default emacs load path
     6 
     6 
     7 (setq-default
     7 (setq-default
     8  ediff-split-window-function 'split-window-horizontally ; diff horizontally
     8  ediff-split-window-function
     9  x-select-enable-clipboard t                            ; paste from X buffer
     9   'split-window-horizontally              ; diff horizontally
    10  inhibit-splash-screen t                                ; disable splash screen
    10  x-select-enable-clipboard t              ; paste from X buffer
    11  truncate-lines t                                       ; truncate, not wrap, lines
    11  inhibit-splash-screen t                  ; disable splash screen
    12  indent-tabs-mode nil                                   ; only uses spaces for indentation
    12  truncate-lines t                         ; truncate, not wrap, lines
    13  split-width-threshold 181)                             ; min width to split window horizontially
    13  indent-tabs-mode nil                     ; only uses spaces for indentation
       
    14  split-width-threshold 181)               ; min width to split window horizontially
    14 
    15 
    15 (put 'set-goal-column 'disabled nil)                    ; enable goal column setting
    16 (put 'set-goal-column 'disabled nil)      ; enable goal column setting
    16 (put 'narrow-to-region 'disabled nil)                   ; enable hiding
    17 (put 'narrow-to-region 'disabled nil)     ; enable hiding
    17 (put 'narrow-to-page 'disabled nil)
    18 (put 'narrow-to-page 'disabled nil)
    18 
    19 
    19 (menu-bar-mode -1)                                      ; remove menu bar
    20 (menu-bar-mode -1)                        ; remove menu bar
    20 (display-time-mode t)                                   ; show clock
    21 (display-time-mode t)                     ; show clock
    21 (column-number-mode t)                                  ; show column numbers
    22 (column-number-mode t)                    ; show column numbers
    22 (delete-selection-mode t)                               ; replace highlighted text
    23 (delete-selection-mode t)                 ; replace highlighted text
    23 (windmove-default-keybindings)                          ; move between windows with shift-arrow
    24 (windmove-default-keybindings)            ; move between windows with shift-arrow
    24 (ido-mode t)                                            ; file/buffer selector
    25 (fset 'yes-or-no-p 'y-or-n-p)             ; replace yes/no prompts
    25 (setq-default ido-enable-flex-matching t)               ; fuzzy matching for ido mode
       
    26 (add-hook 'text-mode-hook 'flyspell-mode t)             ; spellcheck text
       
    27 (add-hook 'text-mode-hook 'turn-on-auto-fill)           ; autofill text
       
    28 
    26 
    29 ;; whitespace
    27 ;;; coding
    30 (global-whitespace-mode t)                              ; show whitespace
    28 (which-func-mode t)                       ; show current function
    31 (add-hook 'before-save-hook 'whitespace-cleanup)        ; cleanup whitespace on exit
    29 (show-paren-mode t)                       ; show matching paren
    32 (setq-default
    30 (transient-mark-mode t)                   ; show highlighting
    33  whitespace-line-column 120                             ; column width
    31 (global-font-lock-mode t)                 ; syntax highlighting
    34  whitespace-style                                       ; whitespace to highlight
    32 (setq-default compile-command "scons ")   ; compile command
    35  '(trailing lines-tail empty indentation
    33 (global-set-key (kbd "C-c c") 'compile)   ; compile
    36             space-before-tab space-after-tab))
    34 (global-set-key (kbd "C-c r") 'recompile) ; recompile
       
    35 (global-set-key
       
    36  (kbd "C-c C-c")
       
    37  'comment-or-uncomment-region)            ; toggle region comment
    37 
    38 
    38 ;; coding
    39 ;;; X stuff
    39 (which-func-mode t)                                     ; show current function
    40 (if window-system
    40 (show-paren-mode t)                                     ; show matching paren
    41     (progn
    41 (transient-mark-mode t)                                 ; show highlighting
    42       (tool-bar-mode -1)      ; remove tool bar
    42 (global-font-lock-mode t)                               ; syntax highlighting
    43       (scroll-bar-mode -1)    ; remove scroll bar
    43 (setq-default compile-command "scons ")                 ; compile command
    44       (visual-line-mode t)    ; word wrap break on whitespace
    44 (global-set-key (kbd "C-c c") 'compile)                 ; compile
    45       (global-hl-line-mode t) ; highlight current line
    45 (global-set-key (kbd "C-c r") 'recompile)               ; recompile
       
    46 (global-set-key (kbd "C-c C-c")                         ; comment
       
    47                 'comment-or-uncomment-region)
       
    48 
    46 
    49 ;; line numbers
    47       ;; twilight theme
       
    48       (require 'color-theme)
       
    49       (load "color-theme-twilight")
       
    50       (color-theme-twilight)
       
    51       ))
       
    52 
       
    53 ;;; terminal
       
    54 (global-set-key (kbd "C-c s") 'eshell) ; start shell
       
    55 (add-hook 'eshell-mode-hook '(lambda ()
       
    56     (progn
       
    57       (setenv "PATH" "~/.cabal/bin:$PATH") ; haskell cabal
       
    58       (setenv "TERM" "emacs"))))           ; enable colors
       
    59 
       
    60 ;;; OS specific configs
       
    61 (cond
       
    62  ((string-match "linux" (emacs-version)) (require 'linux))
       
    63  ((string-match "darwin" (emacs-version)) (require 'darwin))
       
    64  )
       
    65 
       
    66 
       
    67 ;;;; Mode-Specific
       
    68 
       
    69 ;;; linum-mode - line numbers
    50 (mapc
    70 (mapc
    51  (lambda (x)
    71  (lambda (x)
    52    (add-hook x 'linum-mode))
    72    (add-hook x 'linum-mode))
    53  '(text-mode-hook
    73  '(text-mode-hook
    54    c-mode-common-hook
    74    c-mode-common-hook
    55    python-mode-hook
    75    python-mode-hook
    56    haskell-mode-hook
    76    haskell-mode-hook
    57    emacs-lisp-mode-hook))
    77    emacs-lisp-mode-hook))
    58 
    78 
    59 ;; X stuff
    79 ;;; text-mode
    60 (if window-system
    80 (add-hook 'text-mode-hook 'flyspell-mode t)             ; spellcheck text
    61     (progn
    81 (add-hook 'text-mode-hook 'turn-on-auto-fill)           ; autofill text
    62       (tool-bar-mode -1)    ; remove tool bar
       
    63       (scroll-bar-mode -1)  ; remove scroll bar
       
    64       (visual-line-mode t)  ; word wrap break on whitespace
       
    65       (global-hl-line-mode t)
       
    66 
    82 
    67       ;; twilight theme
    83 ;;; ido-mode
    68       (require 'color-theme)
    84 (ido-mode t)                                            ; file/buffer selector
    69       (load "color-theme-twilight")
    85 (setq-default
    70       (color-theme-twilight)
    86  ido-enable-flex-matching t                             ; fuzzy matching for ido mode
    71       ))
    87  ido-create-new-buffer 'always                          ; create new buffer without prompt
       
    88  ido-everywhere t)                                      ; use ido where possible
    72 
    89 
    73 ;; terminal
    90 ;;; whitespace-mode
    74 (global-set-key (kbd "C-c s") 'eshell)                ; start shell
    91 (global-whitespace-mode t)                              ; show whitespace
    75 (add-hook 'eshell-mode-hook '(setenv "TERM" "emacs")) ; enable colors
    92 (add-hook 'before-save-hook 'whitespace-cleanup)        ; cleanup whitespace on exit
       
    93 (setq-default
       
    94  whitespace-line-column 120                             ; column width
       
    95  whitespace-style                                       ; whitespace to highlight
       
    96  '(trailing lines-tail empty indentation
       
    97             space-before-tab space-after-tab))
    76 
    98 
    77 ;; OS specific configs
    99 ;;; python-mode
    78 (cond
       
    79  ((string-match "linux" (emacs-version)) (require 'linux))
       
    80  ((string-match "darwin" (emacs-version)) (require 'darwin))
       
    81  )
       
    82 
       
    83 ;;;;;;;;;;;;; includes & requires ;;;;;;;;;;;;;
       
    84 
       
    85 ;; includes
       
    86 (require 'hoersten-align-with-spaces) ; use only spaces for alignment
       
    87 (require 'hoersten-pastebin-region)   ; send selected text to pastebin
       
    88 (require 'hoersten-c-style)           ; load c specific lisp
       
    89 (require 'vala-mode)                  ; vala programming language
       
    90 
       
    91 ;; nav mode
       
    92 (add-to-list 'load-path "~/.emacs.d/nav")
       
    93 (require 'nav)
       
    94 
       
    95 ;; unicode
       
    96 (require 'pretty-mode)
       
    97 (global-pretty-mode t)
       
    98 
       
    99 ;; snippets
       
   100 (add-to-list 'load-path "~/.emacs.d/yasnippet")
       
   101 (require 'yasnippet)
       
   102 (yas/initialize)
       
   103 (yas/load-directory "~/.emacs.d/yasnippet/snippets")
       
   104 (setq-default yas/prompt-functions '(yas/ido-prompt yas/dropdown-prompt)) ; use ido for multiple snippets
       
   105 
       
   106 ;; python mode
       
   107 (add-hook
   100 (add-hook
   108  'python-mode-hook
   101  'python-mode-hook
   109  (lambda ()
   102  (lambda ()
   110    (setq
   103    (setq
   111     tab-width 3
   104     tab-width 3
   112     python-indent 3
   105     python-indent 3
   113     indent-tabs-mode t)))
   106     indent-tabs-mode t)))
   114 
   107 
   115 ;; haskell mode
   108 ;;; haskell-mode
   116 (add-hook
   109 (add-hook
   117  'haskell-mode-hook
   110  'haskell-mode-hook
   118  (lambda ()
   111  (lambda ()
   119    (haskell-indentation-mode nil)
   112    (haskell-indentation-mode nil)
   120    (haskell-indent-mode t)
   113    (haskell-indent-mode t)
   121    (capitalized-words-mode t)
   114    (capitalized-words-mode t)
   122    (haskell-doc-mode t)
   115    (haskell-doc-mode t)
   123    (imenu-add-menubar-index t)
       
   124    (setq
   116    (setq
   125     haskell-font-lock-symbols 'unicode
   117     haskell-font-lock-symbols 'unicode
   126     haskell-indent-offset 3))
   118     haskell-indent-offset 4
   127  t ;; append instead of prepend else haskell-mode overwrites these settings
   119     whitespace-line-column 87))
       
   120  t ; append instead of prepend else haskell-mode overwrites these settings
   128  )
   121  )
   129 
   122 
   130 ;; zencoding html
   123 ;;; org-mode
   131 (require 'zencoding-mode)
       
   132 (add-hook 'sgml-mode-hook 'zencoding-mode) ; Auto-start on any markup modes
       
   133 
       
   134 ;; unique buffer names with dirs
       
   135 (require 'uniquify)
       
   136 (setq
       
   137  uniquify-buffer-name-style 'post-forward
       
   138  uniquify-separator ":")
       
   139 
       
   140 ;; org mode
       
   141 (add-hook
   124 (add-hook
   142  'org-mode-hook
   125  'org-mode-hook
   143  (lambda ()
   126  (lambda ()
   144    (local-set-key (kbd "M-p") 'org-move-item-up)
   127    (local-set-key (kbd "M-p") 'org-move-item-up)
   145    (local-set-key (kbd "M-S-p") 'org-move-subtree-up)
   128    (local-set-key (kbd "M-S-p") 'org-move-subtree-up)
   146    (local-set-key (kbd "M-n") 'org-move-item-down)
   129    (local-set-key (kbd "M-n") 'org-move-item-down)
   147    (local-set-key (kbd "M-S-n") 'org-move-subtree-down)))
   130    (local-set-key (kbd "M-S-n") 'org-move-subtree-down)))
       
   131 
       
   132 
       
   133 ;;;; Requires
       
   134 
       
   135 (require 'hoersten-align-with-spaces) ; use only spaces for alignment
       
   136 (require 'hoersten-pastebin-region)   ; send selected text to pastebin
       
   137 (require 'hoersten-c-style)           ; load c specific lisp
       
   138 (require 'vala-mode)                  ; vala programming language
       
   139 
       
   140 ;;; auto-complete-mode
       
   141 (add-to-list 'load-path "~/.emacs.d/auto-complete-mode/")
       
   142 (require 'auto-complete-config)
       
   143 (add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete-mode/ac-dict")
       
   144 (ac-config-default)
       
   145 (setq ac-modes (append ac-modes '(haskell-mode)))
       
   146 
       
   147 ;;; pretty-mode - unicode character replacement
       
   148 (require 'pretty-mode)
       
   149 (global-pretty-mode t)
       
   150 
       
   151 ;;; yasnippets
       
   152 (add-to-list 'load-path "~/.emacs.d/yasnippet")
       
   153 (require 'yasnippet)
       
   154 (yas/initialize)
       
   155 (yas/load-directory "~/.emacs.d/yasnippet/snippets")
       
   156 (setq-default yas/prompt-functions '(yas/ido-prompt yas/dropdown-prompt)) ; use ido for multiple snippets
       
   157 
       
   158 ;;; zencoding-mode - html
       
   159 (require 'zencoding-mode)
       
   160 (add-hook 'sgml-mode-hook 'zencoding-mode) ; Auto-start on any markup modes
       
   161 
       
   162 ;;; unique buffer names with dirs
       
   163 (require 'uniquify)
       
   164 (setq
       
   165  uniquify-buffer-name-style 'post-forward
       
   166  uniquify-separator ":")