|
| 1 | +;; Don't Show Warnings |
| 2 | +(setq warning-minimum-level 'error) |
| 3 | +(setq warning-minimum-log-level 'error) |
| 4 | + |
| 5 | +;; Follow symlinks |
| 6 | +(setq vc-follow-symlinks t) |
| 7 | + |
| 8 | +(add-to-list 'load-path "~/.emacs.d/") |
| 9 | +(add-to-list 'load-path "~/.emacs.d/ecb/") |
| 10 | +(add-to-list 'load-path "~/.emacs.d/web-mode/") |
| 11 | +(add-to-list 'load-path "~/.emacs.d/rinari/") |
| 12 | +(add-to-list 'load-path "~/.emacs.d/rhtml") |
| 13 | +(add-to-list 'load-path "~/.emacs.d/php-mode") |
| 14 | +(add-to-list 'load-path "~/.emacs.d/haml-mode") |
| 15 | +(add-to-list 'load-path "~/.emacs.d/coffee-mode") |
| 16 | +(add-to-list 'load-path "~/.emacs.d/nginx-mode") |
| 17 | +(add-to-list 'load-path "~/.emacs.d/scss-mode") |
| 18 | +(add-to-list 'load-path "~/.emacs.d/yaml-mode") |
| 19 | +(add-to-list 'load-path "~/.emacs.d/git-modes") |
| 20 | +(add-to-list 'load-path "~/.emacs.d/auto-complete") |
| 21 | +(add-to-list 'load-path "~/.emacs.d/yasnippet") |
| 22 | + |
| 23 | +;; load some files |
| 24 | +(require 'rspec-mode) |
| 25 | +(require 'simple-wiki) |
| 26 | +(require 'web-mode) |
| 27 | +(require 'php-mode) |
| 28 | +(require 'haml-mode) |
| 29 | +(require 'coffee-mode) |
| 30 | +(require 'sass-mode) |
| 31 | +(require 'scss-mode) |
| 32 | +(require 'nginx-mode) |
| 33 | +(require 'yaml-mode) |
| 34 | +(require 'feature-mode) |
| 35 | +(require 'gitconfig-mode) |
| 36 | +(require 'python-mode) |
| 37 | +(load "ws-trim") |
| 38 | + |
| 39 | +(ido-mode t) |
| 40 | + |
| 41 | +;; mode loaders |
| 42 | +(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) |
| 43 | +(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) |
| 44 | +(add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode)) |
| 45 | +(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) |
| 46 | +(add-to-list 'auto-mode-alist '("\\.erb\\'" . rhtml-mode)) |
| 47 | +(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) |
| 48 | +(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) |
| 49 | +(add-to-list 'auto-mode-alist '("[.]stub_data$" . javascript-mode)) |
| 50 | +(add-to-list 'auto-mode-alist '("[.]wiki$" . simple-wiki-mode)) |
| 51 | +(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) |
| 52 | +(add-to-list 'auto-mode-alist '("\\.C\\'" . c++-mode)) |
| 53 | +(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode)) |
| 54 | +(add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode)) |
| 55 | +(add-to-list 'auto-mode-alist '("\\.scss\\'" . css-mode)) |
| 56 | +(add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode)) |
| 57 | +(add-to-list 'auto-mode-alist '("\\.haml\\'" . haml-mode)) |
| 58 | +(add-to-list 'auto-mode-alist '("\\.coffee\\'" . coffee-mode)) |
| 59 | +(add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode)) |
| 60 | +(add-to-list 'auto-mode-alist '("\\.sass\\'" . sass-mode)) |
| 61 | +(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) |
| 62 | +(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode)) |
| 63 | +(add-to-list 'auto-mode-alist '("\\Capfile\\'" . ruby-mode)) |
| 64 | +(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) |
| 65 | +(add-to-list 'auto-mode-alist '("\\.feature\\'" . feature-mode)) |
| 66 | +(add-to-list 'auto-mode-alist '("\\.gitconfig\'" . gitconfig-mode)) |
| 67 | +(add-to-list 'auto-mode-alist '("\\.gitmodules\'" . gitconfig-mode)) |
| 68 | + |
| 69 | +(add-to-list 'interpreter-mode-alist '("python" . python-mode)) |
| 70 | + |
| 71 | +(setq-default indent-tabs-mode nil) |
| 72 | +(setq-default tab-width 4) |
| 73 | +;;(setq indent-line-function 'insert-tab) |
| 74 | + |
| 75 | +;; ws-trim settings |
| 76 | +(global-ws-trim-mode t) |
| 77 | +(set-default 'ws-trim-level 1) |
| 78 | +(add-hook 'ws-trim-method-hook 'no-tabs-hook) |
| 79 | +(defun no-tabs-hook () |
| 80 | + (interactive) |
| 81 | + (if (string/= major-mode "html-mode") |
| 82 | + (ws-trim-tabs))) |
| 83 | + |
| 84 | +(put 'upcase-region 'disabled nil) |
| 85 | + |
| 86 | +;; turn off tabs |
| 87 | +(setq-default indent-tabs-mode nil) |
| 88 | + |
| 89 | +;; set line width |
| 90 | +(setq-default fill-column 120) |
| 91 | + |
| 92 | +;; set tab stops |
| 93 | +(setq tab-stop-list (number-sequence 4 120 4)) |
| 94 | + |
| 95 | +;; move directory where backups are saved |
| 96 | +(defvar user-temporary-file-directory |
| 97 | + (concat temporary-file-directory user-login-name "/")) |
| 98 | +(make-directory user-temporary-file-directory t) |
| 99 | +(setq backup-by-copying t) |
| 100 | +(setq backup-directory-alist |
| 101 | + `(("." . ,user-temporary-file-directory) |
| 102 | + (,tramp-file-name-regexp nil))) |
| 103 | +(setq auto-save-list-file-prefix |
| 104 | + (concat user-temporary-file-directory ".auto-saves-")) |
| 105 | +(setq auto-save-file-name-transforms |
| 106 | + `((".*" ,user-temporary-file-directory t))) |
| 107 | + |
| 108 | +;; ruby mode settings |
| 109 | +(add-hook 'ruby-mode-hook |
| 110 | + (lambda () |
| 111 | + (setq show-trailing-whitespace t) |
| 112 | + (local-set-key "\r" 'reindent-then-newline-and-indent) |
| 113 | + (setq indent-tabs-mode nil) |
| 114 | + (setq ruby-deep-indent-paren nil) |
| 115 | + (setq ruby-indent-tabs-mode nil))) |
| 116 | +;; (add-hook 'before-save-hook |
| 117 | +;; (lambda () (if (not indent-tabs-mode) |
| 118 | +;; (untabify (point-min) (point-max))))))) |
| 119 | +(setq ruby-indent-level 4) |
| 120 | + |
| 121 | +(defadvice ruby-indent-line (after unindent-closing-paren activate) |
| 122 | + (let ((column (current-column)) |
| 123 | + indent offset) |
| 124 | + (save-excursion |
| 125 | + (back-to-indentation) |
| 126 | + (let ((state (syntax-ppss))) |
| 127 | + (setq offset (- column (current-column))) |
| 128 | + (when (and (eq (char-after) ?\)) |
| 129 | + (not (zerop (car state)))) |
| 130 | + (goto-char (cadr state)) |
| 131 | + (setq indent (current-indentation))))) |
| 132 | + (when indent |
| 133 | + (indent-line-to indent) |
| 134 | + (when (> offset 0) (forward-char offset))))) |
| 135 | + |
| 136 | +(defadvice ruby-indent-line (after line-up-args activate) |
| 137 | + (let (indent prev-indent arg-indent) |
| 138 | + (save-excursion |
| 139 | + (back-to-indentation) |
| 140 | + (when (zerop (car (syntax-ppss))) |
| 141 | + (setq indent (current-column)) |
| 142 | + (skip-chars-backward " \t\n") |
| 143 | + (when (eq ?, (char-before)) |
| 144 | + (ruby-backward-sexp) |
| 145 | + (back-to-indentation) |
| 146 | + (setq prev-indent (current-column)) |
| 147 | + (skip-syntax-forward "w_.") |
| 148 | + (skip-chars-forward " ") |
| 149 | + (setq arg-indent (current-column))))) |
| 150 | + (when prev-indent |
| 151 | + (let ((offset (- (current-column) indent))) |
| 152 | + (cond ((< indent prev-indent) |
| 153 | + (indent-line-to prev-indent)) |
| 154 | + ((= indent prev-indent) |
| 155 | + (indent-line-to (+ prev-indent ruby-indent-level)))) |
| 156 | + (when (> offset 0) (forward-char offset)))))) |
| 157 | + |
| 158 | +;; python mode |
| 159 | + |
| 160 | +;; rhtml mode |
| 161 | +(add-hook 'rhtml-mode-hook |
| 162 | + (lambda () (rinari-launch))) |
| 163 | + |
| 164 | +;; web mode |
| 165 | +(add-hook 'web-mode-hook |
| 166 | + (lambda () |
| 167 | + (setq web-mode-markup-indent-offset 4) |
| 168 | + (setq show-trailing-whitespace t) |
| 169 | + (local-set-key "\r" 'reindent-then-newline-and-indent) |
| 170 | + (setq indent-tabs-mode nil))) |
| 171 | + |
| 172 | +;; c mode settings |
| 173 | +(add-hook 'c-mode-hook |
| 174 | + (lambda () |
| 175 | + (setq c-basic-offset 2))) |
| 176 | + |
| 177 | +;; html-mode settings |
| 178 | +(add-hook 'html-mode-hook |
| 179 | + (lambda () |
| 180 | + (setq sgml-basic-offset 4) |
| 181 | + (setq indent-tabs-mode nil))) |
| 182 | + |
| 183 | +;; xml-mode settings |
| 184 | +(add-hook 'nxml-mode-hook |
| 185 | + (lambda () |
| 186 | + (setq nxml-child-indent 4))) |
| 187 | + |
| 188 | +;; coffee-mode settings |
| 189 | +(add-hook 'coffee-mode-hook |
| 190 | + (lambda () |
| 191 | + (setq tab-width 2))) |
| 192 | + |
| 193 | +;; whitespace settings |
| 194 | +(autoload 'whitespace-mode "whitespace" "Toggle whitespace visualization." t) |
| 195 | +(autoload 'whitespace-toggle-options "whitespace" "Toggle local `whitespace-mode' options." t) |
| 196 | + |
| 197 | +(global-set-key (kbd "C-x w") 'delete-trailing-whitespace) |
| 198 | +(global-set-key (kbd "C-n") 'newline) |
| 199 | + |
| 200 | +(defun move-line (n) |
| 201 | + "Move the current line up or down by N lines." |
| 202 | + (interactive "p") |
| 203 | + (setq col (current-column)) |
| 204 | + (beginning-of-line) (setq start (point)) |
| 205 | + (end-of-line) (forward-char) (setq end (point)) |
| 206 | + (let ((line-text (delete-and-extract-region start end))) |
| 207 | + (forward-line n) |
| 208 | + (insert line-text) |
| 209 | + ;; restore point to original column in moved line |
| 210 | + (forward-line -1) |
| 211 | + (forward-char col))) |
| 212 | + |
| 213 | +(defun move-line-up (n) |
| 214 | + "Move the current line up by N lines." |
| 215 | + (interactive "p") |
| 216 | + (move-line (if (null n) -1 (- n)))) |
| 217 | + |
| 218 | +(defun move-line-down (n) |
| 219 | + "Move the current line down by N lines." |
| 220 | + (interactive "p") |
| 221 | + (move-line (if (null n) 1 n))) |
| 222 | + |
| 223 | +(global-set-key (kbd "ESC <up>") 'move-line-up) |
| 224 | +(global-set-key (kbd "ESC <down>") 'move-line-down) |
| 225 | + |
| 226 | +(define-key global-map (kbd "RET") 'newline-and-indent) |
| 227 | + |
| 228 | +;; aquamacs set opacity |
| 229 | +(add-to-list 'default-frame-alist '(alpha . (80 70))) |
| 230 | +;; aquamacs switch to white on black |
| 231 | +(require 'color-theme) |
| 232 | +(color-theme-clarity) |
| 233 | + |
| 234 | +(defface extra-whitespace-face |
| 235 | + '((t (:background "pale green"))) |
| 236 | + "Used for tabs and such.") |
| 237 | +(defvar my-extra-keywords |
| 238 | + '(("\t" . 'extra-whitespace-face))) |
| 239 | +(add-hook 'emacs-lisp-mode-hook |
| 240 | + (lambda () (font-lock-add-keywords nil my-extra-keywords))) |
| 241 | +(add-hook 'text-mode-hook |
| 242 | + (lambda () (font-lock-add-keywords nil my-extra-keywords))) |
| 243 | +(add-hook 'c-mode-common-hook |
| 244 | + (lambda () (font-lock-add-keywords nil my-extra-keywords))) |
| 245 | + |
| 246 | +(defun duplicate-line() |
| 247 | + (interactive) |
| 248 | + (move-beginning-of-line 1) |
| 249 | + (kill-line) |
| 250 | + (yank) |
| 251 | + (open-line 1) |
| 252 | + (next-line 1) |
| 253 | + (yank) |
| 254 | + ) |
| 255 | +(global-set-key (kbd "C-d") 'duplicate-line) |
| 256 | + |
| 257 | +;; Indent Rigidly N |
| 258 | +(defun indent-rigidly-n (n) |
| 259 | + "Indent the region, or otherwise the current line, by N spaces." |
| 260 | + (let* ((use-region (and transient-mark-mode mark-active)) |
| 261 | + (rstart (if use-region (region-beginning) (point-at-bol))) |
| 262 | + (rend (if use-region (region-end) (point-at-eol))) |
| 263 | + (deactivate-mark "irrelevant")) ; avoid deactivating mark |
| 264 | + (indent-rigidly rstart rend n))) |
| 265 | +(defun indent-rigidly-4 () |
| 266 | + "Indent the region, or otherwise the current line, by 4 spaces." |
| 267 | + (interactive) |
| 268 | + (indent-rigidly-n 4)) |
| 269 | +(defun outdent-rigidly-4 () |
| 270 | + "Indent the region, or otherwise the current line, by -4 spaces." |
| 271 | + (interactive) |
| 272 | + (indent-rigidly-n -4)) |
| 273 | +(defun outdent-rigidly-2 () |
| 274 | + "Indent the region, or otherwise the current line, by -2 spaces." |
| 275 | + (interactive) |
| 276 | + (indent-rigidly-n -2)) |
| 277 | +(global-set-key (kbd "M-<tab>") 'indent-rigidly-4) |
| 278 | +(global-set-key (kbd "C-M-<tab>") 'outdent-rigidly-4) |
| 279 | + |
| 280 | +;; force tab |
| 281 | +(global-set-key (kbd "C-<tab>") 'tab-to-tab-stop) |
| 282 | +(custom-set-variables |
| 283 | + ;; custom-set-variables was added by Custom. |
| 284 | + ;; If you edit it by hand, you could mess it up, so be careful. |
| 285 | + ;; Your init file should contain only one such instance. |
| 286 | + ;; If there is more than one, they won't work right. |
| 287 | + '(safe-local-variable-values (quote ((setq ruby-indent-tabs-mode nil) (ruby-compilation-executable . "ruby") (ruby-compilation-executable . "ruby1.8") (ruby-compilation-executable . "ruby1.9") (ruby-compilation-executable . "rbx") (ruby-compilation-executable . "jruby"))))) |
| 288 | +(custom-set-faces |
| 289 | + ;; custom-set-faces was added by Custom. |
| 290 | + ;; If you edit it by hand, you could mess it up, so be careful. |
| 291 | + ;; Your init file should contain only one such instance. |
| 292 | + ;; If there is more than one, they won't work right. |
| 293 | + ) |
0 commit comments