Created
November 17, 2013 00:47
-
-
Save banister/7507499 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-to-list 'load-path "~/.emacs.d/") | |
(add-to-list 'load-path "~/.emacs.d/ruby-dev/") | |
(add-to-list 'load-path "~/.emacs.d/themes/") | |
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") | |
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/") t) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(package-initialize) | |
; (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") | |
(load-theme 'zenburn t) | |
(column-number-mode 1) | |
;; Modern lisp list tools https://github.com/magnars/dash.el | |
(require 'dash) | |
;; fix annoying inf-ruby-keys error since function was undefined | |
(require 'inf-ruby) | |
(defalias 'inf-ruby-keys 'inf-ruby-setup-keybindings) | |
;; Project management tool | |
(require 'projectile) | |
(projectile-global-mode) | |
(defun remove-all-dired-buffers () | |
(mapc (lambda (buf) (when (eq (buffer-local-value 'major-mode buf) 'dired-mode) (kill-buffer buf))) (buffer-list))) | |
(defun narrow-to-region-indirect (start end) | |
"Restrict editing in this buffer to the current region, indirectly." | |
(interactive "r") | |
(deactivate-mark) | |
(let ((buf (clone-indirect-buffer nil nil))) | |
(with-current-buffer buf | |
(narrow-to-region start end)) | |
(switch-to-buffer buf))) | |
(defun overwrite-region () | |
(interactive) | |
(delete-region (region-beginning) (region-end)) (insert (car kill-ring))) | |
;; start help mini console | |
(global-set-key (kbd "s-h") 'helm-projectile) | |
(global-set-key (kbd "M-r") 'revert-buffer) | |
; indent the whole buffer | |
(global-set-key (kbd "s-i") (lambda () (interactive) (save-excursion (mark-whole-buffer) (indent-region (region-beginning) (region-end))))) | |
;; fast forward to char | |
(global-set-key (kbd "s-s") 'iy-go-to-char) | |
(global-set-key (kbd "C-r") 'iy-go-to-char-backward) | |
(global-set-key (kbd "M-n") 'narrow-to-region-indirect) | |
(global-set-key (kbd "M-u") 'widen) | |
(global-set-key (kbd "C-c l") 'org-store-link) | |
;; jump to a word starting with given char | |
(global-set-key (kbd "s-j") 'ace-jump-word-mode) | |
(global-set-key (kbd "s-x") '(lambda () (interactive) (remove-all-dired-buffers) (dired "./"))) | |
(global-set-key (kbd "M-k") 'kill-whole-line) | |
(global-set-key (kbd "s-d") (lambda () (interactive) (diff-buffer-with-file))) | |
(global-set-key (kbd "s-t") (lambda () (interactive) (let ((compile-command "rake test")) (call-interactively 'compile)))) | |
(global-set-key (kbd "s-t") (lambda () (interactive) (shell-command "rake test"))) | |
(global-set-key (kbd "s-r") 'gist-region-private) | |
(global-set-key (kbd "s-g") 'goto-line) | |
(global-set-key (kbd "s-q") 'kill-region) | |
;; (global-set-key (kbd "C-r") (lookup-key global-map (kbd "C-x r"))) | |
(global-set-key (kbd "C-x y") 'overwrite-region) | |
;; make a simpler alias for switching between windows | |
(global-set-key (kbd "s-o") 'other-window) | |
; enable easy movement around of code blocks via M-left and M-right | |
(defmacro adjust-indent (amount) | |
`(lambda () (interactive) (indent-rigidly (region-beginning) (region-end) ,amount))) | |
(global-set-key (kbd "<M-left>") (adjust-indent -1)) | |
(global-set-key (kbd "<M-right>") (adjust-indent 1)) | |
;; setup hotkey for ack | |
(global-set-key (kbd "s-a") 'projectile-ack) | |
;; find a file in the current project | |
(global-set-key (kbd "s-f") 'projectile-find-file) | |
;; expand selection by semantic units, i.e line --> method --> class | |
(global-set-key (kbd "s-2") 'er/expand-region) | |
;; multi-cursors stuff | |
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
(global-set-key (kbd "C-c C-/") 'mc/mark-all-like-this) | |
;; make macros easier to record/save | |
(global-set-key (kbd "s-1") 'kmacro-start-macro) | |
(global-set-key (kbd "s-q") 'kmacro-end-macro) | |
(global-set-key (kbd "s-e") 'apply-macro-to-region-lines) | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
;; magit status | |
(global-set-key (kbd "C-x g") 'magit-status) | |
;; map | |
(require 'rvm) | |
(rvm-use-default) ;; use rvm's default ruby for the current Emacs session | |
(defun rotate-windows-helper(x d) | |
(if (equal (cdr x) nil) (set-window-buffer (car x) d) | |
(set-window-buffer (car x) (window-buffer (cadr x))) (rotate-windows-helper (cdr x) d))) | |
(defun rotate-windows () | |
(interactive) | |
(rotate-windows-helper (window-list) (window-buffer (car (window-list)))) | |
(select-window (car (last (window-list))))) | |
; bind to the key super-r | |
(global-set-key (kbd "s-w") 'rotate-windows) | |
(setq js-indent-level 2) | |
(defun create-blank-buffer () | |
"create a scratch buffer" | |
(interactive) | |
(switch-to-buffer (get-buffer-create (generate-new-buffer-name"empty"))) | |
(ruby-mode)) | |
(global-set-key (kbd "s-n") 'create-blank-buffer) | |
; rails mode | |
;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/rails-minor-mode")) | |
;; (require 'rails) | |
(add-to-list 'auto-mode-alist '("\\.jst\.eco\\'" . html-mode)) | |
(add-to-list 'auto-mode-alist '("\\.erb\\'" . html-mode)) | |
(add-to-list 'auto-mode-alist '("\\.css\.scss\\'" . sass-mode)) | |
(defun touch-file (my-file) | |
(interactive (list (read-string "File to create:" default-directory))) | |
(shell-command (format "touch %s" my-file)) | |
(if (eq major-mode 'dired-mode) (revert-buffer))) | |
(add-hook 'dired-mode-hook | |
'(lambda () | |
(define-key dired-mode-map | |
"]" 'touch-file))) | |
(custom-set-variables | |
;; custom-set-variables was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
'(ack-and-a-half-executable "/usr/local/bin/ack") | |
'(ack-executable "/usr/local/bin/ack") | |
'(coffee-tab-width 2) | |
'(custom-safe-themes (quote ("1d10043a0318d90a71cfa1f7e6b3b67f77c16ff9854f35a5b8722d87cb74f580" "3d6b08cd1b1def3cc0bc6a3909f67475e5612dba9fa98f8b842433d827af5d30" "fc5fcb6f1f1c1bc01305694c59a1a861b008c534cae8d0e48e4d5e81ad718bc6" "71b172ea4aad108801421cc5251edb6c792f3adbaecfa1c52e94e3d99634dee7" "50ceca952b37826e860867d939f879921fac3f2032d8767d646dd4139564c68a" default))) | |
'(fci-rule-color "#383838") | |
'(vc-annotate-background "#2B2B2B") | |
'(vc-annotate-color-map (quote ((20 . "#BC8383") (40 . "#CC9393") (60 . "#DFAF8F") (80 . "#D0BF8F") (100 . "#E0CF9F") (120 . "#F0DFAF") (140 . "#5F7F5F") (160 . "#7F9F7F") (180 . "#8FB28F") (200 . "#9FC59F") (220 . "#AFD8AF") (240 . "#BFEBBF") (260 . "#93E0E3") (280 . "#6CA0A3") (300 . "#7CB8BB") (320 . "#8CD0D3") (340 . "#94BFF3") (360 . "#DC8CC3")))) | |
'(vc-annotate-very-old-color "#DC8CC3")) | |
(custom-set-faces | |
;; custom-set-faces was added by Custom. | |
;; If you edit it by hand, you could mess it up, so be careful. | |
;; Your init file should contain only one such instance. | |
;; If there is more than one, they won't work right. | |
) | |
;; Keep region when undoing in region | |
(defadvice undo-tree-undo (around keep-region activate) | |
(if (use-region-p) | |
(let ((m (set-marker (make-marker) (mark))) | |
(p (set-marker (make-marker) (point)))) | |
ad-do-it | |
(goto-char p) | |
(set-mark m) | |
(set-marker p nil) | |
(set-marker m nil)) | |
ad-do-it)) | |
;; (defun switch-lines () | |
;; (interactive) | |
;; (let ((marked-string (save-excursion (goto-char (mark)) | |
;; (buffer-substring-no-properties | |
;; (point) (line-end-position))))))) | |
;; turn on dired-details (hides excessive info in dired) | |
(require 'dired-details) | |
(dired-details-install) | |
;; Dired tries to guess a default target directory. | |
;; This means: if there is a Dired buffer displayed in the next | |
;; window, use its current directory, instead of this Dired buffer's | |
;; current directory. | |
(setq dired-dwim-target 't) | |
;; ensure tabs are specially colored, since they mess up things in | |
;; langs like coffeescript | |
(defface extra-whitespace-face | |
'((t (:background "pale green"))) | |
"Used for tabs and such.") | |
(defvar my-extra-keywords | |
'(("\t" . 'extra-whitespace-face))) | |
;; coffeescript specific hooks | |
(defun coffee-init () | |
(font-lock-add-keywords nil my-extra-keywords) | |
(define-key coffee-mode-map | |
;; move point forward a line and to indent level of prev line | |
(kbd "C-j") (lambda () (interactive) | |
(newline) | |
(let ((col (save-excursion (forward-line -1) | |
(beginning-of-line) | |
(skip-syntax-forward "-")))) | |
(indent-to col)))) | |
(hungry-delete-mode 1)) | |
(add-hook 'coffee-mode-hook | |
'coffee-init) | |
(add-hook 'ruby-mode-hook | |
'electric-pair-mode) | |
;; turn on haskell indentation | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | |
;; ensure undo-tree minor mode is available everywhere | |
(global-undo-tree-mode 1) | |
(put 'narrow-to-region 'disabled nil) | |
;; show line numbers | |
(global-linum-mode t) | |
;; start the emacs server | |
(server-start) | |
;; turn transient mark mode on | |
(transient-mark-mode 1) | |
(add-to-list 'load-path "~/.emacs.d/el-get/el-get") | |
(unless (require 'el-get nil 'noerror) | |
(with-current-buffer | |
(url-retrieve-synchronously | |
"https://raw.github.com/dimitri/el-get/master/el-get-install.el") | |
(goto-char (point-max)) | |
(eval-print-last-sexp))) | |
(add-to-list 'el-get-recipe-path "~/.emacs.d/el-get-user/recipes") | |
(el-get 'sync) | |
(require 'auto-complete-config) | |
(add-to-list 'ac-dictionary-directories "~/.emacs.d/dict") | |
(ac-config-default) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment