init.el
changeset 59 f346d7591eac
parent 58 c25a7ccd237a
child 60 8beb028f936c
equal deleted inserted replaced
58:c25a7ccd237a 59:f346d7591eac
     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
     8  ediff-split-window-function
     9   'split-window-horizontally              ; diff horizontally
     9  'split-window-horizontally              ; diff horizontally
    10  inhibit-splash-screen t                  ; disable splash screen
    10  inhibit-splash-screen t                  ; disable splash screen
    11  truncate-lines t                         ; truncate, not wrap, lines
    11  truncate-lines t                         ; truncate, not wrap, lines
    12  indent-tabs-mode nil                     ; only uses spaces for indentation
    12  indent-tabs-mode nil                     ; only uses spaces for indentation
    13  split-width-threshold 181                ; min width to split window horizontially
    13  split-width-threshold 181                ; min width to split window horizontially
    14  split-height-threshold 120               ; min width to split window vertically
    14  split-height-threshold 120               ; min width to split window vertically
    35 (global-set-key (kbd "C-c r") 'recompile) ; recompile
    35 (global-set-key (kbd "C-c r") 'recompile) ; recompile
    36 (subword-mode t)                          ; move by camelCase words
    36 (subword-mode t)                          ; move by camelCase words
    37 
    37 
    38 
    38 
    39 ;;; Darwin
    39 ;;; Darwin
    40 (if (string-match "darwin" (emacs-version))
    40 (setq is-mac (equal system-type 'darwin))
    41     (progn
    41 (when is-mac
    42       (setq-default
    42   (setq-default
    43        mac-command-modifier 'meta
    43    mac-command-modifier 'meta
    44        ns-pop-up-frames nil
    44    ns-pop-up-frames nil
    45        ispell-program-name "/usr/local/bin/aspell")))
    45    ispell-program-name "/usr/local/bin/aspell"))
    46 
    46 
    47 ;;; Xorg
    47 ;;; Xorg
    48 (if window-system
    48 (when window-system
    49     (progn
    49   (tool-bar-mode -1)      ; remove tool bar
    50       (defun get-font ()
    50   (scroll-bar-mode -1)    ; remove scroll bar
    51         "Get appropriate font based on system and hostname."
    51   (menu-bar-mode -1)      ; remove menu bar
    52         (cond
    52   (visual-line-mode t)    ; word wrap break on whitespace
    53          ((string-match "darwin" (emacs-version)) "Ubuntu Mono-14")
    53   (set-frame-font (if is-mac "Ubuntu Mono-14" "Ubuntu Mono-10.5")))
    54          ((string-match "RichardParker"   (system-name)) "Ubuntu Mono-8.5")
       
    55          ((string-match "HoldenCaulfield" (system-name)) "Ubuntu Mono-10.5")
       
    56          ((string-match "lhoersten-66113" (system-name)) "Ubuntu Mono-10.5")
       
    57          ("Ubuntu Mono-10.5")))
       
    58 
       
    59       (tool-bar-mode -1)      ; remove tool bar
       
    60       (scroll-bar-mode -1)    ; remove scroll bar
       
    61       (menu-bar-mode -1)      ; remove menu bar
       
    62       (visual-line-mode t)    ; word wrap break on whitespace
       
    63       (set-frame-font (get-font))))
       
    64 
       
    65 
       
    66 ;;; terminal
       
    67 (global-set-key (kbd "C-c s") 'eshell) ; start shell
       
    68 (defun setup-env ()
       
    69   (setenv "TERM" "emacs") ; enable colors
       
    70   (setenv "ODBCSYSINI" "/home/lhoersten/myodbc")
       
    71   (setenv "ODBCINI" "/home/lhoersten/myodbc/odbc.ini")
       
    72   (setenv "PATH" (concat "/usr/local/bin:" (getenv "HOME") "/.cabal/bin:" (getenv "PATH"))))
       
    73 (add-hook 'eshell-mode-hook 'setup-env)
       
    74 (setup-env)
       
    75 (eshell)
       
    76 
    54 
    77 ;;;; Mode-Specific ;;;;
    55 ;;;; Mode-Specific ;;;;
    78 
    56 
    79 ;;; text-mode
    57 ;;; text-mode
    80 (add-hook 'fundamental-mode-hook 'flyspell-mode t)      ; spellcheck text
    58 (add-hook 'fundamental-mode-hook '(flyspell-mode t))      ; spellcheck text
    81 (add-hook 'fundamental-mode-hook 'turn-on-auto-fill)    ; autofill text
    59 (add-hook 'fundamental-mode-hook 'turn-on-auto-fill)    ; autofill text
    82 
    60 
    83 ;;; ido-mode
    61 ;;; ido-mode
    84 (ido-mode t)                                            ; file/buffer selector
    62 (ido-mode t)                                            ; file/buffer selector
    85 (setq-default
    63 (setq-default
    95  whitespace-style                                       ; whitespace to highlight
    73  whitespace-style                                       ; whitespace to highlight
    96  '(trailing lines-tail empty indentation
    74  '(trailing lines-tail empty indentation
    97             space-before-tab space-after-tab))
    75             space-before-tab space-after-tab))
    98 
    76 
    99 ;;; python-mode
    77 ;;; python-mode
   100 (add-hook 'python-mode-hook (lambda () (setq tab-width 4)))
    78 (add-hook 'python-mode-hook '(setq tab-width 4))
   101 
    79 
   102 ;;; org-mode
    80 ;;; org-mode
   103 (add-hook
    81 (add-hook
   104  'org-mode-hook
    82  'org-mode-hook
   105  (lambda ()
    83  (lambda ()
   139 
   117 
   140 ;; install packages
   118 ;; install packages
   141 (let ((ensure-installed
   119 (let ((ensure-installed
   142        (lambda (name)
   120        (lambda (name)
   143          (unless (package-installed-p name) (package-install name))))
   121          (unless (package-installed-p name) (package-install name))))
   144       (packages '(ac-js2 auto-complete expand-region
   122       (packages
   145        flymake-haskell-multi ghc ghci-completion haskell-mode
   123        '(ac-js2 auto-complete expand-region
   146        iy-go-to-char js2-mode multiple-cursors rainbow-delimiters
   124                 flymake-haskell-multi ghc ghci-completion haskell-mode
   147        rainbow-mode skewer-mode solarized-theme yasnippet
   125                 iy-go-to-char js2-mode multiple-cursors rainbow-delimiters
   148        zencoding-mode)))
   126                 rainbow-mode skewer-mode solarized-theme yasnippet
       
   127                 zencoding-mode visual-regexp)))
   149   (mapc ensure-installed packages))
   128   (mapc ensure-installed packages))
   150 
   129 
   151 ;;; requires
   130 ;;; requires
   152 (require 'c-init)             ; c specific elisp
   131 (require 'c-init)             ; c specific elisp
   153 (require 'align-with-spaces)  ; use only spaces for alignment
   132 (require 'align-with-spaces)  ; use only spaces for alignment
   157 (require 'iy-go-to-char)
   136 (require 'iy-go-to-char)
   158 
   137 
   159 ;;; auto-config-mode
   138 ;;; auto-config-mode
   160 (ac-config-default)
   139 (ac-config-default)
   161 
   140 
       
   141 ;;; terminal
       
   142 (global-set-key (kbd "C-c s") 'eshell) ; start shell
       
   143 (exec-path-from-shell-initialize)
       
   144 (eshell)
       
   145 
   162 ;;; uniquify
   146 ;;; uniquify
   163 (setq
   147 (setq
   164  uniquify-buffer-name-style 'post-forward
   148  uniquify-buffer-name-style 'post-forward
   165  uniquify-separator ":")
   149  uniquify-separator ":")
   166 
   150 
   176 (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
   160 (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
   177 (yas-global-mode t)
   161 (yas-global-mode t)
   178 
   162 
   179 ;;; js2-mode
   163 ;;; js2-mode
   180 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
   164 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
   181 (add-hook 'js2-mode-hook 'ac-js2-mode)
   165 (add-hook 'js2-mode-hook '(ac-js2-mode t))
   182 (setq-default ac-js2-evaluate-calls t)
   166 (setq-default ac-js2-evaluate-calls t)
   183 
   167 
   184 ;;; html-mode
   168 ;;; html-mode
   185 (add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))
   169 (add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))
   186 (add-hook
   170 (add-hook
   189    (local-set-key (kbd "C-c t") 'mc/mark-sgml-tag-pair)
   173    (local-set-key (kbd "C-c t") 'mc/mark-sgml-tag-pair)
   190    (zencoding-mode)
   174    (zencoding-mode)
   191    (rainbow-mode)))
   175    (rainbow-mode)))
   192 
   176 
   193 ;;; css-mode
   177 ;;; css-mode
   194 (add-hook 'css-mode-hook 'rainbow-mode)
   178 (add-hook 'css-mode-hook '(rainbow-mode t))
   195 
   179 
   196 ;;; coding-modes map
   180 ;;; coding-modes map
   197 (mapc
   181 (mapc
   198  (lambda (x) (add-hook x
   182  (lambda (x)
       
   183    (add-hook
       
   184     x
   199     (lambda ()
   185     (lambda ()
   200       (linum-mode)
   186       (linum-mode t)
   201       (rainbow-delimiters-mode)
   187       (rainbow-delimiters-mode t)
   202       (auto-complete-mode))
   188       (auto-complete-mode t)) t))
   203     t))
       
   204  '(text-mode-hook
   189  '(text-mode-hook
   205    c-mode-common-hook
   190    c-mode-common-hook
   206    python-mode-hook
   191    python-mode-hook
   207    haskell-mode-hook
   192    haskell-mode-hook
   208    js2-mode-hook
   193    js2-mode-hook
   214 ;;; haskell-mode
   199 ;;; haskell-mode
   215 (add-hook
   200 (add-hook
   216  'haskell-mode-hook
   201  'haskell-mode-hook
   217  (lambda ()
   202  (lambda ()
   218    (local-set-key (kbd "C-c i") 'haskell-navigate-imports) ; go to imports. prefix to return
   203    (local-set-key (kbd "C-c i") 'haskell-navigate-imports) ; go to imports. prefix to return
   219    (flymake-haskell-multi-load)
   204    (flymake-haskell-multi-load t)
   220    (flymake-mode)
   205    (flymake-mode t)
   221    (capitalized-words-mode)
   206    (capitalized-words-mode t)
   222    (turn-on-haskell-indent)
   207    (turn-on-haskell-indent)
   223    (turn-on-haskell-doc-mode)
   208    (turn-on-haskell-doc-mode)
   224    (turn-on-haskell-decl-scan)
   209    (turn-on-haskell-decl-scan)
   225    (imenu-add-menubar-index)
   210    (imenu-add-menubar-index t)
   226    (setq
   211    (setq
   227     haskell-font-lock-haddock t
   212     haskell-font-lock-haddock t
   228     haskell-stylish-on-save t
   213     haskell-stylish-on-save t
   229     haskell-program-name "ghci"
   214     haskell-program-name "ghci"
   230     haskell-indent-offset 4
   215     haskell-indent-offset 4
   255 ;;; multiple-cursors
   240 ;;; multiple-cursors
   256 (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
   241 (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
   257 (global-set-key (kbd "C->") 'mc/mark-next-like-this)
   242 (global-set-key (kbd "C->") 'mc/mark-next-like-this)
   258 (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
   243 (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
   259 (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
   244 (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
       
   245 
       
   246 ;;; visual-regexp
       
   247 (global-set-key (kbd "C-M-%") 'vr/query-replace)
       
   248 (global-set-key (kbd "M-%") 'vr/replace)