| 1 |
;; (require 'cl) |
| 2 |
|
| 3 |
(mapc (lambda (x) (add-to-list 'load-path (expand-file-name x))) |
| 4 |
'("~/.emacs.d" |
| 5 |
)) |
| 6 |
|
| 7 |
(defun require-all (packages) |
| 8 |
(mapcar #'require packages)) |
| 9 |
|
| 10 |
(require-all '( |
| 11 |
color-theme |
| 12 |
irblack |
| 13 |
parenface |
| 14 |
bar-cursor |
| 15 |
tls |
| 16 |
erc |
| 17 |
)) |
| 18 |
|
| 19 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 20 |
;; GLOBAL |
| 21 |
(color-theme-initialize) |
| 22 |
|
| 23 |
;; (if window-system |
| 24 |
;; (set-background-color "black") |
| 25 |
;; ()) |
| 26 |
(color-theme-irblack) |
| 27 |
;(if window-system |
| 28 |
; (color-theme-gentooish) |
| 29 |
; (color-theme-dark-laptop)) |
| 30 |
;(load-file "~/.emacs.d/color-theme-twilight.el") |
| 31 |
;(color-theme-twilight) |
| 32 |
;(load-file "~/.emacs.d/color-theme-inkpot.el") |
| 33 |
;(color-theme-inkpot) |
| 34 |
|
| 35 |
;; OS X settings |
| 36 |
;; (setq mac-option-key-is-meta nil) |
| 37 |
;; (setq mac-command-key-is-meta t) |
| 38 |
;; (setq mac-command-modifier 'meta) |
| 39 |
;; (setq mac-option-modifier nil) |
| 40 |
|
| 41 |
(bar-cursor-mode 1) |
| 42 |
(menu-bar-mode 0) |
| 43 |
(scroll-bar-mode -1) |
| 44 |
(tool-bar-mode 0) |
| 45 |
(setq linum-format "%3d ") |
| 46 |
(setq-default indent-tabs-mode nil) |
| 47 |
(setq indent-tabs-mode nil) |
| 48 |
(setq make-backup-files nil) |
| 49 |
(set-language-environment "UTF-8") |
| 50 |
(set-input-method "japanese-ascii") ; C-x C-m C-\ |
| 51 |
(winner-mode t) |
| 52 |
(display-battery-mode t) |
| 53 |
(setq display-time-24hr-format t) |
| 54 |
(display-time-mode t) |
| 55 |
(line-number-mode 1) |
| 56 |
(column-number-mode 1) |
| 57 |
|
| 58 |
(tooltip-mode nil) |
| 59 |
(setq midnight-mode t) |
| 60 |
(setq column-number-mode nil) |
| 61 |
(setq size-indication-mode nil) |
| 62 |
(setq mode-line-position nil) |
| 63 |
(mouse-avoidance-mode 'animate) |
| 64 |
(ido-mode t) |
| 65 |
|
| 66 |
;; Ido and uniquify options from http://curiousprogrammer.wordpress.com/2009/07/13/my-emacs-defaults/ |
| 67 |
(setq ido-enable-flex-matching t) |
| 68 |
(setq ido-create-new-buffer 'always) |
| 69 |
(setq uniquify-buffer-name-style 'reverse) |
| 70 |
(setq uniquify-separator "|") |
| 71 |
(setq uniquify-after-kill-buffer-p t) |
| 72 |
(setq uniquify-ignore-buffers-re "^\\*") |
| 73 |
|
| 74 |
(global-set-key "\C-m" 'reindent-then-newline-and-indent) ;No tabs |
| 75 |
(global-set-key "\C-a" 'beginning-of-line-text) |
| 76 |
|
| 77 |
(defun indent-or-expand (arg) |
| 78 |
"Either indent according to mode, or expand the word preceding |
| 79 |
point." |
| 80 |
(interactive "*P") |
| 81 |
(if (and |
| 82 |
(or (bobp) (= ?w (char-syntax (char-before)))) |
| 83 |
(or (eobp) (not (= ?w (char-syntax (char-after)))))) |
| 84 |
(dabbrev-expand arg) |
| 85 |
(indent-according-to-mode))) |
| 86 |
(global-set-key [C-tab] 'indent-according-to-mode) |
| 87 |
|
| 88 |
;; Proxy for ssh tunnel + privoxy |
| 89 |
;; (setq url-proxy-services '(("no_proxy" . "localhost") |
| 90 |
;; ("http" . "localhost:8118"))) |
| 91 |
|
| 92 |
(setq save-place-file "~/.emacs.d/saveplace") ;; keep my ~/ clean |
| 93 |
(setq-default save-place t) ;; activate it for all buffers |
| 94 |
(require 'saveplace) ;; Need to require after setq |
| 95 |
|
| 96 |
(setq backup-directory-alist |
| 97 |
`((".*" . "~/.emacs.d/backups/"))) |
| 98 |
(setq auto-save-file-name-transforms |
| 99 |
`((".*" "~/.emacs.d/backups/" t))) |
| 100 |
|
| 101 |
;; Enable ergoemacs layout |
| 102 |
;; (setenv "ERGOEMACS_KEYBOARD_LAYOUT" "dv") ; US Dvorak layout |
| 103 |
;; (load "~/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-mode") |
| 104 |
;; (ergoemacs-mode 1) |
| 105 |
|
| 106 |
;; Highlight bad whitespace |
| 107 |
(global-whitespace-mode t) |
| 108 |
(setq whitespace-style (quote (tabs tab-mark))) |
| 109 |
(setq-default show-trailing-whitespace t) |
| 110 |
|
| 111 |
;; Make % work like vi |
| 112 |
(global-set-key "%" 'match-paren) |
| 113 |
(defun match-paren (arg) |
| 114 |
"Go to the matching paren if on a paren; otherwise insert %." |
| 115 |
(interactive "p") |
| 116 |
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) |
| 117 |
((looking-at "\\s\)") (forward-char 1) (backward-list 1)) |
| 118 |
(t (self-insert-command (or arg 1))))) |
| 119 |
|
| 120 |
;; Prevent Emacs from stupidly auto-changing my working directory |
| 121 |
;; (defun find-file-save-default-directory () |
| 122 |
;; (interactive) |
| 123 |
;; (setq saved-default-directory default-directory) |
| 124 |
;; (ido-find-file) |
| 125 |
;; (setq default-directory saved-default-directory)) |
| 126 |
;; (global-set-key "\C-x\C-f" 'find-file-save-default-directory) |
| 127 |
|
| 128 |
;; Give killing lines advice |
| 129 |
(defadvice kill-ring-save (before slick-copy activate compile) |
| 130 |
"When called interactively with no active region, copy a single line instead." |
| 131 |
(interactive |
| 132 |
(if mark-active (list (region-beginning) (region-end)) |
| 133 |
(message "Copied line") |
| 134 |
(list (line-beginning-position) |
| 135 |
(line-beginning-position 2))))) |
| 136 |
(defadvice kill-region (before slick-cut activate compile) |
| 137 |
"When called interactively with no active region, kill a single line instead." |
| 138 |
(interactive |
| 139 |
(if mark-active (list (region-beginning) (region-end)) |
| 140 |
(list (line-beginning-position) |
| 141 |
(line-beginning-position 2))))) |
| 142 |
|
| 143 |
;; Tip of the day! |
| 144 |
(defun totd () |
| 145 |
(interactive) |
| 146 |
(random t) ;; seed with time-of-day |
| 147 |
(with-output-to-temp-buffer "*Tip of the day*" |
| 148 |
(let* ((commands (loop for s being the symbols |
| 149 |
when (commandp s) collect s)) |
| 150 |
(command (nth (random (length commands)) commands))) |
| 151 |
(princ |
| 152 |
(concat "Your tip for the day is:\n" |
| 153 |
"========================\n\n" |
| 154 |
(describe-function command) |
| 155 |
"\n\nInvoke with:\n\n" |
| 156 |
(with-temp-buffer |
| 157 |
(where-is command t) |
| 158 |
(buffer-string))))))) |
| 159 |
|
| 160 |
;; Set my location sunrise-sunset |
| 161 |
(setq calendar-latitude 45.4) |
| 162 |
(setq calendar-longitude -122.6) |
| 163 |
(setq calendar-location-name "Portland, OR") |
| 164 |
;; (setq calendar-latitude 17.5) |
| 165 |
;; (setq calendar-longitude 78.5) |
| 166 |
;; (setq calendar-location-name "Hyderabad, India") |
| 167 |
|
| 168 |
;; Start the server for emacsclient |
| 169 |
;(server-start) |
| 170 |
|
| 171 |
;; Custom key maps |
| 172 |
(defun set-keys (commands) |
| 173 |
(mapcar (lambda (x) |
| 174 |
(global-set-key (read-kbd-macro (first x)) (second x))) |
| 175 |
commands)) |
| 176 |
(set-keys '( |
| 177 |
("C-c t" totd) |
| 178 |
("C-c n" global-linum-mode) |
| 179 |
("C-c s p" (lambda () (interactive) |
| 180 |
(if (shellfm-running-p) |
| 181 |
(shellfm-pause) |
| 182 |
((shellfm 1) (shellfm-station-recommended 1))))) |
| 183 |
("C-c s n" shellfm-skip-track) |
| 184 |
("C-c s r" shellfm-station-recommended) |
| 185 |
("C-c s s" shellfm-station-artist) |
| 186 |
("C-c s m" shellfm-station-playlist) |
| 187 |
("C-c s l" shellfm-love-track) |
| 188 |
("C-c s a" shellfm-add-to-playlist) |
| 189 |
("C-c s q" shellfm 0) |
| 190 |
("C-c s i" shellfm-track-info) |
| 191 |
("C-c e" ido-erc-buffer) |
| 192 |
("C-S-<left>" shrink-window-horizontally) |
| 193 |
("C-S-<right>" enlarge-window-horizontally) |
| 194 |
("C-S-<down>" shrink-window) |
| 195 |
("C-S-<up>" enlarge-window) |
| 196 |
("M-s" save-buffer) |
| 197 |
("M-p" ctrl-y-in-vi) |
| 198 |
("M-n" ctrl-e-in-vi) |
| 199 |
("M-N" make-frame) |
| 200 |
("M-W" delete-frame) |
| 201 |
("M-w" ido-kill-buffer) |
| 202 |
("M-1" delete-other-windows) |
| 203 |
("M-!" delete-window) |
| 204 |
("M-2" split-window-horizontally) |
| 205 |
("M-@" split-window-vertically) |
| 206 |
("M-a" beginning-of-line) |
| 207 |
("M-o" other-window) |
| 208 |
("M-O" other-window) |
| 209 |
("M-`" next-window) |
| 210 |
("M-~" previous-window) |
| 211 |
("M-RET" ns-toggle-fullscreen) |
| 212 |
)) |
| 213 |
|
| 214 |
;;toggle full-screen |
| 215 |
;; (defun toggle-fullscreen () |
| 216 |
;; (interactive) |
| 217 |
;; (set-frame-parameter |
| 218 |
;; nil |
| 219 |
;; 'fullscreen |
| 220 |
;; (if (frame-parameter nil 'fullscreen) |
| 221 |
;; nil |
| 222 |
;; 'fullboth))) |
| 223 |
|
| 224 |
;; (global-set-key [(meta return)] 'toggle-fullscreen) |
| 225 |
|
| 226 |
;; Transparency |
| 227 |
(set-frame-parameter (selected-frame) 'alpha '(85 85)) |
| 228 |
(add-to-list 'default-frame-alist '(alpha 85 85)) |
| 229 |
;; (set-frame-font "Droid Sans Mono Dotted-12") |
| 230 |
(eval-when-compile (require 'cl)) |
| 231 |
(defun toggle-transparency () |
| 232 |
(interactive) |
| 233 |
(if (/= |
| 234 |
(cadr (find 'alpha (frame-parameters nil) :key #'car)) |
| 235 |
40) |
| 236 |
(set-frame-parameter nil 'alpha '(40 40)) |
| 237 |
(set-frame-parameter nil 'alpha '(85 85)))) |
| 238 |
(global-set-key (kbd "C-c T") 'toggle-transparency) |
| 239 |
|
| 240 |
;; Vim-like scrolling |
| 241 |
(defun ctrl-e-in-vi (n) |
| 242 |
(interactive "p") |
| 243 |
(scroll-up n)) |
| 244 |
|
| 245 |
(defun ctrl-y-in-vi (n) |
| 246 |
(interactive "p") |
| 247 |
(scroll-down n)) |
| 248 |
|
| 249 |
;; (global-set-key (kbd "<XF86AudioPlay>") |
| 250 |
;; (lambda () (interactive) |
| 251 |
;; (if (shellfm-running-p) |
| 252 |
;; (shellfm-skip-track) |
| 253 |
;; (shellfm 1)))) |
| 254 |
|
| 255 |
;; ERC stuff |
| 256 |
;; (setq erc-encoding-coding-alist (quote (("#lisp" . utf-8) |
| 257 |
;; ("#nihongo" . iso-2022-jp) |
| 258 |
;; ("#" . iso-latin-1) |
| 259 |
;; ("#" . iso-latin-1)))) |
| 260 |
;; (autoload 'erc "erc") |
| 261 |
;; (add-hook 'erc-mode-hook |
| 262 |
;; '(lambda () |
| 263 |
;; (setq scroll-margin 0) |
| 264 |
;; (setq erc-scrolltobottom-mode 1))) |
| 265 |
;; (load "~/.emacs.d/erc-bip") ;; Passwords here |
| 266 |
;; (defun ido-erc-buffer() |
| 267 |
;; (interactive) |
| 268 |
;; (switch-to-buffer |
| 269 |
;; (ido-completing-read "Channel:" |
| 270 |
;; (save-excursion |
| 271 |
;; (delq |
| 272 |
;; nil |
| 273 |
;; (mapcar (lambda (buf) |
| 274 |
;; (when (buffer-live-p buf) |
| 275 |
;; (with-current-buffer buf |
| 276 |
;; (and (eq major-mode 'erc-mode) |
| 277 |
;; (buffer-name buf))))) |
| 278 |
;; (buffer-list))))))) |
| 279 |
|
| 280 |
|
| 281 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 282 |
;; Haskell mode |
| 283 |
;; |
| 284 |
(load "~/.emacs.d/haskell-mode/haskell-site-file") |
| 285 |
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) |
| 286 |
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) |
| 287 |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) |
| 288 |
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent) |
| 289 |
|
| 290 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 291 |
;; Generic Lisp / Emacs Lisp |
| 292 |
;; from http://www.emacswiki.org/emacs/AutoIndentation |
| 293 |
|
| 294 |
(defadvice yank (after indent-region activate) |
| 295 |
(if (member major-mode '(clojure-mode emacs-lisp-mode lisp-mode)) |
| 296 |
(let ((mark-even-if-inactive t)) |
| 297 |
(indent-region (region-beginning) (region-end) nil)))) |
| 298 |
|
| 299 |
(defun tab-fix () |
| 300 |
(local-set-key [tab] 'indent-or-expand)) |
| 301 |
(defun slime-tab-fix () |
| 302 |
(local-set-key [tab] 'slime-complete-symbol)) |
| 303 |
(add-hook 'emacs-lisp-mode-hook 'tab-fix) |
| 304 |
(add-hook 'lisp-mode-hook 'slime-tab-fix) |
| 305 |
|
| 306 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 307 |
;; Translation |
| 308 |
(autoload 'babel "babel" |
| 309 |
"Use a web translation service to translate the message MSG." t) |
| 310 |
(autoload 'babel-region "babel" |
| 311 |
"Use a web translation service to translate the current region." t) |
| 312 |
(autoload 'babel-as-string "babel" |
| 313 |
"Use a web translation service to translate MSG, returning a string." t) |
| 314 |
(autoload 'babel-buffer "babel" |
| 315 |
"Use a web translation service to translate the current buffer." t) |
| 316 |
|
| 317 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 318 |
;; Custom |
| 319 |
(custom-set-variables |
| 320 |
;; custom-set-variables was added by Custom. |
| 321 |
;; If you edit it by hand, you could mess it up, so be careful. |
| 322 |
;; Your init file should contain only one such instance. |
| 323 |
;; If there is more than one, they won't work right. |
| 324 |
'(blink-cursor-mode nil) |
| 325 |
'(case-fold-search t) |
| 326 |
'(comint-scroll-to-bottom-on-input t) |
| 327 |
'(fancy-splash-image "") |
| 328 |
;; '(frame-background-mode (quote dark)) |
| 329 |
'(ido-decorations (quote ("" "" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]"))) |
| 330 |
'(ido-everywhere t) |
| 331 |
'(inhibit-startup-screen t) |
| 332 |
'(lisp-loop-forms-indentation 6) |
| 333 |
'(lisp-loop-keyword-indentation 6) |
| 334 |
'(lisp-simple-loop-indentation 6) |
| 335 |
'(mode-line-format (quote ("%e--[" mode-line-buffer-identification "]" (vc-mode vc-mode) " " mode-line-modes " " global-mode-string " %-"))) |
| 336 |
'(mode-line-in-non-selected-windows t) |
| 337 |
'(mode-line-modes (quote ("%[" "(" (:propertize ("" mode-name)) ("" mode-line-process) (:propertize ("" minor-mode-alist)) "%n" ")" "%]"))) |
| 338 |
'(mumamo-background-colors nil) |
| 339 |
'(require-final-newline t) |
| 340 |
'(savehist-mode t nil (savehist)) |
| 341 |
'(scroll-conservatively 100000) |
| 342 |
'(scroll-down-aggressively 0.0) |
| 343 |
'(scroll-margin 4) |
| 344 |
'(scroll-step 1) |
| 345 |
'(scroll-up-aggressively 0.0) |
| 346 |
'(show-paren-mode t nil (paren))) |
| 347 |
(custom-set-faces |
| 348 |
;; custom-set-faces was added by Custom. |
| 349 |
;; If you edit it by hand, you could mess it up, so be careful. |
| 350 |
;; Your init file should contain only one such instance. |
| 351 |
;; If there is more than one, they won't work right. |
| 352 |
'(mumamo-border-face-in ((t nil))) |
| 353 |
'(mumamo-border-face-out ((t nil)))) |
| 354 |
|
| 355 |
|
| 356 |
;;; This was installed by package-install.el. |
| 357 |
;;; This provides support for the package system and |
| 358 |
;;; interfacing with ELPA, the package archive. |
| 359 |
;;; Move this code earlier if you want to reference |
| 360 |
;;; packages in your .emacs. |
| 361 |
(when |
| 362 |
(load |
| 363 |
(expand-file-name "~/.emacs.d/elpa/package.el")) |
| 364 |
(package-initialize) |
| 365 |
(require 'starter-kit-elpa)) |