Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

233 lines (182 sloc) 7.845 kb
;-*-Emacs-Lisp-*-
;(setq mac-option-modifier 'alt)
;; Delete selection mode -- Treats selection like programs other than emacs
(delete-selection-mode 1)
(blink-cursor-mode 1)
(defun reload-keys ()
(interactive)
(load-file "~/.emacs.d/.keys"))
(defun reload-emacs ()
(interactive)
(load-file "~/.emacs.d/init.el"))
(defun vi-open-line-above ()
"Insert a newline above the current line and put point at beginning."
(interactive)
(unless (bolp)
(beginning-of-line))
(newline)
(forward-line -1)
(indent-according-to-mode))
(defun vi-open-line-below ()
"Insert a newline below the current line and put point at beginning."
(interactive)
(unless (eolp)
(end-of-line))
(newline-and-indent))
(defun vi-open-line (&optional abovep)
"Insert a newline below the current line and put point at beginning.
With a prefix argument, insert a newline above the current line."
(interactive "P")
(if abovep
(vi-open-line-above)
(vi-open-line-below)))
;Text Surgery
(defun nap-copy-line ()
"Copy current line into kill ring"
(interactive)
(kill-ring-save (line-beginning-position)
(line-beginning-position 2))
(message "Line copied."))
;(define-prefix-command 'text-surgery)
;(global-set-key (kbd "C-i") 'text-surgery)
;(define-key text-surgery (kbd "C-l") 'nap-copy-line)
;(global-set-key (kbd "C-y") 'nap-copy-line)
;(global-set-key (kbd "C-w") 'nap-copy-line)
;(global-set-key (kbd "C-p") 'clipboard-yank)
;(global-set-key (kbd "C-c C-w") 'mark-word)
;(global-set-key (kbd "C-.") 'increase-left-margin)
;(global-set-key (kbd "C-,") 'decrease-left-margin)
(define-key ctl-x-map (kbd "C-y") 'anything-show-kill-ring)
(define-key mode-specific-map (kbd "h") 'hs-hide-all)
(define-key mode-specific-map (kbd "s") 'hs-show-all)
;Project Ops
(global-set-key (kbd "C-s-t") 'find-file-in-project)
;Window Operations
;(define-prefix-command 'window-ops)
;(global-set-key (kbd "C-w") 'window-ops)
;(define-key window-ops (kbd "k") 'windmove-up)
;(define-key window-ops (kbpd "j") 'windmove-down)
;(define-key window-ops (kbd "h") 'windmove-left)
;(define-key window-ops (kbd "l") 'windmove-right)
(global-set-key (kbd "s-w") 'other-window)
(global-set-key (kbd "s-1") 'delete-other-windows)
(global-set-key (kbd "s-2") 'split-window-vertically)
(global-set-key (kbd "s-3") 'split-window-horizontally)
(global-set-key (kbd "s-0") 'delete-window)
;; Movement
;(define-prefix-command 'text-movement)
;(global-set-key (kbd "C-j") 'next-line)
;(global-set-key (kbd "C-k") 'previous-line)
;(global-set-key (kbd "A-C-l") 'forward-char)
;(global-set-key (kbd "A-C-h") 'backward-char)
;(global-set-key (kbd "C-l") 'forward-word)
;(global-set-key (kbd "C-h") 'backward-word)
;(global-set-key (kbd "A-C-j") 'next-line)
;(global-set-key (kbd "A-C-k") 'previous-line)
;(global-set-key (kbd "C-n") 'scroll-up)
;(global-set-key (kbd "C-u") 'scroll-down)
;(global-set-key (kbd "C-a") 'back-to-indentation)
;Smooth Mouse Scrolling
(setq mouse-wheel-scroll-amount '(2 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mosue 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
(defun indent-or-expand (arg)
"Either indent or expand based on context"
(interactive "*P")
(if (and
(or (bobp) (= ?w (char-syntax (char-before))))
(or (eobp) (not (= ?w (char-syntax (char-after))))))
(dabbrev-expand arg)
(indent-according-to-mode)))
(defun my-tab-fix ()
(local-set-key [tab] 'indent-or-expand))
(add-hook 'c-mode-hook 'my-tab-fix)
(add-hook 'sh-mode-hook 'my-tab-fix)
(add-hook 'emacs-lisp-mode-hook 'my-tab-fix)
(add-hook 'fundamental-mode-hook 'my-tab-fix)
(add-hook 'clojure-mode-hook 'my-tab-fix)
;;(add-hook 'ruby-mode 'my-tab-fix)
(define-key clojure-mode-map (kbd "s-i") 'slime-inspect)
(define-key clojure-mode-map (kbd "s-t") 'slime-clojure-run-tests)
(define-key clojure-mode-map (kbd "k") 'self-insert-command)
;;(define-key clojure-mode-map (kbd "C-s-<clear>") 'kill-sexp)
;;(define-key css-mode-map (kbd "C-k") 'paredit-kill)
(global-set-key (kbd "s-/") 'indent-or-expand)
;(global-set-key (kbd "A-o") 'scroll-down)
;(global-set-key (kbd "A-l") 'scroll-up)
(global-set-key (kbd "s-r") 'slime-eval-defun)
(global-set-key (kbd "C-o") 'vi-open-line-below)
(define-prefix-command 'emacs-lisp-ops)
(global-set-key (kbd "C-9") 'emacs-lisp-ops)
(define-key emacs-lisp-ops (kbd "C-d") 'eval-defun)
(define-key emacs-lisp-ops (kbd "C-e") 'eval-buffer)
(define-key emacs-lisp-ops (kbd "C-r") 'eval-defun)
(define-key emacs-lisp-ops (kbd "C-w") 'my-theme-cycle)
(define-key emacs-lisp-ops (kbd "C-k") 'reload-keys)
(define-key emacs-lisp-ops (kbd "C-m") 'reload-emacs)
;Project
(define-prefix-command 'project-opts)
(global-set-key (kbd "C-0") 'project-opts)
(define-key project-opts (kbd "C-0") 'anything)
(define-key project-opts (kbd "C-o") 'open-firefox)
(define-key project-opts (kbd "C-r") 'slime-eval-buffer)
(define-key project-opts (kbd "C-s") 'start-lein-swank)
(define-key project-opts (kbd "C-u") 'start-lein-deps-swank)
(define-key project-opts (kbd "C-n") 'start-lein-native-deps-swank)
(global-set-key (kbd "s-r") 'slime-eval-defun)
(global-set-key (kbd "s-SPC") 'anything)
(define-key project-opts (kbd "C-e") 'copy-expression-to-buffer)
(global-set-key (kbd "s-e") 'send-expression-in-buffer)
(defun exec-and-open-firefox ()
(interactive)
(slime-eval-defun)
(open-firefox))
(defun open-firefox ()
"Open Firefox"
(interactive)
(shell-command "open http://localhost:8080"))
(global-set-key (kbd "C-\\") 'indent-region)
;; Paredit
(define-key paredit-mode-map (kbd "C-w") 'paredit-backward-kill-word)
(define-key ruby-mode-map (kbd "<RET>") 'reindent-then-newline-and-indent)
;;(define-key rinari-mode-map (kbd "<RET>") 'newline-and-indent)
(define-key global-map (kbd "RET") 'reindent-then-newline-and-indent)
(defun run-ruby-file ()
(interactive)
(compile (concat "ruby -w " buffer-file-name)))
(define-key ruby-mode-map (kbd "s-r") 'run-ruby-file)
;; eproject
(global-set-key (kbd "s-f") 'eproject-find-file)
;; make cursor movement keys under right hand's home-row.
(global-set-key (kbd "s-h") 'backward-char) ; was indent-new-comment-line
(global-set-key (kbd "s-l") 'forward-char) ; was downcase-word
(global-set-key (kbd "s-k") 'previous-line) ; was tab-to-tab-stop
(global-set-key (kbd "s-j") 'next-line) ; was kill-sentence
(global-set-key (kbd "C-M-h") 'backward-word) ; was tab-to-tab-stop
(global-set-key (kbd "C-M-l") 'forward-word) ; was kill-sentence
(global-set-key (kbd "s-m") 'ido-execute-command) ; was kill-sentence
(global-set-key (kbd "s-p") 'ecb-toggle-ecb-windows)
(global-set-key (kbd "s-o") 'ecb-toggle-layout)
(global-set-key (kbd "C-w") 'sane-backward-kill-word)
(global-set-key (kbd "M-p") 'fill-paragraph)
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "M-p") 'isearch-backward-regexp)
(global-set-key (kbd "C-s-<backspace>") 'backward-word)
(global-set-key (kbd "C-s-<268632076>") 'forward-word)
(global-set-key (kbd "C-s-<clear>") 'backward-paragraph)
(global-set-key (kbd "C-s-<linefeed>") 'forward-paragraph)
(global-set-key (kbd "C-c C-k") 'kill-this-buffer)
(global-set-key (kbd "C-c k") 'kill-this-buffer)
(defun backward-kill-line (arg)
"Delete the linefeed and carriage return of the previous line when point is at the beginning of the current line"
(interactive "p")
(let ((prev-char (char-before (point)))
(at-beginning-of-line nil))
(if (and (characterp prev-char)
(or (char-equal prev-char 10)
(char-equal prev-char 13)))
(backward-delete-char 1)
(kill-line 0))))
(global-set-key (kbd "C-s-<clear>") 'backward-kill-line)
(global-set-key (kbd "s-n") 'yas/expand)
Jump to Line
Something went wrong with that request. Please try again.