Skip to content

Instantly share code, notes, and snippets.

@tjweir
Created December 14, 2010 15:42
Show Gist options
  • Save tjweir/740595 to your computer and use it in GitHub Desktop.
Save tjweir/740595 to your computer and use it in GitHub Desktop.
.emacs
(global-font-lock-mode t)
(set-default-font "-apple-Cousine-medium-normal-normal-*-12-*-*-*-m-0-iso10646-")
(add-to-list 'load-path "/Users/tjweir/.emacs.d/vendor/color-theme")
(require 'color-theme)
(color-theme-initialize)
(windmove-default-keybindings)
(setq use-file-dialog nil)
;; "y or n" instead of "yes or no"
(fset 'yes-or-no-p 'y-or-n-p)
;; Highlight regions and add special behaviors to regions.
;; "C-h d transient" for more info
(setq transient-mark-mode t)
;; Display line and column numbers
(setq line-number-mode t)
(setq column-number-mode t)
(global-set-key "\C-c\C-w" 'backward-kill-word)
;; Remove unnecessary gui stuff
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode 1))
(blink-cursor-mode 1) ;; no blink
(set-background-color "black")
(set-face-background 'default "black")
(set-face-background 'region "black")
(set-face-foreground 'default "white")
(set-face-foreground 'region "gray60")
(set-foreground-color "white")
(set-cursor-color "red")
;; Scala Mode
(add-to-list 'load-path "/Users/tjweir/code/scala_compilers/scala/misc/scala-tool-support/emacs")
(defun scala-turnoff-indent-tabs-mode ()
(setq indent-tabs-mode nil))
;; scala mode hooks
(add-hook 'scala-mode-hook 'scala-turnoff-indent-tabs-mode)
(require 'scala-mode-auto)
(add-to-list 'auto-mode-alist '("\\.scala$" . scala-mode))
(add-to-list 'load-path "/Users/tjweir/code/ensime/dist/elisp/")
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
;; MINI HOWTO: open .scala file. Ensure bin/server.sh is executable. M-x ensime
;;
;; The following lines are always needed. Choose your own keys.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(add-to-list 'load-path "/Users/tjweir/.emacs.d/utilities/emacs-wiki")
(require 'emacs-wiki)
(show-paren-mode t)
(iswitchb-mode t)
(add-to-list 'load-path "/Users/tjweir/.emacs.d/vendor")
(require 'dired+)
(require 'textmate)
(require 'peepopen)
(textmate-mode)
(require 'yasnippet-bundle)
(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.
'(inhibit-startup-screen t)
'(js-auto-indent-flag t)
'(js-indent-level 2)
'(js2-auto-indent-p t)
'(js2-indent-on-enter-key t)
'(tab-width 2))
(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.
)
;; tabs?
'(standard-indent 2)
'(tab-width 2)
;; colorscheme
;;(color-theme-snowish)
;;(color-theme-zen-and-art)
;;(color-theme-snow)
(set-face-attribute 'default nil :font "Cousine-14")
;; remap to hippie expand
(global-set-key (kbd "M-/") 'hippie-expand)
(global-set-key [(meta g)] 'goto-line)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
(global-set-key [kp-delete] 'delete-char)
;; Mobile Org
(setq org-directory "DIR")
(setq org-mobile-inbox-for-pull "flagged.org")
(setq org-mobile-directory "MobileOrg")
(setq org-agenda-files (quote ("~/tyler.org")))
(setq org-default-notes-file (concat org-directory "~/notes.org"))
(define-key global-map "\C-cc" 'org-capture)
;; WINDOW STUFF
(defun split-window-4()
"Splite window into 4 sub-window"
(interactive)
(if (= 1 (length (window-list)))
(progn (split-window-vertically)
(split-window-horizontally)
(other-window 2)
(split-window-horizontally)
)
)
)
(defun split-v ()
(interactive)
(if (= 2 (length (window-list)))
(let (( thisBuf (window-buffer))
( nextBuf (progn (other-window 1) (buffer-name))))
(progn (delete-other-windows)
(split-window-horizontally)
(set-window-buffer nil thisBuf)
(set-window-buffer (next-window) nextBuf)
))
)
)
(defun split-h ()
(interactive)
(if (= 2 (length (window-list)))
(let (( thisBuf (window-buffer))
( nextBuf (progn (other-window 1) (buffer-name))))
(progn (delete-other-windows)
(split-window-vertically)
(set-window-buffer nil thisBuf)
(set-window-buffer (next-window) nextBuf)
))
)
)
(defun split-v-3 ()
"Change 3 window style from horizontal to vertical"
(interactive)
(select-window (get-largest-window))
(if (= 3 (length (window-list)))
(let ((winList (window-list)))
(let ((1stBuf (window-buffer (car winList)))
(2ndBuf (window-buffer (car (cdr winList))))
(3rdBuf (window-buffer (car (cdr (cdr winList))))))
(message "%s %s %s" 1stBuf 2ndBuf 3rdBuf)
(delete-other-windows)
(split-window-horizontally)
(set-window-buffer nil 1stBuf)
(other-window 1)
(set-window-buffer nil 2ndBuf)
(split-window-vertically)
(set-window-buffer (next-window) 3rdBuf)
(select-window (get-largest-window))
)
)
)
)
(defun split-h-3 ()
"Change 3 window style from vertical to horizontal"
(interactive)
(select-window (get-largest-window))
(if (= 3 (length (window-list)))
(let ((winList (window-list)))
(let ((1stBuf (window-buffer (car winList)))
(2ndBuf (window-buffer (car (cdr winList))))
(3rdBuf (window-buffer (car (cdr (cdr winList))))))
(message "%s %s %s" 1stBuf 2ndBuf 3rdBuf)
(delete-other-windows)
(split-window-vertically)
(set-window-buffer nil 1stBuf)
(other-window 1)
(set-window-buffer nil 2ndBuf)
(split-window-horizontally)
(set-window-buffer (next-window) 3rdBuf)
(select-window (get-largest-window))
)
)
)
)
(defun roll-v-3 ()
"Rolling 3 window buffers clockwise"
(interactive)
(select-window (get-largest-window))
(if (= 3 (length (window-list)))
(let ((winList (window-list)))
(let ((1stWin (car winList))
(2ndWin (car (cdr winList)))
(3rdWin (car (cdr (cdr winList)))))
(let ((1stBuf (window-buffer 1stWin))
(2ndBuf (window-buffer 2ndWin))
(3rdBuf (window-buffer 3rdWin))
)
(set-window-buffer 1stWin 3rdBuf)
(set-window-buffer 2ndWin 1stBuf)
(set-window-buffer 3rdWin 2ndBuf)
)
)
)
)
)
(defun change-split-type ()
"Changes splitting from vertical to horizontal and vice-versa"
(interactive)
(if (= 2 (length (window-list)))
(let ((thisBuf (window-buffer))
(nextBuf (progn (other-window 1) (buffer-name)))
(split-type (if (= (window-width)
(frame-width))
'split-window-horizontally
'split-window-vertically)))
(progn
(delete-other-windows)
(funcall split-type)
(set-window-buffer nil thisBuf)
(set-window-buffer (next-window) nextBuf))))
)
(defun change-split-type-3 ()
"Change 3 window style from horizontal to vertical and vice-versa"
(interactive)
(select-window (get-largest-window))
(if (= 3 (length (window-list)))
(let ((winList (window-list)))
(let ((1stBuf (window-buffer (car winList)))
(2ndBuf (window-buffer (car (cdr winList))))
(3rdBuf (window-buffer (car (cdr (cdr winList)))))
(split-3
(lambda(1stBuf 2ndBuf 3rdBuf split-1 split-2)
"change 3 window from horizontal to vertical and vice-versa"
(message "%s %s %s" 1stBuf 2ndBuf 3rdBuf)
(delete-other-windows)
(funcall split-1)
(set-window-buffer nil 1stBuf)
(other-window 1)
(set-window-buffer nil 2ndBuf)
(funcall split-2)
(set-window-buffer (next-window) 3rdBuf)
(select-window (get-largest-window))
))
(split-type-1 nil)
(split-type-2 nil)
)
(if (= (window-width) (frame-width))
(setq split-type-1 'split-window-horizontally split-type-2 'split-window-vertically)
(setq split-type-1 'split-window-vertically split-type-2 'split-window-horizontally))
(funcall split-3 1stBuf 2ndBuf 3rdBuf split-type-1 split-type-2)
))))
;; fuzzy search
(require 'fuzzy)
(turn-on-fuzzy-isearch)
;; zen coding
(add-to-list 'load-path "~/.emacs.d/vendor/zencoding/")
(require 'zencoding-mode)
(add-hook 'sgml-mode-hook 'zencoding-mode)
;; smex
;;(add-to-list 'load-path "~/.emacs.d/vendor/sm")
(require 'smex)
(smex-initialize)
(require 'undo-tree)
(setq load-path (append (list (expand-file-name "~/.emacs.d/vendor/js2/")) load-path))
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(setq-default indent-tabs-mode nil)
(setq tab-width 2) ; or any other preferred value
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
;; mimics the vim superstar
(defun my-isearch-word-at-point ()
(interactive)
(call-interactively 'isearch-forward-regexp))
(defun my-isearch-yank-word-hook ()
(when (equal this-command 'my-isearch-word-at-point)
(let ((string (concat "\\<"
(buffer-substring-no-properties
(progn (skip-syntax-backward "w_") (point))
(progn (skip-syntax-forward "w_") (point)))
"\\>")))
(if (and isearch-case-fold-search
(eq 'not-yanks search-upper-case))
(setq string (downcase string)))
(setq isearch-string string
isearch-message
(concat isearch-message
(mapconcat 'isearch-text-char-description
string ""))
isearch-yank-flag t)
(isearch-search-and-update))))
(add-hook 'isearch-mode-hook 'my-isearch-yank-word-hook)
;;(global-set-key "\C-8" 'backward-kill-word)
(global-hl-line-mode 1)
(set-face-background 'highlight "#222")
(set-face-foreground 'highlight "#FFF")
(set-cursor-color "#F00")
;; this is for peepopen to open in buffers not new Frames
(setq ns-pop-up-frames nil)
;;emulated % in vim
(defun goto-match-paren (arg)
"Go to the matching parenthesis if on parenthesis AND last command is a movement command, otherwise insert %.
vi style of % jumping to matching brace."
(interactive "p")
(message "%s" last-command)
(if (not (memq last-command '(
set-mark
cua-set-mark
goto-match-paren
down-list
up-list
end-of-defun
beginning-of-defun
backward-sexp
forward-sexp
backward-up-list
forward-paragraph
backward-paragraph
end-of-buffer
beginning-of-buffer
backward-word
forward-word
mwheel-scroll
backward-word
forward-word
mouse-start-secondary
mouse-yank-secondary
mouse-secondary-save-then-kill
move-end-of-line
move-beginning-of-line
backward-char
forward-char
scroll-up
scroll-down
scroll-left
scroll-right
mouse-set-point
next-buffer
previous-buffer
)
))
(self-insert-command (or arg 1))
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1))))))
(global-set-key (kbd "%") 'goto-match-paren)
(global-set-key (kbd "C-z") 'undo)
;; ENSIME Stuff
(defun make-lift-doc-url (type &optional member)
(ensime-make-java-doc-url-helper
"http://main.scala-tools.org/mvnsites-snapshots/liftweb/Ãscaladocs/" type member))
(add-to-list 'ensime-doc-lookup-map '("net\\.liftweb\\." . make-lift-doc-url))
(add-to-list 'load-path "/Users/tjweir/.emacs.d/vendor/full-ack")
(autoload 'ack-same "full-ack" nil t)
(autoload 'ack "full-ack" nil t)
(autoload 'ack-find-same-file "full-ack" nil t)
(autoload 'ack-find-file "full-ack" nil t)
(defun line-to-top-of-window ()
"Shift current line to the top of the window- i.e. zt in Vim"
(interactive)
(set-window-start (selected-window) (point))
)
(defun line-to-bottom-of-window ()
"Shift current line to the botom of the window- i.e. zb in Vim"
(interactive)
(line-to-top-of-window)
(scroll-down (- (window-height) 3))
)
(defun ctrl-e-in-vi (n)
(interactive "p")
(scroll-up n))
(defun ctrl-y-in-vi (n)
(interactive "p")
(scroll-down n))
(global-set-key "\M-n" 'ctrl-e-in-vi)
(global-set-key "\M-p" 'ctrl-y-in-vi)
(global-set-key "\C-x\C-a\C-a" 'line-to-top-of-window)
(global-set-key "\C-x\C-e" 'line-to-bottom-of-window)
(color-theme-github)
(require 'bs)
(global-set-key "\C-x\C-b" 'bs-show)
(add-to-list 'load-path "/Users/tjweir/g/twittering-mode")
(require 'twittering-mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment