Last active
October 6, 2015 14:08
-
-
Save trevorc/3005603 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
;;;;;;;;;;;;;;;;;;;; | |
;; Initialization ;; | |
;;;;;;;;;;;;;;;;;;;; | |
(require 'cl) | |
(defmacro* dolist* ((iterator list &optional return-value) &rest body) | |
"Like `dolist' but `destructuring-bind's the elements of LIST. | |
If ITERATOR is a symbol then dolist* is just like `dolist' except | |
that it creates a fresh binding." | |
(declare (indent 1)) | |
(if (listp iterator) | |
(let ((i (make-symbol "DOLIST*-I-"))) | |
`(dolist (,i ,list ,return-value) | |
(destructuring-bind ,iterator ,i | |
,@body))) | |
`(dolist (,iterator ,list ,return-value) | |
(let ((,iterator ,iterator)) | |
,@body)))) | |
(setq user-emacs-directory | |
(file-truename (file-name-directory | |
(or load-file-name buffer-file-name)))) | |
(dolist* ((symbol . directory) | |
'((backups-dir . "backups") | |
(saves-dir . "saves") | |
(var-dir . "var"))) | |
(let ((path (file-name-as-directory | |
(expand-file-name directory user-emacs-directory)))) | |
(set (make-local-variable symbol) path) | |
(unless (file-directory-p path) | |
(make-directory path)))) | |
;;;;;;;;;;;;;;;;;;;; | |
;; Lisp Functions ;; | |
;;;;;;;;;;;;;;;;;;;; | |
(defun tc-scroll-down-keep-cursor () | |
(interactive) | |
(scroll-down 1)) | |
(defun tc-scroll-up-keep-cursor () | |
(interactive) | |
(scroll-up 1)) | |
(defun tc-switch-to-other-buffer () | |
(interactive) | |
(switch-to-buffer nil)) | |
(defun tc-other-other-window () | |
(interactive) | |
(other-window -1)) | |
(defun tc-eshell-other-window () | |
(interactive) | |
(switch-to-buffer-other-window "*eshell*") | |
(eshell)) | |
(defun tc-eshell-prompt () | |
(concat (abbreviate-file-name (eshell/pwd)) | |
(if (zerop (user-uid)) "# " "$ "))) | |
(defun tc-execute-extended-command () | |
(interactive) | |
(call-interactively | |
(fset 'tc-execute-extended-command | |
(if (fboundp 'smex) 'smex | |
'execute-extended-command)))) | |
(defun tc-install-packages () | |
(interactive) | |
(unless (fboundp 'package-install) | |
(error "package-install not available")) | |
(unless package-archive-contents | |
(package-refresh-contents)) | |
(dolist (package tc-install-packages) | |
(unless (package-installed-p package) | |
(package-install package)))) | |
(defun tc-linum-format (line-number) | |
(propertize (format tc-linum-format line-number) 'face 'linum)) | |
(defun tc-recompile-hook () | |
(let ((byte-compile-verbose nil) | |
(byte-compile-warnings nil) | |
(font-lock-verbose nil)) | |
(byte-compile-file buffer-file-name))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Editor Configuration ;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(fset 'yes-or-no-p 'y-or-n-p) | |
(fset 'display-startup-echo-area-message 'ignore) | |
(setq-default indent-tabs-mode nil) | |
(setq auto-save-list-file-prefix (expand-file-name ".saves-" var-dir) | |
auto-save-file-name-transforms `((".*" ,saves-dir t)) | |
backup-directory-alist `((".*" . ,backups-dir)) | |
delete-old-versions t | |
diff-switches "-u" | |
enable-local-eval nil | |
inhibit-default-init t | |
inhibit-splash-screen t | |
initial-scratch-message nil | |
kill-whole-line t | |
package-archives | |
'(("gnu" . "http://elpa.gnu.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/")) | |
ring-bell-function 'ignore | |
sentence-end-double-space nil | |
show-trailing-whitespace t | |
user-full-name "Trevor Caira" | |
user-mail-address "trevor@caira.com") | |
(set-face-attribute 'default nil :height 140) | |
(set-language-environment "UTF-8") | |
;;;;;;;;;;;;;;;;;; | |
;; Key Bindings ;; | |
;;;;;;;;;;;;;;;;;; | |
(dolist* ((key . command) | |
'(("M-p" . tc-scroll-down-keep-cursor) | |
("M-n" . tc-scroll-up-keep-cursor) | |
("M-x" . tc-execute-extended-command) | |
("C-c f" . ff-find-other-file) | |
("C-c i" . imenu) | |
("C-c <backspace>" . hungry-delete-backward) | |
("C-c <C-backspace>" . hungry-delete-forward) | |
("C-c <up>" . backward-kill-paragraph) | |
("C-c <down>" . kill-paragraph) | |
("C-x SPC" . fixup-whitespace) | |
("C-x C-b" . ibuffer) | |
("C-x g" . magit-status) | |
("C-x p" . tc-other-other-window) | |
("C-x i" . string-rectangle) | |
("C-x x" . delete-rectangle) | |
("C-x C-;" . comment-box) | |
("C-x C-/" . align-regexp) | |
("C-x 4 e" . tc-eshell-other-window) | |
("C-x 4 <up>" . buf-move-up) | |
("C-x 4 <down>" . buf-move-down) | |
("C-x 4 <left>" . buf-move-left) | |
("C-x 4 <right>" . buf-move-right) | |
("s-w" . delete-window) | |
("s-o" . ido-find-file) | |
("s-b" . tc-switch-to-other-buffer) | |
("s-r" . redraw-display))) | |
(global-set-key (read-kbd-macro key) command)) | |
;;;;;;;;;;;;;;; | |
;; Autoloads ;; | |
;;;;;;;;;;;;;;; | |
(when (or (fboundp 'package-initialize) | |
(require 'package nil t)) | |
(package-initialize)) | |
(require 'uniquify nil t) | |
(autoload 'buf-move-up "buffer-move" | |
"Swap the current buffer and the buffer above the split." t) | |
(autoload 'buf-move-down "buffer-move" | |
"Swap the current buffer and the buffer under the split." t) | |
(autoload 'buf-move-left "buffer-move" | |
"Swap the current buffer and the buffer on the left of the split." t) | |
(autoload 'buf-move-right "buffer-move" | |
"Swap the current buffer and the buffer on the right of the split." t) | |
;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Mode configuration ;; | |
;;;;;;;;;;;;;;;;;;;;;;;; | |
(dolist* ((mode . enable) | |
'((blink-cursor-mode . 0) | |
(fringe-mode . 0) | |
(menu-bar-mode . 0) | |
(scroll-bar-mode . 0) | |
(tool-bar-mode . 0) | |
(column-number-mode . 1) | |
(ido-mode . 1) | |
(haskell-indent-mode . haskell-mode-hook) | |
(linum-mode . prog-mode-hook) | |
(paredit-mode . clojure-mode-hook) | |
(paredit-mode . emacs-lisp-mode-hook) | |
(rainbow-delimiters-mode . prog-mode-hook) | |
(whitespace-mode . prog-mode-hook))) | |
(when (fboundp mode) | |
(if (symbolp enable) | |
(add-hook enable mode) | |
(funcall mode enable)))) | |
(add-hook 'c-mode-common-hook | |
(lambda () | |
(c-set-offset 'innamespace 0) | |
(c-toggle-hungry-state 1) | |
(cwarn-mode 1))) | |
(add-hook 'clojure-mode-hook | |
(lambda () | |
(dolist* ((key . command) | |
'(("C-c C-j" . nrepl-jack-in) | |
("C-c C-n" . clojure-insert-ns-form))) | |
(local-set-key (read-kbd-macro key) command)))) | |
(add-hook 'emacs-lisp-mode-hook | |
(lambda () | |
(add-hook 'after-save-hook 'tc-recompile-hook nil t) | |
(font-lock-add-keywords 'emacs-lisp-mode | |
`((,(concat | |
"(" (regexp-opt '("interactive" "dolist*") 'words)) | |
(1 font-lock-keyword-face)) | |
(,(regexp-opt '("t" "nil") 'words) | |
. font-lock-constant-face))) | |
(put 'font-lock-add-keywords 'lisp-indent-function 1))) | |
(add-hook 'linum-before-numbering-hook | |
(lambda () | |
(let* ((count (count-lines (point-min) (point-max))) | |
(width (+ 1 (length (number-to-string count)))) | |
(format (concat "%" (number-to-string width) "d "))) | |
(setq tc-linum-format format)))) | |
(eval-after-load 'paredit | |
'(dolist* ((key . command) | |
'(("C-c <left>" . paredit-forward-slurp-sexp) | |
("C-c <right>" . paredit-backward-slurp-sexp) | |
("RET" . paredit-newline) | |
("{" . paredit-open-curly) | |
("}" . paredit-close-curly) | |
("M-[" . paredit-wrap-square))) | |
(define-key paredit-mode-map (read-kbd-macro key) command))) | |
(dolist* ((symbol . filename) | |
'((eshell-last-dir-ring-file-name . "eshell.last") | |
(eshell-history-file-name . "eshell.hist") | |
(ido-save-directory-list-file . "ido.last") | |
(slime-repl-history-file . "slime.hist") | |
(smex-save-file . "smex-items") | |
(tetris-score-file . "tetris"))) | |
(set symbol (expand-file-name filename var-dir))) | |
(add-to-list 'completion-ignored-extensions ".hi") | |
(setq c-default-style "stroustrup" | |
css-indent-offset 2 | |
dired-use-ls-dired nil | |
dired-listing-switches "-aloF" | |
dired-ls-F-marks-symlinks t | |
erc-hide-list '("JOIN" "PART" "QUIT") | |
erc-nick "unlink" | |
eshell-banner-message "" | |
eshell-prompt-function 'tc-eshell-prompt | |
eshell-prompt-regexp "^[^#$\n]*[#$] " | |
haskell-indent-thenelse 2 | |
js-indent-level 2 | |
linum-format 'tc-linum-format | |
sh-basic-offset 2 | |
tc-install-packages '(apache-mode | |
buffer-move | |
clojure-mode | |
haskell-mode | |
hungry-delete | |
magit | |
nrepl | |
paredit | |
rainbow-delimiters | |
slime | |
smex) | |
uniquify-buffer-name-style 'forward | |
vc-handled-backends nil | |
whitespace-style '(face | |
trailing | |
newline | |
space-before-tab | |
tab-mark | |
newline-mark)) | |
(when (eq window-system 'ns) | |
(add-to-list 'tc-install-packages 'exec-path-from-shell) | |
(when (fboundp 'exec-path-from-shell-initialize) | |
(exec-path-from-shell-initialize))) | |
;;;;;;;;;;;;;;;;;;; | |
;; Customization ;; | |
;;;;;;;;;;;;;;;;;;; | |
(when window-system | |
(custom-set-variables | |
'(custom-enabled-themes '(solarized-light)) | |
'(custom-safe-themes | |
'("d2622a2a2966905a5237b54f35996ca6fda2f79a9253d44793cfe31079e3c92b" | |
default)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment