init.el
changeset 75 5f3bf3a9295b
parent 74 1ec54926890f
child 76 af643427e1be
equal deleted inserted replaced
74:1ec54926890f 75:5f3bf3a9295b
     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/elisp")     ; set default emacs load path
     5 (add-to-list 'load-path "~/.emacs.d/elisp")   ; 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
    15  reb-re-syntax 'string                    ; use string syntax for regexp builder
    15  reb-re-syntax 'string                        ; use string syntax for regexp builder
    16  require-final-newline 'visit-save)       ; add a newline automatically
    16  require-final-newline 'visit-save)           ; add a newline automatically
    17 
    17 
    18 (put 'set-goal-column 'disabled nil)      ; enable goal column setting
    18 (put 'set-goal-column 'disabled nil)          ; enable goal column setting
    19 (put 'narrow-to-region 'disabled nil)     ; enable hiding
    19 (put 'narrow-to-region 'disabled nil)         ; enable hiding
    20 (put 'narrow-to-page 'disabled nil)
    20 (put 'narrow-to-page 'disabled nil)
    21 
    21 
    22 (column-number-mode t)                    ; show column numbers
    22 (column-number-mode t)                        ; show column numbers
    23 (delete-selection-mode t)                 ; replace highlighted text
    23 (delete-selection-mode t)                     ; replace highlighted text
    24 (windmove-default-keybindings)            ; move between windows with shift-arrow
    24 (windmove-default-keybindings)                ; move between windows with shift-arrow
    25 (fset 'yes-or-no-p 'y-or-n-p)             ; replace yes/no prompts
    25 (fset 'yes-or-no-p 'y-or-n-p)                 ; replace yes/no prompts
    26 (global-hl-line-mode t)                   ; highlight current line
    26 (global-hl-line-mode t)                       ; highlight current line
    27 
    27 
    28 
    28 
    29 ;;; Coding
    29 ;;; Coding
    30 (which-func-mode t)                       ; show current function
    30 (which-func-mode t)                           ; show current function
    31 (show-paren-mode t)                       ; show matching paren
    31 (show-paren-mode t)                           ; show matching paren
    32 (transient-mark-mode t)                   ; show highlighting
    32 (transient-mark-mode t)                       ; show highlighting
    33 (global-font-lock-mode t)                 ; syntax highlighting
    33 (global-font-lock-mode t)                     ; syntax highlighting
    34 (global-set-key (kbd "C-c c") 'compile)   ; compile
    34 (global-set-key (kbd "C-c c") 'compile)       ; compile
    35 (global-set-key (kbd "C-c r") 'recompile) ; recompile
    35 (global-set-key (kbd "C-c r") 'recompile)     ; recompile
    36 (global-set-key (kbd "C-c a") 'align-regexp) ; align
    36 (global-set-key (kbd "C-c a") 'align-regexp)  ; align
    37 (global-set-key (kbd "C-c g") 'rgrep)     ; grep
    37 (global-set-key (kbd "C-c g") 'rgrep)         ; grep
    38 (subword-mode t)                          ; move by camelCase words
    38 (subword-mode t)                              ; move by camelCase words
    39 
    39 
    40 
    40 
    41 ;;; Darwin
    41 ;;; Darwin
    42 (setq is-mac (equal system-type 'darwin))
    42 (setq is-mac (equal system-type 'darwin))
    43 (when is-mac
    43 (when is-mac
    47    ns-pop-up-frames nil
    47    ns-pop-up-frames nil
    48    ispell-program-name "/usr/local/bin/aspell"))
    48    ispell-program-name "/usr/local/bin/aspell"))
    49 
    49 
    50 ;;; Xorg
    50 ;;; Xorg
    51 (when window-system
    51 (when window-system
    52   (tool-bar-mode -1)      ; remove tool bar
    52   (tool-bar-mode -1)                          ; remove tool bar
    53   (scroll-bar-mode -1)    ; remove scroll bar
    53   (scroll-bar-mode -1)                        ; remove scroll bar
    54   (unless is-mac (menu-bar-mode -1)) ; remove menu bar
    54   (unless is-mac (menu-bar-mode -1))          ; remove menu bar
    55   (visual-line-mode t)    ; word wrap break on whitespace
    55   (visual-line-mode t)                        ; word wrap break on whitespace
    56   (set-default-font (if is-mac "Ubuntu Mono-12" "Ubuntu Mono-10.5")))
    56   (set-default-font (if is-mac "Ubuntu Mono-12" "Ubuntu Mono-10.5")))
    57 
    57 
    58 ;;;; Mode-Specific ;;;;
    58 ;;;; Mode-Specific ;;;;
    59 
    59 
    60 ;;; text-mode
    60 ;;; text-mode
    61 (add-hook 'fundamental-mode-hook 'flyspell-mode)        ; spellcheck text
    61 (add-hook 'fundamental-mode-hook 'flyspell-mode)      ; spellcheck text
    62 (add-hook 'fundamental-mode-hook 'turn-on-auto-fill)    ; autofill text
    62 (add-hook 'fundamental-mode-hook 'turn-on-auto-fill)  ; autofill text
    63 
    63 
    64 ;;; ido-mode
    64 ;;; ido-mode
    65 (ido-mode t)                                            ; file/buffer selector
    65 (ido-mode t)                                          ; file/buffer selector
    66 (setq-default
    66 (setq-default
    67  ido-enable-flex-matching t                             ; fuzzy matching for ido mode
    67  ido-enable-flex-matching t                           ; fuzzy matching for ido mode
    68  ido-create-new-buffer 'always                          ; create new buffer without prompt
    68  ido-create-new-buffer 'always                        ; create new buffer without prompt
    69  ido-everywhere t                                       ; use ido where possible
    69  ido-everywhere t                                     ; use ido where possible
    70  ido-max-window-height 1)                               ; max ido window height
    70  ido-max-window-height 1)                             ; max ido window height
    71 
    71 
    72 ;;; whitespace-mode
    72 ;;; whitespace-mode
    73 (global-whitespace-mode t)                              ; show whitespace
    73 (global-whitespace-mode t)                            ; show whitespace
    74 (add-hook 'before-save-hook 'whitespace-cleanup)        ; cleanup whitespace on exit
    74 (add-hook 'before-save-hook 'whitespace-cleanup)      ; cleanup whitespace on exit
    75 (setq-default
    75 (setq-default
    76  whitespace-line-column 120                             ; column width
    76  whitespace-line-column 120                           ; column width
    77  whitespace-style                                       ; whitespace to highlight
    77  whitespace-style                                     ; whitespace to highlight
    78  '(trailing lines-tail empty indentation
    78  '(trailing lines-tail empty indentation
    79             space-before-tab space-after-tab))
    79             space-before-tab space-after-tab))
    80 
    80 
    81 ;;; org-mode
    81 ;;; org-mode
    82 (add-hook
    82 (add-hook
    86    (local-set-key (kbd "M-S-p") 'org-move-subtree-up)
    86    (local-set-key (kbd "M-S-p") 'org-move-subtree-up)
    87    (local-set-key (kbd "M-n") 'org-move-item-down)
    87    (local-set-key (kbd "M-n") 'org-move-item-down)
    88    (local-set-key (kbd "M-S-n") 'org-move-subtree-down)))
    88    (local-set-key (kbd "M-S-n") 'org-move-subtree-down)))
    89 
    89 
    90 ;;; ibuffer
    90 ;;; ibuffer
    91 (global-set-key (kbd "C-x C-b") 'ibuffer) ; better buffer browser
    91 (global-set-key (kbd "C-x C-b") 'ibuffer)             ; better buffer browser
    92 (setq-default
    92 (setq-default
    93  ibuffer-show-empty-filter-groups nil
    93  ibuffer-show-empty-filter-groups nil
    94  ibuffer-saved-filter-groups
    94  ibuffer-saved-filter-groups
    95  '(("default"
    95  '(("default"
    96     ("Emacs Lisp" (mode . emacs-lisp-mode))
    96     ("Emacs Lisp" (mode . emacs-lisp-mode))
   122 ;; powerline
   122 ;; powerline
   123 (require 'powerline)
   123 (require 'powerline)
   124 (powerline-default-theme)
   124 (powerline-default-theme)
   125 
   125 
   126 ;;; terminal
   126 ;;; terminal
   127 (global-set-key (kbd "C-c s") 'eshell) ; start shell
   127 (global-set-key (kbd "C-c s") 'eshell)  ; start shell
   128 (exec-path-from-shell-initialize)
   128 (exec-path-from-shell-initialize)
   129 (eshell)
   129 (eshell)
   130 (add-hook 'eshell-mode-hook (lambda () (setenv "TERM" "emacs")))
   130 (add-hook 'eshell-mode-hook (lambda () (setenv "TERM" "emacs")))
   131 
   131 
   132 ;;; custom requires
   132 ;;; custom requires
   133 (require 'haskell-init)
   133 (require 'haskell-init)
   134 (require 'javascript-init)
   134 (require 'javascript-init)
   135 (require 'c-init)             ; c specific elisp
   135 (require 'c-init)                       ; c specific elisp
   136 
   136 
   137 ;;; company mode
   137 ;;; company mode
   138 (add-hook 'after-init-hook 'global-company-mode)
   138 (add-hook 'after-init-hook 'global-company-mode)
   139 (global-set-key (kbd "M-/") 'company-complete)
   139 (global-set-key (kbd "M-/") 'company-complete)
   140 (custom-set-variables
   140 (custom-set-variables
   143  '(company-selection-wrap-around t)
   143  '(company-selection-wrap-around t)
   144  '(company-show-numbers t)
   144  '(company-show-numbers t)
   145  '(company-tooltip-align-annotations t))
   145  '(company-tooltip-align-annotations t))
   146 
   146 
   147 ;;; uniquify
   147 ;;; uniquify
   148 (require 'uniquify)           ; unique buffer names with dirs
   148 (require 'uniquify)                     ; unique buffer names with dirs
   149 (setq
   149 (setq
   150  uniquify-buffer-name-style 'post-forward
   150  uniquify-buffer-name-style 'post-forward
   151  uniquify-separator ":")
   151  uniquify-separator ":")
   152 
   152 
   153 ;;; color-theme
   153 ;;; color-theme