Created
January 13, 2012 05:08
-
-
Save oblique63/1604782 to your computer and use it in GitHub Desktop.
.emacs bootstrap file
This file contains hidden or 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
;;--- PATH setup ------------------------------------------------------------------------- | |
(when (string-match "apple-darwin" system-configuration) | |
; add '/usr/local/bin' to my PATH | |
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin")) | |
(setq exec-path (append exec-path '("/usr/local/bin")))) | |
(setenv "PATH" (concat (getenv "PATH") ":/cygwin/bin")) | |
(setq exec-path (append exec-path '("/cygwin/bin"))) | |
;;=== Package Management ================================================================= | |
;;--- El-get ----------------------------------------------------------------------------- | |
(defun eval-url (url) | |
(let ((buffer (url-retrieve-synchronously url))) | |
(save-excursion | |
(set-buffer buffer) | |
(goto-char (point-min)) | |
(re-search-forward "^$" nil 'move) | |
(eval-region (point) (point-max)) | |
(kill-buffer (current-buffer))))) | |
(defun install-el-get () | |
(eval-url | |
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")) | |
(ignore-errors | |
(let ((default-directory "~/.emacs.d/el-get/")) | |
(normal-top-level-add-subdirs-to-load-path))) | |
(setq el-get-first-run nil) | |
(unless (require 'el-get nil t) | |
(install-el-get) | |
(el-get-emacswiki-refresh t) | |
(setq el-get-first-run t)) | |
;;--- Elpa ------------------------------------------------------------------------------- | |
(defun install-elpa () | |
(eval-url "http://tromey.com/elpa/package-install.el")) | |
(ignore-errors | |
(progn | |
(load-file "~/.emacs.d/elpa/package.el") | |
(require 'package))) | |
(if (or (not (featurep 'package)) | |
el-get-first-run) | |
(install-elpa)) | |
;; TODO: properly handle emacs < 24 without elpa installation | |
;(if (not (featurep 'package)) | |
;(if (< emacs-major-version 24) | |
; (progn | |
; ;; if elpa is installed, but we're in an older emacs, download the | |
; ;; newer 'package.el' | |
; (if (not (file-exists-p "~/.emacs.d/package23.el")) | |
; (url-copy-file "http://repo.or.cz/w/emacs.git/blob_plain/1a0a666f941c99882093d7bd08ced15033bc3f0c:/lisp/emacs-lisp/package.el" | |
; "~/.emacs.d/package23.el")) | |
; ;(eval-url "http://repo.or.cz/w/emacs.git/blob_plain/1a0a666f941c99882093d7bd08ced15033bc3f0c:/lisp/emacs-lisp/package.el") | |
; ;(eval-url "http://www.emacswiki.org/emacs-en/download/backport-package.el") | |
; (load-file "~/.emacs.d/package23.el") | |
; (require 'package) ) | |
; (install-elpa));) | |
(ignore-errors | |
(let ((default-directory "~/.emacs.d/elpa/")) | |
(normal-top-level-add-subdirs-to-load-path))) | |
;; additional elpa repos | |
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/") | |
("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/"))) | |
(package-initialize) | |
;;------------------------------------------------------------------------------------------ | |
;; El-get Recipies ------------------------------------------------------------------------- | |
(setq el-get-sources | |
'( | |
; (:name auto-complete-github | |
; :website "http://cx4a.org/software/auto-complete/" | |
; :description "The most intelligent auto-completion extension." | |
; :type github | |
; :pkgname "m2ym/auto-complete" | |
; :load-path "." | |
; :post-init (progn | |
; (require 'auto-complete) | |
; (add-to-list 'ac-dictionary-directories | |
; (expand-file-name "dict")) | |
; (require 'auto-complete-config) | |
; (ac-config-default))) | |
(:name css-mode | |
:description "Minor mode for CSS" | |
:features css-mode | |
:type elpa) | |
(:name unityjs-mode | |
:type git | |
:url "git://github.com/naruse/EmacsUnityScript.git" | |
:load "unityjs-mode.el" | |
:compile "unityjs-mode.el" | |
:post-init (lambda () | |
(autoload 'unityjs-mode "unityjs-mode" nil t))) | |
(:name jinja2-mode | |
:type git | |
:url "git://github.com/paradoxxxzero/jinja2-mode.git" | |
:load "jinja2-mode.el" | |
:compile "jinja2-mode.el" | |
:post-init (lambda () | |
(autoload 'jinja2-mode "jinja2-mode" nil t) )) | |
;(:name g-client | |
; :type git | |
; :url "git://github.com/jaalto/emacs-epackage--g-client.git" | |
; :post-init (lambda () | |
; (autoload 'g-client-epackage-install "g-client-epackage-install" nil t))) | |
(:name auto-pair-plus | |
:description "Autopair handler to extend Autopair behavior." | |
:type git | |
:url "git://github.com/emacsmirror/auto-pair-plus.git" | |
:depends autopair) | |
(:name dired-details+ | |
:type http | |
:url "http://www.emacswiki.org/emacs/download/dired-details%2b.el" | |
:depends fit-frame autofit-frame | |
:post-init (lambda () (require 'dired-details+))) | |
(:name python-pylint :type elpa) | |
(:name pep8 :type elpa) | |
(:name dtrt-indent :type elpa) | |
(:name tron-theme :type elpa) | |
(:name pastels-on-dark-theme :type elpa) | |
(:name monokai-theme :type elpa) | |
(:name django-theme :type elpa) | |
(:name color-theme-actress :type elpa) | |
(:name color-theme-dg :type elpa) | |
(:name color-theme-gruber-darker :type elpa) | |
(:name color-theme-wombat+ :type elpa) | |
(:name color-theme-molokai :type elpa) | |
(:name color-theme-sanityinc-tomorrow :type elpa) | |
(:name color-theme-sanityinc-solarized :type elpa) | |
(:name color-theme-colorful-obsolescence :type elpa) | |
(:name color-theme-active :type elpa) | |
(:name lorem-ipsum :type elpa) | |
(:name starter-kit-ruby :type elpa) | |
(:name starter-kit-js :type elpa) | |
(:name starter-kit-eshell :type elpa) | |
(:name flymake-haml :type elpa) | |
(:name flymake-jslint :type elpa) | |
(:name flymake-jshint :type elpa) | |
(:name flymake-sass :type elpa) | |
(:name flymake-coffee :type elpa) | |
(:name yas-jit :type elpa) | |
(:name color-theme-tangotango | |
:description "Another color theme based on the Tango palette." | |
:type git | |
:url "https://github.com/juba/color-theme-tangotango.git" | |
:depends color-theme | |
:post-init (lambda () | |
(autoload 'color-theme-tangotango "color-theme-tangotango" | |
"color-theme: tangotango" t) )) | |
(:name coffee-mode-github | |
:type http | |
:url "https://raw.github.com/defunkt/coffee-mode/master/coffee-mode.el" | |
:post-init (lambda () (require 'coffee-mode))) | |
(:name desktop | |
:type http | |
:url "http://repo.or.cz/w/emacs.git/blob_plain/HEAD:/lisp/desktop.el" | |
:post-init (lambda () (require 'desktop))) | |
(:name desktop-recover | |
:type http | |
:url "https://raw.github.com/doomvox/desktop-recover/master/desktop-recover.el" | |
:depends desktop | |
:post-init (lambda () (require 'desktop-recover))) | |
(:name desktop-menu | |
:type http | |
:url "http://www.emacswiki.org/emacs/download/desktop-menu.el" | |
:depends desktop | |
:post-init (lambda () (require 'desktop-menu))) | |
;(:name color-theme-sanityinc | |
; :description "Two pleasant medium-contrast Emacs color themes in light and dark flavours" | |
; :type github | |
; :pkgname "purcell/color-theme-sanityinc" | |
; :depends color-theme | |
; :post-init (progn | |
; (autoload 'color-theme-sanityinc-light "color-theme-sanityinc" | |
; "color-theme: sanityinc-light" t) | |
; (autoload 'color-theme-sanityinc-dark "color-theme-sanityinc" | |
; "color-theme: sanityinc-dark" t) )) | |
(:name popwin | |
:description "Popup Window Manager." | |
:website "https://github.com/m2ym/popwin-el" | |
:type http | |
:url "https://raw.github.com/m2ym/popwin-el/1a456562aac5c18d04cc4c9c2f8816aec9615b66/popwin.el" | |
:pkgname "m2ym/popwin-el" | |
:features popwin | |
:load "popwin.el" | |
:compile "popwin.el" | |
:post-init (lambda () | |
(require 'popwin) | |
(setq display-buffer-function 'popwin:display-buffer))) | |
(:name inf-ruby :type elpa) | |
(:name ruby-compilation :type elpa) | |
; (:name slim-mode | |
; :description "Slim template mode" | |
; :type http | |
; :url "https://raw.github.com/stonean/slim/master/extra/slim-mode.el" | |
; :load "slim-mode.el" | |
; :compile "slim-mode.el" | |
; :features slim-mode | |
; :post-init (lambda () | |
; (autoload 'slim-mode "slim-mode" nil t))) | |
(:name window-numbering | |
:description "Assigns a number to each window in a frame, accessible by 'M-#'" | |
:type http | |
:url "http://nschum.de/src/emacs/window-numbering-mode/window-numbering.el" | |
:post-init (lambda () | |
(require 'window-numbering) | |
(window-numbering-mode 1))) | |
;(:name zenburn-theme | |
; :description "Zenburn theme for Emacs" | |
; :type http | |
; :url "https://raw.github.com/djcb/elisp/master/themes/zenburn-theme.el" | |
; :features zenburn-theme | |
; :post-init (lambda () | |
; (add-to-list 'custom-theme-load-path | |
; (el-get-package-directory "zenburn-theme")))) | |
(:name ruby-mode-github | |
:type git | |
:url "git://github.com/jaalto/emacs-epackage--ruby-mode.git" | |
:features ruby-mode | |
:load "ruby-mode.el" | |
:compile "ruby-mode.el" | |
:post-init (lambda () (require 'ruby-mode))) | |
(:name sr-speedbar | |
:type emacswiki | |
:description "Same frame speedbar" | |
:post-init (lambda () (require 'sr-speedbar))) | |
(:name js2-mode-mooz | |
:type git | |
:url "git://github.com/mooz/js2-mode.git" | |
:load "js2-mode.el" | |
:compile ("js2-mode.el") | |
:features js2-mode) | |
;(:name yasnippet-github | |
; :website "http://code.google.com/p/yasnippet/" | |
; :description "YASnippet is a template system for Emacs." | |
; :type git | |
; :url "https://github.com/capitaomorte/yasnippet.git" | |
; :features "yasnippet" | |
; :prepare (lambda () | |
; ;; Set up the default snippets directory | |
; ;; | |
; ;; Principle: don't override any user settings | |
; ;; for yas/snippet-dirs, whether those were made | |
; ;; with setq or customize. If the user doesn't | |
; ;; want the default snippets, she shouldn't get | |
; ;; them! | |
; (unless (or (boundp 'yas/snippet-dirs) (get 'yas/snippet-dirs 'customized-value)) | |
; (setq yas/snippet-dirs | |
; (list (concat el-get-dir (file-name-as-directory "yasnippet") "snippets"))))) | |
; | |
; :post-init (lambda () | |
; ;; Trick customize into believing the standard | |
; ;; value includes the default snippets. | |
; ;; yasnippet would probably do this itself, | |
; ;; except that it doesn't include an | |
; ;; installation procedure that sets up the | |
; ;; snippets directory, and thus doesn't know | |
; ;; where those snippets will be installed. See | |
; ;; http://code.google.com/p/yasnippet/issues/detail?id=179 | |
; (put 'yas/snippet-dirs 'standard-value | |
; ;; as cus-edit.el specifies, "a cons-cell | |
; ;; whose car evaluates to the standard | |
; ;; value" | |
; (list (list 'quote | |
; (list (concat el-get-dir (file-name-as-directory "yasnippet") "snippets")))))) | |
; ;; byte-compile load vc-svn and that fails | |
; ;; see https://github.com/dimitri/el-get/issues/200 | |
; :compile nil) | |
)) | |
;; Install Packages -------------------------------------------------------------------- | |
(setq my-el-get-packages | |
(append | |
'( | |
auto-install | |
auto-pair-plus | |
;auto-complete | |
popwin | |
auto-complete | |
;auto-complete+ | |
auto-complete-extension | |
auto-complete-clang | |
auto-complete-css | |
auto-complete-ruby | |
auto-complete-emacs-lisp | |
;auto-complete-yasnippet | |
;ac-anything2 | |
;apropos+ | |
buffer-move | |
color-theme | |
color-theme-almost-monokai | |
color-theme-chocolate-rain | |
color-theme-desert | |
color-theme-ir-black | |
;color-theme-mac-classic -- light theme, eww | |
color-theme-railscasts | |
color-theme-solarized | |
color-theme-subdued | |
color-theme-tango-2 | |
color-theme-tango | |
color-theme-tangotango | |
color-theme-tomorrow | |
color-theme-twilight | |
color-theme-zen-and-art | |
tron-theme | |
pastels-on-dark-theme | |
monokai-theme | |
django-theme | |
color-theme-actress | |
color-theme-dg | |
color-theme-gruber-darker | |
color-theme-wombat+ | |
color-theme-molokai | |
color-theme-sanityinc-tomorrow | |
color-theme-sanityinc-solarized | |
color-theme-colorful-obsolescence | |
color-theme-active | |
desktop | |
desktop-menu | |
desktop-recover | |
lorem-ipsum | |
starter-kit-ruby | |
starter-kit-js | |
starter-kit-eshell | |
;color-theme-zenburn -- redundant and possibly old? | |
;zenburn-theme | |
csharp-mode | |
clojure-mode | |
css-mode | |
csv-mode | |
csv-nav | |
coffee-mode-github | |
;cppsense | |
diff-git | |
dired+ | |
;dired-single | |
dired-sync | |
;django-mode -- TODO: replace with recipie for https://github.com/myfreeweb/django-mode | |
doc-mode | |
dtrt-indent | |
ecb | |
egg | |
;ess | |
;emacs-goodies-el | |
;fsharp-mode -- repo's not working for me | |
;gist | |
google-c-style | |
haml-mode | |
;haskell-mode | |
;haskell-mode-exts | |
hlinum | |
;hs-mode -- repo not working? | |
;ipython -- has problems loading | |
jinja2-mode | |
js2-mode-mooz | |
js-comint | |
json | |
keywiz | |
linum-ex | |
lua-mode | |
maxframe | |
markdown-mode | |
minimap | |
;nav | |
pep8 | |
;pymacs | |
python-mode | |
python-pylint | |
regex-tool | |
rst-mode | |
rspec-mode | |
;ruby-block | |
;ruby-end | |
ruby-mode | |
;ruby-mode-github | |
rhtml-mode | |
;rinari | |
ropemacs | |
haml-mode | |
sass-mode | |
;scss-mode | |
;slim-mode -- throws a lisp error.. | |
smart-tab | |
smex | |
;sr-speedbar -- 'nav' is better | |
;smooth-scrolling -- NOT smooth... | |
textmate | |
;theme-roller -- conflicts with other themes | |
unityjs-mode | |
vline | |
window-numbering | |
yaml-mode | |
;yasnippet | |
zencoding-mode | |
) | |
(mapcar 'el-get-source-name el-get-sources))) | |
;(el-get) | |
;(ignore-errors | |
;(if el-get-first-run | |
(el-get 'sync my-el-get-packages) | |
;(el-get) ;) | |
;) | |
;;--------------------------------------------------------------------------------------------- | |
;;=== Customizations ========================================================================== | |
;; TODO: add autoload instead of require if possible, and/or check if | |
;; the current require statement returns anything useful. | |
;(defun require-if-needed (pkg) | |
; (if (not (featurep pkg)) | |
; (require pkg nil t))) | |
;;--- General Tweaks -------------------------------------------------------------------------- | |
(prefer-coding-system 'utf-8) | |
(cua-mode 1) | |
(line-number-mode t) | |
(setq-default line-spacing 2) | |
(setq inhibit-splash-screen t) | |
(column-number-mode t) | |
(delete-selection-mode t) | |
(setq x-select-enable-clipboard t) | |
(setq diredp-find-file-reuse-dir-buffer t) | |
(setq diredp-mouse-find-file-reuse-dir-buffer t) | |
(if (fboundp 'Modify-frame-parameters) (Modify-frame-parameters nil '((wait-for-wm . nil)))) | |
(if (fboundp 'global-linum-mode) (global-linum-mode)) | |
(if (fboundp 'visual-line-mode) (visual-line-mode)) | |
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) | |
(if (fboundp 'tabbar-mode) (tabbar-mode -1)) | |
(if (require 'maxframe nil t) (maximize-frame)) | |
(global-auto-revert-mode 1) | |
; navigate windows with M-<arrows> | |
(windmove-default-keybindings 'meta) | |
(setq windmove-wrap-around t) | |
;; Show full path of buffer | |
;; [source: http://lists.gnu.org/archive/html/help-gnu-emacs/2011-01/msg00585.html] | |
(setq-default mode-line-buffer-identification | |
(list 'buffer-file-name | |
(propertized-buffer-identification "%12f") | |
(propertized-buffer-identification "%12b"))) | |
(add-hook 'dired-mode-hook | |
(lambda () | |
;; TODO: handle (DIRECTORY FILE ...) list value for dired-directory | |
(setq mode-line-buffer-identification | |
;; emulate "%17b" (see dired-mode): | |
'(:eval | |
(propertized-buffer-identification | |
(if (< (length default-directory) 17) | |
(concat default-directory | |
(make-string (- 17 (length default-directory)) | |
?\s)) | |
default-directory)))))) | |
;; Show full path of buffer in title bar | |
(setq-default | |
frame-title-format | |
(list '((buffer-file-name " %f" (dired-directory | |
dired-directory | |
(revert-buffer-function " %b" | |
("%b - Dir: " default-directory))))))) | |
(setq-default | |
icon-title-format | |
(list '((buffer-file-name " %f" (dired-directory | |
dired-directory | |
(revert-buffer-function " %b" | |
("%b - Dir: " default-directory))))))) | |
;;--- Dired ----------------------------------------------------------------------------------- | |
(setq dired-details-hidden-string "") ;; dired-details | |
(toggle-diredp-find-file-reuse-dir t) ;; dired+ | |
;;--- Desktop --------------------------------------------------------------------------------- | |
(desktop-save-mode 1) | |
(setq desktop-menu-directory "~/.emacs.d/") | |
;;--- Nav ------------------------------------------------------------------------------------- | |
(defun single-nav () | |
(interactive) | |
(setq nav-buffer (get-buffer "*nav*")) | |
(if nav-buffer | |
(progn | |
(switch-to-buffer-other-window nav-buffer) | |
(nav-shrink-wrap)) | |
(nav) )) | |
;; TODO: fix this to actually work... | |
;(defun nav-ibuffer-toggle () | |
; (setq nav-buffer (get-buffer "*nav*")) | |
; (setq ibuff-bs (get-buffer "*ibuffer-bs*")) | |
; | |
; (if (and (not nav-buffer) ibuff-bs) | |
; (nav)) | |
; (if (and (not ibuff-bs) nav-buffer) | |
; (ibuffer-bs-show)) | |
; (if (and ibuff-bs nav-buffer) | |
; (setq nav-win (get-buffer-window nav-buffer)) | |
; (setq ibuff-win (get-buffer-window ibuff-bs)) | |
; | |
; (if ibuff-win | |
; (switch-to-buffer-other-window nav-buffer) | |
; (if nav-win | |
; (switch-to-buffer-other-window ibuff-bs)) ))) | |
;;--- iBuffer --------------------------------------------------------------------------------- | |
(require 'ibuf-ext) | |
(setq ibuffer-saved-filter-groups | |
'(("home" | |
("Emacs" (filename . ".emacs")) | |
("Org" (mode . org-mode)) | |
("README" (or (filename . "README") | |
(filename . "readme"))) | |
("Markdown" (or (mode . markdown-mode) | |
(mode . gfm-mode) | |
(filename . ".md") | |
(filename . ".markdown"))) | |
("LaTeX" (or (mode . latex-mode) | |
(filename . ".tex"))) | |
("School: 510" (filename . "/School/cs510")) | |
("School: 256" (filename . "/School/cs256/")) | |
("School: 415" (filename . "/School/cs415/")) | |
("School" (filename . "/School/")) | |
("WORK: Models" (filename . "/Work/RoRConsole/app/models/")) | |
("WORK: Views" (filename . "/Work/RoRConsole/app/views/")) | |
("WORK: Controllers" (filename . "/Work/RoRConsole/app/controllers/")) | |
("WORK: Helpers" (filename . "/Work/RoRConsole/app/helpers/")) | |
("WORK: Config" (filename . "/Work/RoRConsole/config/")) | |
("WORK: Migrations" (filename . "/Work/RoRConsole/db/migrate/")) | |
("WORK: CSS" (filename . "/Work/RoRConsole/public/stylesheets/")) | |
("WORK: JS" (filename . "/Work/RoRConsole/public/javascripts/")) | |
("WORK" (filename . "/Work/")) | |
("Models (RAILS)" (filename . "/app/models/")) | |
("Views (RAILS)" (filename . "/app/views/")) | |
("Controllers (RAILS)" (filename . "/app/controllers/")) | |
("Helpers (RAILS)" (filename . "/app/helpers/")) | |
("Jinja Templates" (or (filename . ".j2") | |
(mode . jinja2-mode))) | |
("ERB Templates" (or (mode . rhtml-mode) | |
(filename . ".erb"))) | |
("HAML" (mode . haml-mode)) | |
("HTML" (mode . html-mode)) | |
("SASS" (mode . sass-mode)) | |
("SCSS" (mode . scss-mode)) | |
("CSS" (mode . css-mode)) | |
("JS" (mode . js2-mode)) | |
("Coffee" (mode . coffee-mode)) | |
("Unity" (filename . "/Assets/Scripts/")) | |
("Make" (filename . "Makefile")) | |
("C" (mode . c-mode)) | |
("Python" (mode . python-mode)) | |
("Ruby" (mode . ruby-mode)) | |
("Shell" (or (name . "\*eshell\*") | |
(name . "\*nav-shell\*") | |
(name . "\*shell\*"))) | |
("Help" (or (name . "\*Help\*") | |
(name . "\*Apropos\*") | |
(name . "\*info\*")))))) | |
(add-hook 'ibuffer-mode-hook | |
'(lambda () | |
(ibuffer-auto-mode 1) | |
(ibuffer-switch-to-saved-filter-groups "home"))) | |
;; Human-readible 'size' column | |
(define-ibuffer-column size-h | |
(:name "Size" :inline t) | |
(cond | |
((> (buffer-size) 1000) (format "%7.2fk" (/ (buffer-size) 1000.0))) | |
((> (buffer-size) 1000000) (format "%7.2fM" (/ (buffer-size) 1000000.0))) | |
(t (format "%8d" (buffer-size))))) | |
;; Column formatting | |
(setq ibuffer-formats | |
'((mark modified read-only " " | |
(name 25 25 :left :elide) | |
" " | |
(mode 8 8 :left :elide) | |
" " | |
(size-h 8 -1 :right) | |
" " | |
filename-and-process))) | |
(setq ibuffer-show-empty-filter-groups nil) | |
(setq ibuffer-expert t) | |
;(add-to-list 'ibuffer-never-show-predicates "^\\*") | |
;;--- Auto-save ------------------------------------------------------------------------------- | |
(defun save-buffer-if-visiting-file (&optional args) | |
"Save the current buffer only if it is visiting a file" | |
(interactive) | |
(if (buffer-file-name) | |
(save-buffer args))) | |
(add-hook 'auto-save-hook 'save-buffer-if-visiting-file) | |
(setq | |
backup-by-copying t | |
backup-directory-alist '(("." . "~/.emacs.d/backups/")) | |
delete-old-versions t | |
kept-new-versions 6 | |
kept-old-versions 2 | |
version-control t ) | |
(setq auto-save-file-name-transforms | |
`((".*" , "~/.emacs.d/backups/" t))) | |
;;--- OS Hacks -------------------------------------------------------------------------------- | |
(unless (string-match "apple-darwin" system-configuration) | |
; on mac, there's always a menu bar drown, don't have it empty | |
(menu-bar-mode -1)) | |
(when (string-match "apple-darwin" system-configuration) | |
(setq mac-allow-anti-aliasing t) | |
(setq mac-option-key-is-meta nil) | |
(setq mac-command-key-is-meta t) | |
(setq mac-command-modifier 'meta) | |
(setq mac-option-modifier 'meta) | |
; ispell fix | |
(setq-default ispell-program-name "/usr/local/bin/aspell") | |
(setq-default ispell-list-command "list") | |
) | |
; avoid compiz manager rendering bugs | |
(add-to-list 'default-frame-alist '(alpha . 100)) | |
;;--- Shell Tweaks ----------------------------------------------------------------------------- | |
(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) | |
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) | |
;;--- Flyspell --------------------------------------------------------------------------------- | |
(add-hook 'text-mode-hook 'flyspell-mode) | |
;;--- Smex ------------------------------------------------------------------------------------- | |
(require 'smex) | |
(setq smex-save-file "~/.emacs.d/.smex-items") | |
;;--- Ido -------------------------------------------------------------------------------------- | |
(ido-mode t) | |
(ido-everywhere t) | |
(setq ido-save-directory-list-file "~/.emacs.d/.ido.last") | |
(setq ido-enable-flex-matching t) | |
(setq ido-use-filename-at-point 'guess) | |
(setq ido-show-dot-for-dired t) | |
;;--- Fullscreen ------------------------------------------------------------------------------- | |
(defun fullscreen () | |
(interactive) | |
(set-frame-parameter nil 'fullscreen | |
(if (frame-parameter nil 'fullscreen) nil 'fullboth))) | |
;;--- Font ------------------------------------------------------------------------------------- | |
(ignore-errors | |
(set-face-attribute 'default nil :font "Consolas") | |
(set-default-font "Consolas:pixelsize=13:weight=normal:slant=normal:width=normal:spacing=100:scalable=true")) | |
;;--- Color Themes ----------------------------------------------------------------------------- | |
;;(require 'color-theme-chocolate-rain) | |
(require 'color-theme) | |
(if (fboundp 'color-theme-initialize) (color-theme-initialize)) | |
(require 'color-theme-almost-monokai) | |
(require 'color-theme-desert) | |
(require 'color-theme-ir-black) | |
;(require 'color-theme-railscasts) | |
;(require 'color-theme-solarized) | |
(require 'color-theme-subdued) | |
(require 'color-theme-tango-2) | |
(require 'color-theme-tango) | |
(require 'color-theme-tomorrow) | |
;(require 'color-theme-twilight) | |
;(require 'color-theme-sanityinc-solarized) | |
;(load-library "color-theme-sanityinc-solarized") | |
;(color-theme-sanityinc-solarized-dark) | |
;(load-theme 'wombat) | |
;(load-theme 'tsdh-dark) | |
;(load-theme 'tango-dark) | |
;(load-theme 'misterioso) | |
;(load-theme 'deeper-blue) | |
;(color-theme-zenburn) | |
;(color-theme-tangotango) | |
(color-theme-almost-monokai) | |
;(color-theme-chocolate-rain) | |
;(color-theme-desert) | |
;(color-theme-ir-black) | |
;(color-theme-railscasts) | |
;(color-theme-solarized) | |
;(color-theme-subdued) | |
;(color-theme-tango-2) | |
;(color-theme-tango) | |
;(color-theme-tomorrow) | |
;(color-theme-twilight) | |
;(color-theme-zen-and-art) | |
(if (not window-system) | |
(color-theme-taming-mr-arneson) | |
;(color-theme-renegade) | |
) | |
;;--- Hilight Line ---------------------------------------------------------------------------- | |
(defface hl-line | |
'((t (:background "gray15"))) | |
"Face to use for `hl-line-face'." | |
:group 'hl-line) | |
(setq hl-line-face 'hl-line) | |
(global-hl-line-mode t) | |
;;--- Indentation ------------------------------------------------------------------------------ | |
(setq-default tab-width 4) | |
(setq-default indent-tabs-mode nil) | |
(setq js-indent-level 4) | |
(setq ruby-indent-level 2) | |
(setq ruby-mode-hook | |
(function (lambda () | |
(setq ruby-deep-arglist t) | |
(setq ruby-deep-indent-paren nil) | |
(setq c-tab-always-indent nil)))) | |
(setq coffee-mode-hook | |
(function (lambda() | |
(set (make-local-variable 'tab-width) 2)))) | |
;(c-set-offset label 4) | |
;(c-set-offset statement 4) | |
(setq custom-c-style-hook | |
(function (lambda () | |
(setq indent-tabs-mode nil) | |
(setq c-indent-level 4) | |
(setq c-default-style "java") | |
(setq c-basic-offset 4)))) | |
(setq c++-mode-hook | |
custom-c-style-hook) | |
(setq csharp-mode-hook | |
custom-c-style-hook) | |
(setq c-mode-hook | |
custom-c-style-hook) | |
;(setq c-default-style "java" c-basic-offset 4) | |
(c-set-offset 'case-label 4) | |
;(electric-indent-mode t) | |
;;--- AutoPair --------------------------------------------------------------------------------- | |
;(require 'autopair) | |
(load-library "autopair") | |
; workaround for bug | |
(add-hook 'sldb-mode-hook #'(lambda () (setq autopair-dont-activate t))) | |
(set-default 'autopair-dont-activate #'(lambda () (eq major-mode 'sldb-mode))) | |
(ignore-errors (autopair-global-mode t)) | |
(show-paren-mode 1) | |
;;--- Scrolling Tweaks ------------------------------------------------------------------------- | |
(setq | |
scroll-margin 0 | |
scroll-conservatively 100000 | |
scroll-preserve-screen-position 1) | |
;;--- Speedbar --------------------------------------------------------------------------------- | |
(load-library "sr-speedbar") | |
(setq sr-speedbar-right-side t) | |
(setq speedbar-frame-parameters | |
'((minibuffer) | |
(width . 40) | |
(border-width . 0) | |
(menu-bar-lines . 0) | |
(tool-bar-lines . 0) | |
(unsplittable . t) | |
(left-fringe . 0))) | |
(setq speedbar-hide-button-brackets-flag t) | |
(setq speedbar-show-unknown-files t) | |
(setq speedbar-smart-directory-expand-flag t) | |
(setq speedbar-use-images nil) | |
;;--- MiniMap --------------------------------------------------------------------------------- | |
(require 'minimap) | |
(defun minimap-toggle () | |
"Show minimap if hidden, hide if present." | |
(interactive) | |
(if (and minimap-bufname | |
(get-buffer minimap-bufname) | |
(get-buffer-window (get-buffer minimap-bufname))) | |
(minimap-kill) | |
(minimap-create))) | |
;;--- Zencoding ------------------------------------------------------------------------------- | |
(require 'zencoding-mode) | |
(add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes | |
;;--- Find Symbol ----------------------------------------------------------------------------- | |
;; searches for function/class defenitions in a file | |
(defun ido-goto-symbol () | |
"Will update the imenu index and then use ido to select a | |
symbol to navigate to" | |
(interactive) | |
(imenu--make-index-alist) | |
(let ((name-and-pos '()) | |
(symbol-names '())) | |
(flet ((addsymbols (symbol-list) | |
(when (listp symbol-list) | |
(dolist (symbol symbol-list) | |
(let ((name nil) (position nil)) | |
(cond | |
((and (listp symbol) (imenu--subalist-p symbol)) | |
(addsymbols symbol)) | |
((listp symbol) | |
(setq name (car symbol)) | |
(setq position (cdr symbol))) | |
((stringp symbol) | |
(setq name symbol) | |
(setq position (get-text-property 1 'org-imenu-marker symbol)))) | |
(unless (or (null position) (null name)) | |
(add-to-list 'symbol-names name) | |
(add-to-list 'name-and-pos (cons name position)))))))) | |
(addsymbols imenu--index-alist)) | |
(let* ((selected-symbol (ido-completing-read "Symbol? " symbol-names)) | |
(position (cdr (assoc selected-symbol name-and-pos)))) | |
(goto-char position)))) | |
;;--- AutoComplete + Yasnippet + Python ----------------------------------------------------- | |
;; Source: http://www.enigmacurry.com/2009/01/21/autocompleteel-python-code-completion-in-emacs/ | |
(require 'python) | |
(require 'auto-complete) | |
;(require 'yasnippet) | |
(autoload 'python-mode "python-mode" "Python Mode." t) | |
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) | |
(add-to-list 'interpreter-mode-alist '("python" . python-mode)) | |
(setq init-pymacs nil) | |
(if init-pymacs | |
(progn | |
;; Initialize Pymacs | |
(autoload 'pymacs-apply "pymacs") | |
(autoload 'pymacs-call "pymacs") | |
(autoload 'pymacs-eval "pymacs" nil t) | |
(autoload 'pymacs-exec "pymacs" nil t) | |
(autoload 'pymacs-load "pymacs" nil t) | |
;; Initialize Rope | |
(pymacs-load "ropemacs" "rope-") | |
(setq ropemacs-enable-autoimport t) | |
;; Initialize Yasnippet | |
;Don't map TAB to yasnippet | |
;In fact, set it to something we'll never use because | |
;we'll only ever trigger it indirectly. | |
(setq yas/trigger-key (kbd "C-c <kp-multiply>")) | |
(yas/initialize) | |
(yas/load-directory "~/.emacs.d/el-get/yasnippet-github/snippets") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; Auto-completion | |
;;; Integrates: | |
;;; 1) Rope | |
;;; 2) Yasnippet | |
;;; all with AutoComplete.el | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defun prefix-list-elements (list prefix) | |
(let (value) | |
(nreverse | |
(dolist (element list value) | |
(setq value (cons (format "%s%s" prefix element) value)))))) | |
(defvar ac-source-rope | |
'((candidates | |
. (lambda () | |
(prefix-list-elements (rope-completions) ac-target)))) | |
"Source for Rope") | |
(defun ac-python-find () | |
"Python `ac-find-function'." | |
(require 'thingatpt) | |
(let ((symbol (car-safe (bounds-of-thing-at-point 'symbol)))) | |
(if (null symbol) | |
(if (string= "." (buffer-substring (- (point) 1) (point))) | |
(point) | |
nil) | |
symbol))) | |
(defun ac-python-candidate () | |
"Python `ac-candidates-function'" | |
(let (candidates) | |
(dolist (source ac-sources) | |
(if (symbolp source) | |
(setq source (symbol-value source))) | |
(let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit)) | |
(requires (cdr-safe (assq 'requires source))) | |
cand) | |
(if (or (null requires) | |
(>= (length ac-target) requires)) | |
(setq cand | |
(delq nil | |
(mapcar (lambda (candidate) | |
(propertize candidate 'source source)) | |
(funcall (cdr (assq 'candidates source))))))) | |
(if (and (> ac-limit 1) | |
(> (length cand) ac-limit)) | |
(setcdr (nthcdr (1- ac-limit) cand) nil)) | |
(setq candidates (append candidates cand)))) | |
(delete-dups candidates))) | |
(add-hook 'python-mode-hook | |
(lambda () | |
(auto-complete-mode 1) | |
(set (make-local-variable 'ac-sources) | |
(append ac-sources '(ac-source-rope) '(ac-source-yasnippet))) | |
(set (make-local-variable 'ac-find-function) 'ac-python-find) | |
(set (make-local-variable 'ac-candidate-function) 'ac-python-candidate) | |
(set (make-local-variable 'ac-auto-start) nil))) | |
;;Ryan's python specific tab completion | |
(defun ryan-python-tab () | |
; Try the following: | |
; 1) Do a yasnippet expansion | |
; 2) Do a Rope code completion | |
; 3) Do an indent | |
(interactive) | |
(if (eql (ac-start) 0) | |
(indent-for-tab-command))) | |
(defadvice ac-start (before advice-turn-on-auto-start activate) | |
(set (make-local-variable 'ac-auto-start) t)) | |
(defadvice ac-cleanup (after advice-turn-off-auto-start activate) | |
(set (make-local-variable 'ac-auto-start) nil)) | |
(define-key python-mode-map "\t" 'ryan-python-tab) | |
)) | |
;;--- Auto Modes ---------------------------------------------------------------------------- | |
(setq auto-mode-alist | |
(append '(("\\.md" . gfm-mode) | |
("\\.markdown" . markdown-mode) | |
("\\.yaml" . yaml-mode) | |
("\\.j2" . jinja2-mode) | |
("\\.slim" . slim-mode) | |
("\\.erb" . rhtml-mode) | |
("Rakefile" . ruby-mode) | |
("\\.rake" . ruby-mode) | |
("Gemfile" . ruby-mode) | |
("_spec\\.rb" . rspec-mode) | |
("Cakefile" . coffee-mode)) | |
auto-mode-alist)) | |
;;--- Surround ------------------------------------------------------------------------------ | |
(defun surround-region-with-tag (tag beg end) | |
(interactive "sTag: \nr") | |
(save-excursion | |
(goto-char beg) | |
(insert "<" tag ">\n") | |
(goto-char (+ end 3 (length tag))) | |
(setq tag-name (first (split-string tag))) | |
(insert "\n</" tag-name ">"))) | |
;;--- Key Bindings and Shortcuts ------------------------------------------------------------ | |
(global-set-key (kbd "C-c r") 'repeat) | |
(global-set-key (kbd "C-c g") 'goto-line) | |
(global-set-key (kbd "C-c C-g") 'ido-goto-symbol) | |
(global-set-key (kbd "C-c d") 'delete-trailing-whitespace) | |
(global-set-key (kbd "C-c M-r") 'query-replace) | |
(global-set-key (kbd "C-c M-e") 'query-replace-regexp) | |
(global-set-key (kbd "C-c z") 'zencoding-expand-line) | |
(global-set-key (kbd "C-c C-w") 'surround-region-with-tag) | |
(global-set-key (kbd "C-c m") 'minimap-toggle) | |
(global-set-key (kbd "C-c n") 'single-nav) ; hit 'q' to close | |
(global-set-key (kbd "C-x C-b") 'ibuffer-bs-show) | |
(global-set-key (kbd "C-c v") 'vline-mode) | |
(global-set-key (kbd "C-c c") 'comment-region) | |
(global-set-key (kbd "C-c i") 'indent-region) | |
;(global-set-key (kbd "C-c s") 'sr-speedbar-toggle) -- using nav instead | |
;(global-set-key (kbd "C-c C-f") 'fullscreen) -- Doesn't work :( | |
(global-set-key (kbd "C-c C-s") 'dired-do-sync) | |
(global-set-key (kbd "C-c C-d") 'dired-details-toggle) | |
(global-set-key (kbd "C-c M-d") 'desktop-menu) | |
(global-set-key (kbd "C-c M-s") 'desktop-save-in-desktop-dir) | |
(global-set-key (kbd "M-s M-s") 'nav-shell) | |
(global-set-key (kbd "M-s M-e") 'eshell) | |
(global-set-key (kbd "M-x") 'smex) | |
(global-set-key (kbd "M-X") 'smex-major-mode-commands) | |
;; Smart yank/paste (auto-indent pastes to current indent level) | |
(global-set-key (kbd "C-c C-v") 'do-smart-yank) | |
(fset 'do-smart-yank "\C-y\C-c\C-q") | |
;; Window resizing | |
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally) | |
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally) | |
(global-set-key (kbd "S-C-<down>") 'shrink-window) | |
(global-set-key (kbd "S-C-<up>") 'enlarge-window) | |
(if (and (string-match "apple-darwin" system-configuration) | |
(not window-system)) | |
; option/alt/cmd keys don't work as 'Meta under a mac terminal | |
(progn | |
(global-set-key (kbd "S-c") 'smex) | |
(global-set-key (kbd "S-c") 'smex-major-mode-commands))) | |
(desktop-recover-interactive) | |
;;; This was installed by package-install.el. | |
;;; This provides support for the package system and | |
;;; interfacing with ELPA, the package archive. | |
;;; Move this code earlier if you want to reference | |
;;; packages in your .emacs. | |
(when | |
(load | |
(expand-file-name "~/.emacs.d/elpa/package.el")) | |
(package-initialize)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment