public
Last active

  • Download Gist
~/.emacs
Emacs Lisp
1
(load-file "~/emacs_extensions/init.el")
~/emacs_extensions/init.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t)
 
(defun set-frame-size-according-to-resolution ()
;;(interactive)
(if window-system
(progn
(if (> (x-display-pixel-width) 1280)
(add-to-list 'default-frame-alist (cons 'width 203))
(add-to-list 'default-frame-alist (cons 'width 80)))
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 70) (frame-char-height))))))
(enlarge-window-horizontally 20)
(set-frame-position (selected-frame) 0 0)
)
 
(load-file "~/emacs_extensions/cedet/common/cedet.el")
(semantic-load-enable-excessive-code-helpers)
(semantic-load-enable-semantic-debugging-helpers)
 
(add-to-list 'load-path
"~/emacs_extensions/ecb")
(require 'ecb)
 
(defun find-all-emacs-projects ()
(let ((projs (file-expand-wildcards "~/projects/**/.emacs_project")))
(let (value)
(dolist (element projs value)
(setq value (cons (car (split-string element "/.emacs_project")) value))))))
 
(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.
'(ecb-layout-window-sizes (quote (("left3" (0.1921182266009852 . 0.35294117647058826) (0.1921182266009852 . 0.3137254901960784) (0.1921182266009852 . 0.3137254901960784)))))
'(ecb-options-version "2.32")
'(ecb-source-path (cons "~/emacs_extensions" (find-all-emacs-projects)))
'(ecb-tip-of-the-day nil))
(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.
)
(ecb-layout-switch "left3")
(ecb-activate)
 
 
(load-file "~/emacs_extensions/ruby_support.el")
 
(global-set-key (kbd "<f5>") 'ecb-goto-window-directories)
(global-set-key (kbd "<f6>") 'eval-buffer)
;;(global-set-key (kbd "<f7>") 'ecb-goto-window-methods)
 
(set-frame-size-according-to-resolution)
 
(add-to-list 'load-path "~/emacs_extensions/test-runner")
 
(require 'test-runner)
 
(global-set-key [(f7)] 'run-test)
 
;; enable test-case-mode automatically
(add-hook 'find-file-hook 'enable-test-case-mode-if-test)
 
;; run the test when saving the file
(setq test-case-run-after-saving t)
 
(add-to-list 'load-path "~/emacs_extensions")
(require 'window-numbering)
(window-numbering-mode 1)
 
(require 'tempo-snippets)
 
(define-key ruby-mode-map (kbd "RET") 'ruby-reindent-then-newline-and-indent)
 
(defadvice yank (after indent-region activate)
(if (member major-mode '(emacs-lisp-mode scheme-mode lisp-mode c-mode c++-mode objc-mode latex-mode plain-tex-mode ruby-mode))
(let ((mark-even-if-inactive t))
(indent-region (region-beginning) (region-end) nil))))
 
(defadvice yank-pop (after indent-region activate)
(if (member major-mode '(emacs-lisp-mode scheme-mode lisp-mode c-mode c++-mode objc-mode latex-mode plain-tex-mode ruby-mode))
(let ((mark-even-if-inactive t))
(indent-region (region-beginning) (region-end) nil))))
 
(require 'my_extensions)
 
(setq longlines-wrap-follows-window-size t)
~/emacs_extensions/my_extensions.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
(defun populate-emacs-project-files-table (file)
(if (file-directory-p file)
(mapc 'populate-emacs-project-files-table (directory-files file t "^[^\.]"))
(let* ((file-name (file-name-nondirectory file))
(existing-record (assoc file-name emacs-project-files-table))
(unique-parts (get-unique-emacs-project-directory-names file (cdr existing-record))))
(if existing-record
(let ((new-key (concat file-name " - " (car unique-parts)))
(old-key (concat (car existing-record) " - " (cadr unique-parts))))
(setf (car existing-record) old-key)
(setq emacs-project-files-table (acons new-key file emacs-project-files-table)))
(setq emacs-project-files-table (acons file-name file emacs-project-files-table))))))
 
(defun get-unique-emacs-project-directory-names (path1 path2)
(let* ((parts1 (and path1 (split-string path1 "/" t)))
(parts2 (and path2 (split-string path2 "/" t)))
(part1 (pop parts1))
(part2 (pop parts2))
(looping t))
(while (and part1 part2 looping)
(if (equal part1 part2)
(setq part1 (pop parts1) part2 (pop parts2))
(setq looping nil)))
(list part1 part2)))
 
(defun emacs-project-find (file)
(interactive (list (if (functionp 'ido-completing-read)
(ido-completing-read "Find file in project: " (mapcar 'car (emacs-project-files)))
(completing-read "Find file in project: " (mapcar 'car (emacs-project-files))))))
(find-file (cdr (assoc file emacs-project-files-table))))
 
(defun emacs-proj-root (&optional dir)
(or dir (setq dir default-directory))
(if (file-exists-p (concat dir ".emacs_project"))
dir
(if (equal dir "/")
nil
(emacs-proj-root (expand-file-name (concat dir "../"))))))
 
(defun emacs-project-files (&optional file)
; uncomment these lines if it's too slow to load the whole emacs-project-files-table
; (when (or (not emacs-project-files-table) ; initial load
; (not (string-match (emacs-proj-root) (cdar emacs-project-files-table)))) ; switched projects
(setq emacs-project-files-table nil)
(populate-emacs-project-files-table (or file (emacs-proj-root)))
emacs-project-files-table)
 
(global-set-key (kbd "C-M-z") 'emacs-project-find)
(global-set-key (kbd "C-M-y") 'longlines-mode)
 
(setq auto-mode-alist (cons '("\\.rake\\'" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("Capfile" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("Rakefile" . ruby-mode) auto-mode-alist))
 
(setq ido-execute-command-cache nil)
(defun ido-execute-command ()
(interactive)
(call-interactively
(intern
(ido-completing-read
"M-x "
(progn
(unless ido-execute-command-cache
(mapatoms (lambda (s)
(when (commandp s)
(setq ido-execute-command-cache
(cons (format "%S" s) ido-execute-command-cache))))))
ido-execute-command-cache)))))
(add-hook 'ido-setup-hook
(lambda ()
(setq ido-enable-flex-matching t)
(global-set-key "\M-x" 'ido-execute-command)))
 
(setq truncate-partial-width-windows nil)
 
;;renari html support tweak
(define-key html-mode-map
"\C-c\M-s" 'rinari-console)
(define-key html-mode-map
"\C-c\C-v" (lambda () (interactive) (toggle-buffer 'rails-view)))
(define-key html-mode-map
"\C-c\C-t" 'toggle-buffer)
(define-key html-mode-map
"\C-c\C-r" 'ruby-rake)
(define-key html-mode-map
"\C-c\C-g" 'rinari-get-path)
(define-key html-mode-map
"\C-c\C-f" 'rinari-find-config-file)
(define-key html-mode-map
"\C-c\C-b" 'rinari-find-by-context)
(define-key html-mode-map
"\C-x\C-\M-F" 'find-file-in-project)
 
;;find tests
(defun find-test-in-project (file)
(interactive (list (if (functionp 'ido-completing-read)
(ido-completing-read "Find file in project: " (mapcar 'car (project-tests)))
(completing-read "Find file in project: " (mapcar 'car (project-tests))))))
(find-file (cdr (assoc file project-files-table))))
 
(defun project-tests (&optional file)
(setq project-files-table nil)
(populate-project-files-table (or file (project-test-dir)))
project-files-table)
 
(defun project-test-dir ()
(let ((test-dir (concat (emacs-proj-root) "/test"))
(spec-dir (concat (emacs-proj-root) "/spec")))
(cond ((file-exists-p test-dir) test-dir)
((file-exists-p spec-dir) spec-dir))))
 
(global-set-key (kbd "C-x C-M-t") 'find-test-in-project)
 
(custom-set-variables
'(semanticdb-default-file-name ".semantic.cache")
'(semanticdb-default-save-directory "~/.emacs.d/.semantic"))
 
(provide 'my_extensions)
~/emacs_extensions/ruby_support.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
;; Fonts and cursor
;; (set-default-font "-apple-profont-medium-r-normal--10-100-72-72-m-100-mac-roman")
;;(set-background-color "black")
;;(set-foreground-color "white")
;;(set-cursor-color "red")
 
;; Set encoding to UTF-8
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
 
;; Useful key strokes
(global-set-key "\M-g" 'goto-line)
(global-set-key "\M-d" 'delete-region)
(global-set-key "\M-p" 'emacs-wiki-change-project)
 
;; Anti Aliasing
;; (setq mac-allow-anti-aliasing t)
(setq mac-allow-anti-aliasing nil)
 
;; Frame title : set to buffer name
(setq frame-title-format "Emacs - %f ")
(setq icon-title-format "Emacs - %b")
 
;; Editor Preferences
(column-number-mode t) ;; Show column numbers
(tool-bar-mode nil) ;; Disable tool bar
(menu-bar-mode nil) ;; Disable menu bar
(scroll-bar-mode nil) ;; Disable scrollbar
(transient-mark-mode t) ;; Selection highlighting
(setq-default truncate-lines t)
(setq scroll-step 1
scroll-margin 3
scroll-conservatively 10000) ;; Scrolling
(show-paren-mode t) ;; Highlight parens
(setq show-paren-style 'parentheses) ;; Shor parens
(blink-cursor-mode nil) ;; Disable blinking of cursor
(fset 'yes-or-no-p 'y-or-n-p) ;; Alias Y and N
(setq message-log-max 100) ;; Set log buffer size
;; (resize-minibuffer-mode 1) ;; Resize buffer depending on text
(follow-mode t) ;; Easier editing of longs files
(setq inhibit-startup-message t) ;; Disable start up message
(setq search-highlight t) ;; Highlight search results
(setq kill-whole-line t) ;; Kill whole line
(setq backup-inhibited t) ;; Never backup
(setq column-number-mode t) ;; Show column numbers
(setq line-number-mode 1) ;; Show line numbers
(setq-default indent-tabs-mode nil) ;; Use spaces for tabs
(setq visible-bell t) ;; Visable bells
;; (kill-buffer "*scratch*") ;; Kill default scratch buffer
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
 
;; Extras
(add-to-list 'load-path "~/emacs_extensions/misc")
;;(require 'pabbrev)
 
;; Twitter
;;(require 'twittering-mode)
;;(setq twittering-username "")
;;(setq twittering-password "")
 
;; Cursor Preferences
(cond (window-system
(progn
(setq default-frame-alist
(append default-frame-alist
'((cursor-type . bar)
)))
(setq initial-frame-alist
'( (cursor-type . bar)
)))))
 
;; Edit .emacs shortcut
(defun dot-emacs ()
"Visit .emacs"
(interactive)
(find-file "~/.emacs"))
 
;; ASpell And FlySpell
(setq ispell-program-name "/opt/local/bin/aspell")
(add-hook 'text-mode-hook
'(lambda()
(flyspell-mode)
))
 
;; Text Mode
(add-hook 'text-mode-hook 'auto-fill-mode)
(add-hook 'text-mode-hook 'longlines-mode)
 
;; Kill without confirmation
(global-set-key "\C-xk" 'kill-current-buffer)
(defun kill-current-buffer ()
"Kill the current buffer, without confirmation."
(interactive)
(kill-buffer (current-buffer)))
 
;; Google Search
(defun search-google ()
"Prompt for a query in the minibuffer, launch the web browser and query google."
(interactive)
(let ((search (read-from-minibuffer "Google Search: ")))
(browse-url (concat "http://www.google.com/search?q=" search))))
 
;; Remove hard wrapped endings
(defun remove-hard-wrap-paragraph ()
"Replace newline chars in current paragraph by single spaces."
(interactive)
(let ((fill-column 90002000))
(fill-paragraph nil)))
 
(defun remove-hard-wrap-region (start end)
"Replace newline chars in region by single spaces."
(interactive "r")
(let ((fill-column 90002000))
(fill-region start end)))
 
(global-set-key (kbd "M-Q") 'remove-hard-wrap-paragraph)
 
(defun toggle-truncate-lines ()
"Toggle the variable truncate-lines between true and false"
(interactive)
(if (eq truncate-lines 't)
(set-variable 'truncate-lines nil)
(set-variable 'truncate-lines 't)
)
)
(global-set-key (kbd "<f7>") 'toggle-truncate-lines)
 
;; Ruby Mode
(add-to-list 'load-path "~/emacs_extensions/ruby-mode")
(require 'ruby-mode)
(require 'ruby-electric)
 
(defun ruby-eval-buffer () (interactive)
"Evaluate the buffer with ruby."
(shell-command-on-region (point-min) (point-max) "ruby"))
 
(defun ruby-load-current-buffer ()
"Load current buffer's Ruby file into the inferior Ruby process.
Saving the current buffer first if needed."
(interactive)
(let ((buffer (current-buffer)))
(or (eq major-mode 'ruby-mode)
(error "Not ruby mode"))
(save-buffer buffer)
(comint-send-string
(ruby-proc)
(concat "(load '" (buffer-file-name buffer) "'\)\n")
)
)
)
 
(defun run-ruby-file ()
(interactive)
(let ((buffer (current-buffer)))
(start-process "run-ruby-file" "*run-ruby-file*" "ruby" (buffer-file-name buffer)))
)
 
(add-hook 'inf-ruby-load-hook
(function (lambda ()
(define-key ruby-mode-map [f8] 'run-ruby-file)
(define-key ruby-mode-map "\C-c\C-i" 'run-ruby)
))
)
 
(defun my-ruby-mode-hook ()
(setq standard-indent 4)
;;(pabbrev-mode t)
(ruby-electric-mode t)
(define-key ruby-mode-map "\C-c\C-a" 'ruby-eval-buffer))
(add-hook 'ruby-mode-hook 'my-ruby-mode-hook)
 
 
(defun my-ruby-mode-hook ()
(setq standard-indent 4)
;;(pabbrev-mode t)
(ruby-electric-mode t)
(define-key ruby-mode-map "\C-c\C-a" 'ruby-eval-buffer))
(add-hook 'ruby-mode-hook 'my-ruby-mode-hook)
 
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
 
;; Rinari Mode (Rails)
(add-to-list 'load-path "~/emacs_extensions/rinari")
(add-to-list 'load-path "~/emacs_extensions/rinari/rhtml")
 
(defun my-rhtml-mode-hook ()
(auto-fill-mode -1)
(flyspell-mode -1)
(longlines-mode -1))
(add-hook 'rhtml-mode-hook 'my-rhtml-mode-hook)
 
(require 'rinari)
(setq auto-mode-alist (cons '("\\.rhtml\\'" . rhtml-mode) auto-mode-alist))
 
;; PHP Mode
(add-to-list 'load-path "~/.site-lisp/php-mode")
(require 'php-mode)
 
;; HTML Mode
 
;; Css Mode
(require 'css-mode)
 
;; Javascript Mode
 
;;;; Erlang Mode
;;;; This is needed for Erlang mode setup
;;(setq erlang-root-dir "/opt/local/lib/erlang")
;;(setq load-path (cons "/opt/local/lib/erlang/lib/tools-2.6.2/emacs" load-path))
;;(setq exec-path (cons "/opt/local/lib/erlang/bin" exec-path))
;;(require 'erlang-start)
;;
;;;; This is needed for Distel setup
;;(let ((distel-dir "~/emacs_extensions/distel/elisp"))
;; (unless (member distel-dir load-path)
;; ;; Add distel-dir to the end of load-path
;; (setq load-path (append load-path (list distel-dir)))))
;;
;;(require 'distel)
;;(distel-setup)
;;
;;;; Erlang customizations
;;(add-hook 'erlang-mode-hook
;; (lambda ()
;; ;; when starting an Erlang shell in Emacs, default in the node name
;; (setq inferior-erlang-machine-options '("-sname" "emacs"))
;; ;; add Erlang functions to an imenu menu
;; (imenu-add-to-menubar "imenu")))
;;
;;;; A number of the erlang-extended-mode key bindings are useful in the shell too
;;(defconst distel-shell-keys
;; '(("\C-\M-i" erl-complete)
;; ("\M-?" erl-complete)
;; ("\M-." erl-find-source-under-point)
;; ("\M-," erl-find-source-unwind)
;; ("\M-*" erl-find-source-unwind)
;; )
;; "Additional keys to bind when in Erlang shell.")
;;
;;(add-hook 'erlang-shell-mode-hook
;; (lambda ()
;; ;; add some Distel bindings to the Erlang shell
;; (dolist (spec distel-shell-keys)
;; (define-key erlang-shell-mode-map (car spec) (cadr spec)))))
 
;;(require 'slime-autoloads)
;;(setq slime-lisp-implementations
;; `((sbcl ("/opt/local/bin/sbcl"))
;; (clisp ("/opt/local/bin/clisp"))))
;;(add-hook 'lisp-mode-hook
;; (lambda ()
;; (cond ((not (featurep 'slime))
;; (require 'slime)
;; (normal-mode)))))
;;
;;(eval-after-load "slime"
;; '(slime-setup '(slime-fancy slime-banner)))
 
;; Slime
(setq inferior-lisp-program "/opt/local/bin/sbcl")
(add-to-list 'load-path "~/emacs_extensions/slime")
(require 'slime)
(slime-setup)
 
;;(pabbrev-mode-off)

Just wanted to say thanks!

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.