Skip to content

Instantly share code, notes, and snippets.

@localredhead
Created October 11, 2012 20:44
Show Gist options
  • Save localredhead/3875357 to your computer and use it in GitHub Desktop.
Save localredhead/3875357 to your computer and use it in GitHub Desktop.
emacs config WIP. Combo Emacs Start Kit + Emacs Kicker
;; emacs kicker --- kick start emacs setup
;; Copyright (C) 2010 Dimitri Fontaine
;;
;; Author: Dimitri Fontaine <dim@tapoueh.org>
;; URL: https://github.com/dimitri/emacs-kicker
;; Created: 2011-04-15
;; Keywords: emacs setup el-get kick-start starter-kit
;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
;;
;; This file is NOT part of GNU Emacs.
(require 'cl) ; common lisp goodies, loop
;;; Load starter kit defaults
(starter-kit-load "org")
(starter-kit-load "ruby")
(starter-kit-load "js")
(starter-kit-load "bindings")
;;; Add custom packages.
;;; Emacs-rails and Emacs-Starter-Kit24 enable Elpa and Marmalade.
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil t)
(url-retrieve
"https://github.com/dimitri/el-get/raw/master/el-get-install.el"
(lambda (s)
(end-of-buffer)
(eval-print-last-sexp))))
;; now either el-get is `require'd already, or have been `load'ed by the
;; el-get installer.
;; set local recipes
(setq
el-get-sources
'((:name buffer-move ; have to add your own keys
:after (lambda ()
(global-set-key (kbd "<C-S-up>") 'buf-move-up)
(global-set-key (kbd "<C-S-down>") 'buf-move-down)
(global-set-key (kbd "<C-S-left>") 'buf-move-left)
(global-set-key (kbd "<C-S-right>") 'buf-move-right)
(global-set-key (kbd "S-<up>") 'windmove-up)
(global-set-key (kbd "S-<down>") 'windmove-down)
(global-set-key (kbd "S-<right>") 'windmove-right)
(global-set-key (kbd "S-<left>") 'windmove-left)))
(:name smex ; a better (ido like) M-x
:after (lambda ()
(setq smex-save-file "~/.emacs.d/.smex-items")
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)))
(:name magit ; git meet emacs, and a binding
:after (lambda ()
(global-set-key (kbd "C-x C-z") 'magit-status)))
(:name rvm
:type git
:url "http://github.com/djwhitt/rvm.el.git"
:load "rvm.el"
:compile ("rvm.el")
:after (progn (rvm-use "1.9.3" "jiff")))
(:name icicles
:type git
:url "https://github.com/emacsmirror/icicles.git"
:load "icicles.el"
:compile ("icicles.el"))
(:name curl
:type git
:url "https://github.com/cinsk/emacs-curl.git"
:load "curl.el"
:compile ("curl.el"))
(:name org-jira
:type git
:url "https://github.com/baohaojun/org-jira.git"
:load "org-jira.el"
:compile ("org-jira.el"))
(:name ecb
:type git
:url "https://github.com/alexott/ecb.git"
:load "ecb.el"
:compile ("ecb.el"))
(:name projectile
:type git
:url "https://github.com/bbatsov/projectile.git"
:load "projectile.el")
(:name haml-mode
:type git
:url "https://github.com/nex3/haml-mode.git"
:load "haml-mode.el"
:features "haml-mode")
(:name restclient
:type git
:url "https://github.com/pashky/restclient.el.git"
:load "restclient.el")
(:name goto-last-change ; move pointer back to last change
:after (lambda ()
;; when using AZERTY keyboard, consider C-x C-_
(global-set-key (kbd "C-x C-/") 'goto-last-change)))))
;; now set our own packages
(setq
my:el-get-packages
'(el-get ; el-get is self-hosting
escreen ; screen for emacs, C-\ C-h
php-mode-improved ; if you're into php...
switch-window ; takes over C-x o
auto-complete ; complete as you type with overlays
zencoding-mode ; http://www.emacswiki.org/emacs/ZenCoding
color-theme ; nice looking emacs
color-theme-tango)) ; check out color-theme-solarized -- I did and it's awesome!
;;
;; Some recipes require extra tools to be installed
;;
;; Note: el-get-install requires git, so we know we have at least that.
;;
(when (el-get-executable-find "cvs")
(add-to-list 'my:el-get-packages 'emacs-goodies-el)) ; the debian addons for emacs
(when (el-get-executable-find "svn")
(loop for p in '(psvn ; M-x svn-status
yasnippet ; powerful snippet mode
)
do (add-to-list 'my:el-get-packages p)))
(setq my:el-get-packages
(append
my:el-get-packages
(loop for src in el-get-sources collect (el-get-source-name src))))
;; install new packages and init already installed packages
(el-get 'sync my:el-get-packages)
;;; The following semantic references are needed
;;; to solve an issue with ECB.
(require 'semantic)
(require 'semantic/analyze)
(provide 'semantic-analyze)
(provide 'semantic-ctxt)
(provide 'semanticdb)
(provide 'semanticdb-find)
(provide 'semanticdb-mode)
(provide 'semantic-load)
(setq utf-translate-cjk-mode nil) ; disable CJK coding/encoding (Chinese/Japanese/Korean characters)
(set-language-environment 'utf-8) ; force everything to UTF-8
(setq locale-coding-system 'utf-8) ; so all character input is valid.
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; on to the visual settings
(setq inhibit-splash-screen t) ; no splash screen, thanks
(line-number-mode 1) ; have line numbers and
(column-number-mode 1) ; column numbers in the mode line
(tool-bar-mode -1) ; no tool bar with icons
(scroll-bar-mode -1) ; no scroll bars
;; Makes scrolling smoother.
(setq redisplay-dont-pause t
scroll-margin 1
scroll-step 1
scroll-conservatively 10000
scroll-preserve-screen-position 1)
(push "/usr/local/bin" exec-path)
(setq default-directory "~/Projects/")
(setq my-projects '("~/Projects/Jiff3"))
(rvm-use "1.9.3" "jiff") ; force rvm to a gemset because its tempermental
(require 'ecb)
(setq tags-table-list my-projects) ; load a list of directories with tags tables
(setq ecb-source-path my-projects)
(setq stack-trace-on-error t)
(ecb-byte-compile)
(setq ecb-tip-of-the-day nil)
(setq ecb-layout-name "1oca1redhead")
(ecb-activate)
(global-ede-mode t)
(projectile-global-mode)
;; (require 'minimap)
;; (minimap-mode)
;; (minimap-create)
;; (minimap-update-delay)
; Set Tags in root of rails dirs
; for ubuntu: ctags-exuberant -a -e -f TAGS --tag-relative -R app lib spec config bin vendor
; for osx: *compile ctags from source: export CFLAGS=-O0 ;https://trac.macports.org/ticket/31256
; generate tags for ruby gems using bundler(this is the holy grail of ctags generation)
; bundle show --paths | xargs ctags-exuberant -a -e -f TAGS --tag-relative -R app lib spec config bin vendor
(defun build-ctags ()
(interactive)
(message "building project tags")
(let ((root (eproject-root)))
(shell-command (concat "ctags -e -R --extra=+fq --exclude=db --exclude=test --exclude=.git --exclude=public -f " root "TAGS " root)))
(visit-project-tags)
(message "tags built successfully"))
(defun visit-project-tags ()
(interactive)
(let ((tags-file (concat (eproject-root) "TAGS")))
(visit-tags-table tags-file)
(message (concat "Loaded " tags-file))))
(setq tags-case-fold-search t)
(defun like-a-surgeon ()
(local-set-key [(control return)] 'semantic-ia-complete-symbol)
(local-set-key "\C-c?" 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-c>" 'semantic-complete-analyze-inline)
(local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle)
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert))
(add-hook 'c-mode-common-hook 'like-a-surgeon)
(defun forceps ()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'forceps)
;; Setup Auto Complete
(add-to-list 'load-path "~/.emacs.d/src")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(ac-set-trigger-key "TAB")
(global-auto-complete-mode t)
(require 'curl)
(require 'jira)
(setq jiralib-url "http://jiffinc.atlassian.net")
;; you need make sure whether the "/jira" at the end is
;; necessary or not, see discussion at the end of this page
(require 'org-jira)
(require 'icicles)
;(icy-mode 1)
(load-theme 'solarized-dark t)
(setq-default tab-width 2)
(setq confirm-kill-emacs 'yes-or-no-p)
(require 'find-file-in-project)
(global-set-key (kbd "C-x ;") 'ftf-find-file) ; requires find-things-fast
;; Make all shells open in their own buffer, otherwise use C-u M-x
(defadvice shell (around always-new-shell)
"Always start a new shell."
(let ((buffer (generate-new-buffer-name "*shell*"))) ad-do-it))
(ad-activate 'shell)
;; choose your own fonts, in a system dependant way
(if (string-match "apple-darwin" system-configuration)
(set-face-font 'default "Monaco-13")
(set-face-font 'default "Source Code Pro-10"))
;(set-frame-font "Liberation Mono-10") ;The best three programming fonts.
;(set-frame-font "Anonymous Pro-13")
(global-hl-line-mode) ; highlight current line
(global-linum-mode 1) ; add line numbers on the left
;; avoid compiz manager rendering bugs
(add-to-list 'default-frame-alist '(alpha . 100))
;; copy/paste with C-c and C-v and C-x, check out C-RET too
(cua-mode)
;; under mac, have Command as Meta and keep Option for localized input
(when (string-match "apple-darwin" system-configuration)
(setq mac-allow-anti-aliasing t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'none))
;; Use the clipboard, pretty please, so that copy/paste "works"
(setq x-select-enable-clipboard t)
;; Navigate windows with M-<arrows>
(windmove-default-keybindings 'meta)
(setq windmove-wrap-around t)
;; whenever an external process changes a file underneath emacs, and there
;; was no unsaved changes in the corresponding buffer, just revert its
;; content to reflect what's on-disk.
(global-auto-revert-mode 1)
;; M-x shell is a nice shell interface to use, let's make it colorful. If
;; you need a terminal emulator rather than just a shell, consider M-x term
;; instead.
;(autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t)
;(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; If you do use M-x term, you will notice there's line mode that acts like
;; emacs buffers, and there's the default char mode that will send your
;; input char-by-char, so that curses application see each of your key
;; strokes.
;;
;; The default way to toggle between them is C-c C-j and C-c C-k, let's
;; better use just one key to do the same.
(require 'term)
(define-key term-raw-map (kbd "C-'") 'term-line-mode)
(define-key term-mode-map (kbd "C-'") 'term-char-mode)
;; Have C-y act as usual in term-mode, to avoid C-' C-y C-'
;; Well the real default would be C-c C-j C-y C-c C-k.
(define-key term-raw-map (kbd "C-y") 'term-paste)
;; use ido for minibuffer completion
(require 'ido)
(ido-mode 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)
;; default key to switch buffer is C-x b, but that's not easy enough
;;
;; when you do that, to kill emacs either close its frame from the window
;; manager or do M-x kill-emacs. Don't need a nice shortcut for a once a
;; week (or day) action.
;(global-set-key (kbd "C-x C-b") 'ido-switch-buffer)
;(global-set-key (kbd "C-x C-c") 'ido-switch-buffer)
;(global-set-key (kbd "C-x B") 'ibuffer)
;; C-x C-j opens dired with the cursor right on the file you're editing
(require 'dired-x)
;; full screen
(defun fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth)))
(global-set-key [f11] 'fullscreen)
(require 'restclient)
;;; RoR stuff below
(setq rinari-tags-file-name "TAGS")
(setq rsense-home "/opt/rsense-0.3")
(add-to-list 'load-path (concat rsense-home "/etc"))
(require 'rsense)
(require 'haml-mode)
(add-hook 'haml-mode-hook 'rinari-minor-mode)
;; Emacs Rails
(add-to-list 'load-path (expand-file-name "~/.emacs.d/rails-minor-mode"))
(require 'rails)
(require 'rvm)
(require 'emacs-spork) ; https://github.com/scpike/emacs-spork
;; Make rspec mode use bash.
;; add --drb to .rspec in project root to make this work. ;; muy importante!
(defadvice rspec-compile (around rspec-compile-around)
"Use BASH shell for running the specs because of ZSH issues."
(let ((shell-file-name "/bin/bash"))
ad-do-it))
(ad-activate 'rspec-compile)
;; Ruby Debugger
(add-to-list 'load-path "~/.emacs.d/src/ruby-debug-extra-0.10.4/emacs")
(require 'rdebug)
(setq rdebug-short-key-mode t)
(global-set-key "\C-c\C-d" 'rdebug)
(autoload 'rdebug "rdebug" "ruby-debug interface" t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 1. Get latest emacs (now comes with cedet!)
;; 2. Install emacs starter kit24 (comes with rinari)
;; 3. Install emacs rails too
;; (because it really doesn't hurt and I like it more than rinari)
;; (I use parts of both)
;; 4. Installf el-get
;; 5. Get ECB from newecb repo on github. https://github.com/alexott/ecb/tree/new-cedet
;; 6. Install Rsense and Autocomplete (use teh googles to get the latest)
;; - install them in /opt you heathen!
;; - add to .bashrc: export RSENSE_HOME=/opt/rsense-0.3/
;; 7. Add rvm path to .bachrc so emacs sees it
;; - add to .bashrc: PATH=$PATH:$HOME/.rvm/bin:$RSENSE_HOME/bin # Add RVM and RSENSE to PATH for scripting
;; - add to .bashrc: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
;; 8. Install rvm.el from github using el-get. Everything else you want comes from elpa, melpa, tromey or el-get
;; 9. Add .rspec file to the root of your rails project, and make --drb the first line so all specs use spork by default.
;; 10. Download and install ruby-debug-extra and place it in /src
;; 11. profit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment