1/27/2014 - 4:53 PM



;; aliases

(defalias 'dm 'delete-matching-lines)
(defalias 'dnm 'delete-non-matching-lines)
(defalias 'exe 'eval-buffer)
(defalias 'hm 'highlight-lines-matching-regexp)
(defalias 'rq 'list-matching-lines) ;; regex query
(defalias 'sl 'sort-lines)
(defalias 'tc 'toggle-case-fold-search)
(defalias 'uc 'upcase-initials-region)

(global-set-key [M-delete] 'kill-word)
(global-set-key [delete] 'delete-char)

(key-chord-define-global "ac" 'align-current)
(key-chord-define-global "cg" 'customize-group)
(key-chord-define-global "fv" (lambda () (interactive) (kill-buffer (buffer-name))))
(key-chord-define-global "jn" (lambda () (interactive) (switch-to-buffer nil)))
(key-chord-define-global "nm" 'mu4e)
(key-chord-define-global "ok" 'projectile-multi-occur)
(key-chord-define-global "sb" 'speedbar)
(key-chord-define-global "sc" (lambda () (interactive)(switch-to-buffer "*scratch*")))
(key-chord-define-global "sv" 'save-buffer)
(key-chord-define-global "vg" 'vc-git-grep)
(key-chord-define-global "vr" 'vr/replace)

;; window
(global-set-key (kbd "<f2>") 'split-window-vertically)
(global-set-key (kbd "<f3>") 'split-window-horizontally)
(global-set-key (kbd "<f4>") 'delete-window)
(global-set-key (kbd "<f5>") 'delete-other-windows)
(global-set-key (kbd "<f7>") 'toggle-window-split)
(global-set-key (kbd "<f9>") 'my/split-window)
(global-set-key (kbd "C-0") (lambda () (interactive) (select-window (previous-window))))
(global-set-key (kbd "C-9") (lambda () (interactive) (select-window (next-window))))
(global-set-key (kbd "M-6") 'find-tag-other-window)

;; git
(key-chord-define-global "vg" 'vc-git-grep)
(key-chord-define-global "bm" 'magit-blame-mode)
(global-set-key (kbd "M-0") 'helm-git-find-files)
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-c l") 'magit-log)

;; modes

(global-set-key (kbd "C-c C-f") 'flyspell-mode)
(global-set-key (kbd "C-c m") 'menu-bar-mode)
(global-set-key (kbd "C-c q") 'auto-fill-mode)
(global-set-key (kbd "C-h C-v") 'visual-line-mode)
(key-chord-define-global "bm" 'magit-blame-mode)
(key-chord-define-global "fc" 'flycheck-mode)
(key-chord-define-global "i9" 'electric-indent-mode)
(key-chord-define-global "ln" 'linum-mode)

;; org

(global-set-key (kbd "C-c C-0") 'org-insert-todo-subheading)
(global-set-key (kbd "C-c C-9") 'org-insert-subheading)
(global-set-key (kbd "C-c I") 'org-clock-out)
(global-set-key (kbd "C-c i") 'org-clock-in)
(global-set-key (kbd "C-h C-.") (lambda () (interactive) (find-file "~/org/home.org")))
(global-set-key (kbd "C-h C-n") (lambda () (interactive) (org-agenda nil "n")))
(global-set-key (kbd "C-h C-u") (lambda () (interactive) (find-file "~/org/work.org")))
(global-set-key (kbd "C-h C-w") 'org-cut-subtree)
(global-set-key (kbd "C-h T") 'org-capture)
(global-set-key (kbd "C-h t") (lambda () (interactive) (org-capture nil "s")))

;; helm
(global-set-key (kbd "C-h o") 'helm-info-org)
(global-set-key (kbd "<C-S-iso-lefttab>") 'helm-for-files)
(global-set-key (kbd "C-h ,") 'helm-apropos)
(global-set-key (kbd "C-h .") 'helm-info-emacs)
(global-set-key (kbd "C-h 3") 'helm-locate-library)
(global-set-key (kbd "C-h 4") 'helm-info-elisp)
(global-set-key (kbd "C-h C--") 'helm-google)
(global-set-key (kbd "C-h C-SPC") 'helm-show-kill-ring)
(global-set-key (kbd "C-h C-h") 'helm-M-x)
(global-set-key (kbd "C-h C-l") 'helm-locate)
(global-set-key (kbd "C-h SPC") 'helm-all-mark-rings)
(global-set-key (kbd "C-h h") 'helm-projectile)
(global-set-key (kbd "M-0") 'helm-git-find-files)
(global-set-key (kbd "M-5") 'helm-etags-select)
(global-set-key (kbd "M-9") 'helm-occur)
(global-set-key (kbd "M-I") 'helm-swoop-back-to-last-point)
(global-set-key (kbd "M-i") 'helm-swoop)
(global-set-key (kbd "M-x") 'helm-M-x)
(key-chord-define-global "34" 'helm-imenu)

(global-set-key "\C-l" 'goto-line)
(global-set-key "\C-q" 'scroll-n-lines-to-end)
(global-set-key "\C-z" 'scroll-n-lines-to-top)
(global-set-key (kbd "<M-down>") 'buf-move-down)
(global-set-key (kbd "<M-f10>") 'move-text-up)
(global-set-key (kbd "<M-f9>") 'move-text-down)
(global-set-key (kbd "<M-left>") 'buf-move-left)
(global-set-key (kbd "<M-right>") 'buf-move-right)
(global-set-key (kbd "<M-up>") 'buf-move-up)
(global-set-key (kbd "<f6>") (lambda () (interactive) (kill-buffer (buffer-name))))
(global-set-key (kbd "<f8>") (lambda () (interactive) (switch-to-buffer nil)))
(global-set-key (kbd "C-*") 'mc/mark-all-like-this)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-3") 'back-button-local-backward)
(global-set-key (kbd "C-4") 'back-button-local-forward)
(global-set-key (kbd "C-8") 'er/expand-region)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-?") 'my-find-function-or-variable-at-point)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-S-l") 'package-list-packages)

(global-set-key (kbd "C-c C-w") 'browse-url-at-point)
(global-set-key (kbd "C-c T") (lambda () (interactive) (my-open-terminal nil)))
(global-set-key (kbd "C-c V") 'var_dump)
(global-set-key (kbd "C-c c") 'deft)
(global-set-key (kbd "C-c d") 'ispell-change-dictionary)
(global-set-key (kbd "C-c e") 'my-erc-connect)
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-c l") 'magit-log)
(global-set-key (kbd "C-c n") 'show-file-name)
(global-set-key (kbd "C-c o") 'occur)
(global-set-key (kbd "C-c r") 'revert-buffer)
(global-set-key (kbd "C-c s") 'shell)
(global-set-key (kbd "C-c t") (lambda () (interactive) (my-open-terminal t)))
(global-set-key (kbd "C-c v") 'var_dump-die)
(global-set-key (kbd "C-c w") 'whitespace-cleanup)
(global-set-key (kbd "C-h C-/") 'fasd-find-file)
(global-set-key (kbd "C-h C-0") 'edebug-defun)
(global-set-key (kbd "C-h C-<return>") 'eww)
(global-set-key (kbd "C-h C-b") 'eval-buffer)
(global-set-key (kbd "C-h C-c") 'multi-term-next)
(global-set-key (kbd "C-h C-d") 'dired-jump)
(global-set-key (kbd "C-h C-e") 'toggle-debug-on-error)
(global-set-key (kbd "C-h C-f") 'find-function-at-point)
(global-set-key (kbd "C-h C-f") 'grep-find)
(global-set-key (kbd "C-h C-g") 'ag-project)
(global-set-key (kbd "C-h C-m") 'discover-my-major)
(global-set-key (kbd "C-h C-p") 'find-file)
(global-set-key (kbd "C-h C-r") 'multi-term-prev)
(global-set-key (kbd "C-h C-s") 'save-buffer)
(global-set-key (kbd "C-h C-z") 'projectile-find-file)
(global-set-key (kbd "C-h M-RET") 'my-eww-browse-dwim)
(global-set-key (kbd "C-h TAB") 'my-indent-whole-buffer)
(global-set-key (kbd "C-h g") 'projectile-grep)
(global-set-key (kbd "C-h n") 'multi-term)
(global-set-key (kbd "C-h r") 'multi-term-dedicated-toggle)
(global-set-key (kbd "C-h x") (lambda () (interactive) (shell-command "pkill emacs")))
(global-set-key (kbd "C-h z") 'projectile-ack)
(global-set-key (kbd "C-x C-b") 'ido-switch-buffer)
(global-set-key (kbd "C-x C-u") 'my-url-insert-file-contents)
(global-set-key (kbd "C-x a s") 'auto-save-buffers-enhanced-toggle-activity)
(global-set-key (kbd "C-z") 'undo-only)
(global-set-key (kbd "M-2") 'highlight-symbol-occur)
(global-set-key (kbd "M-3") (lambda () (interactive) (highlight-symbol-jump -1)))
(global-set-key (kbd "M-4") (lambda () (interactive) (highlight-symbol-jump 1)))
(global-set-key (kbd "M-8") 'er/contract-region)
(global-set-key (kbd "M-W") 'delete-region)
;;; rex zone

;; show linum by default

(global-linum-mode t)
(setq linum-format " %03d ")

(setq display-time-day-and-date t)
(setq display-time-24hr-format t)


(setq same-window-regexps '("."))

;;c-x c-n to set global-column;
;;c-u c-x c-n to cancel global-column.
(put 'set-goal-column 'disabled nil)
(put 'eval-expression 'disabled nil)

; sort-fields
; sort-numeric-fields
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)

;; Tabs and Indentations
(setq-default c-basic-offset 4)
(setq-default default-tab-width 4)
(setq-default indent-tabs-mode nil)
(setq-default sgml-basic-offset 4)
(setq-default tab-width 4)

;; disable auto-save, no backup files
(setq auto-save-default nil)
(setq-default make-backup-files nil)

(defun current-mode(&optional n)
  (interactive "P")
  (message "%s" major-mode))

(defun scroll-n-lines-to-top (&optional n)
  "scroll ahead to top, one line by default"
  (interactive "P")
  (scroll-up (prefix-numeric-value n)))

(defun scroll-n-lines-to-end (&optional n)
  "scrool to end by n line"
  (interactive "P")
  (scroll-down (prefix-numeric-value n)))

(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(setq yas-snippet-dirs
      '("~/.emacs.d/mysnippets"               ;; personal snippets
        "~/.emacs.d/elpa/yasnippet-0.8.0/snippets"           ;; foo-mode and bar-mode snippet collection
        ; "/path/to/yasnippet/yasmate/snippets" ;; the yasmate collection
        ; "/path/to/yasnippet/snippets"         ;; the default collection
(yas-global-mode 1)
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)

;; aliases
(defalias 'dm 'delete-matching-lines)
(defalias 'dnm 'delete-non-matching-lines)
(defalias 'exe 'eval-buffer)
(defalias 'hm 'highlight-lines-matching-regexp)
(defalias 'rp 'query-replace-regexp)
(defalias 'rq 'list-matching-lines) ;; regex query
(defalias 'sl 'sort-lines)
(defalias 'tc 'toggle-case-fold-search)
(defalias 'uc 'upcase-initials-region)

;; keyborad shortcuts
(global-set-key "\C-l" 'goto-line)
(global-set-key "\C-q" 'scroll-n-lines-to-end)
(global-set-key "\C-z" 'scroll-n-lines-to-top)
(global-set-key [M-delete] 'kill-word)
(global-set-key [delete] 'delete-char)