lloyda2 / dotfiles

A sampling of my configuration files. Unlike all the other cool people who use computers, I don't have my own tracking and deployment script yet, so I'm just using hard links.

Clone this repository (size: 57.8 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/lloyda2/dotfiles/
commit 37: 7d1be2e5d486
parent 36: 69caceff8854
branch: default
tags: tip
Massive .emacs optimization!
Adam Lloyd / lloyda2
6 weeks ago

Changed (Δ2.8 KB):

raw changeset »

emacs (87 lines added, 185 lines removed)

Up to file-list emacs:

1
1
;; .emacs
2
2
3
;;; uncomment this line to disable loading of "default.el" at startup
4
;; (setq inhibit-default-init t)
3
(add-to-list 'load-path "~/lib/elisp")
4
(add-to-list 'load-path "~/lib/elisp/color-theme-molokai")
5
(add-to-list 'load-path "~/lib/elisp/ruby-mode")
6
(add-to-list 'load-path "/usr/share/emacs/site-lisp/haskell-mode")
5
7
6
;; enable visual feedback on selections
7
;(setq transient-mark-mode t)
8
(require 'color-theme-molokai)
9
(require 'filladapt)
10
(require 'icomplete+)
11
;; (require 'git)
8
12
9
;; default to better frame titles
10
(setq frame-title-format
11
      (concat  "%b - emacs@" (system-name)))
13
;; (autoload 'git-blame-mode "git-blame"
14
;;   "Minor mode for incremental blame for Git." t)
15
(autoload 'haskell-mode "haskell-mode"
16
  "Major mode for editing Haskell files.")
17
(autoload 'php-mode "php-mode"
18
  "Major mode for editing PHP files.")
19
(autoload 'ruby-mode "ruby-mode"
20
  "Major mode for editing Ruby files.")
12
21
13
;; default to unified diffs
22
;; (load "~/lib/elisp/nxhtml/autostart.el")
23
24
14
25
(setq diff-switches "-u")
26
(setq frame-title-format (concat "%b - emacs@" (system-name)))
27
(setq inhibit-startup-screen t)
28
(setq prolog-program-name "/usr/bin/pl")
29
(setq require-final-newline 'visit-save)
15
30
16
;; always end a file with a newline
17
;(setq require-final-newline 'query)
18
19
;;; uncomment for CJK utf-8 support for non-Asian users
20
;; (require 'un-define)
21
(custom-set-variables
22
  ;; custom-set-variables was added by Custom.
23
  ;; If you edit it by hand, you could mess it up, so be careful.
24
  ;; Your init file should contain only one such instance.
25
  ;; If there is more than one, they won't work right.
26
 '(column-number-mode 1)
27
 '(inhibit-startup-screen t))
28
(custom-set-faces
29
  ;; custom-set-faces was added by Custom.
30
  ;; If you edit it by hand, you could mess it up, so be careful.
31
  ;; Your init file should contain only one such instance.
32
  ;; If there is more than one, they won't work right.
33
; '(default ((t (:inherit nil :stipple nil :background "#ffffff" :foreground "#1a1a1a" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 102 :width normal :foundry "unknown" :family "Inconsolata"))))
34
 '(fringe ((((class color) (background light)) nil))))
31
(setq-default browse-url-browser-function 'browse-url-generic)
32
(setq-default browse-url-generic-program "chromium")
33
(setq-default calendar-week-start-day 1)
34
(setq-default indent-tabs-mode nil)
35
(setq-default mail-self-blind t)
36
(setq-default rmail-file-name "~/.rmail")
37
(setq-default standard-indent 4)
38
(setq-default tab-width 4)
39
(setq-default user-mail-address "lloyda2@rpi.edu")
35
40
36
41
37
42
(set-face-attribute 'default nil
38
                    :family "Inconsolata" :height 102)
39
;(set-face-attribute 'default nil :height 152)
43
                    :family "Inconsolata"
44
                    :height 102)
40
45
41
;;;; EXTERNAL LIBRARIES ;;;;
42
;; add path for my elisp libraries
43
(add-to-list 'load-path "~/lib/elisp/")
44
;; add path for dvc
45
;(add-to-list 'load-path "/usr/share/emacs/site-lisp/dvc")
46
;(require 'xhg)
47
46
48
;; add path for ruby-mode
49
(add-to-list 'load-path "~/lib/elisp/ruby-mode")
50
(autoload 'ruby-mode "ruby-mode" "Major mode for editing Ruby files.")
47
(add-to-list 'auto-mode-alist '("\.lua$" . lua-mode))
48
(add-to-list 'auto-mode-alist '("\.org$" . org-mode))
49
(add-to-list 'auto-mode-alist '("\.php[345]?$" . php-mode))
50
(add-to-list 'auto-mode-alist '("\.pl$" . prolog-mode))
51
52
(add-to-list 'auto-mode-alist '("/PKGBUILD$" . shell-script-mode))
53
54
55
;; (defun doxymacs-font-lock-hook ()
56
;;   (if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
57
;;       (doxymacs-font-lock)))
58
59
(defun open-new-line (arg)
60
  "Open a new line below the current line and move to its start."
61
  (interactive "P")
62
  (end-of-line)
63
  (newline-and-indent))
64
65
(dolist (command '(yank yank-pop))
66
  (eval `(defadvice ,command (after indent-region activate)
67
           (and (not current-prefix-arg)
68
                (member major-mode '(c-mode
69
                                     c++-mode
70
                                     emacs-lisp-mode
71
                                     haskell-mode
72
                                     latex-mode
73
                                     lua-mode
74
                                     plain-tex-mode
75
                                     python-mode
76
                                     ruby-mode
77
                                     scheme-mode))
78
                (let ((mark-even-if-inactive transient-mark-mode))
79
                  (indent-region (region-beginning) (region-end) nil))))))
80
81
82
(add-hook 'c-mode-common-hook 'turn-on-filladapt-mode)
83
;; (add-hook 'font-lock-mode-hook  'doxymacs-font-lock-hook)
84
(add-hook 'nxml-mode-hook
85
          (lambda () (rng-validate-mode 0))
86
          t)
51
87
(add-hook 'ruby-mode-hook
52
88
          (lambda ()
53
89
            (add-hook 'local-write-file-hooks
61
97
            (define-key ruby-mode-map "\C-m" 'reindent-then-newline-and-indent)
62
98
            ))
63
99
64
;(add-to-list 'load-path "~/lib/elisp/emacs-rails-reloaded")
65
;(require 'rails-autoload)
66
100
67
;; use icomplete+
68
(require 'icomplete+)
69
70
;; use emacs-git-mode
71
;; (require 'git)
72
;; (autoload 'git-blame-mode "git-blame" "Minor mode for incremental blame for Git." t)
73
74
;; use nxhtml
75
(load "~/lib/elisp/nxhtml/autostart.el")
76
(add-hook 'nxml-mode-hook
77
            (lambda () (rng-validate-mode 0))
78
            t)
79
80
;; use haskell-mode
81
(add-to-list 'load-path "/usr/share/emacs/site-lisp/haskell-mode")
82
(autoload 'haskell-mode "haskell-mode" "A Haskell editing mode")
83
84
;; use doxymacs
85
;(require 'doxymacs)
86
;(add-hook 'c-mode-common-hook 'doxymacs-mode)
87
;(defun my-doxymacs-font-lock-hook ()
88
;  (if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
89
;      (doxymacs-font-lock)))
90
;(add-hook 'font-lock-mode-hook 'my-doxymacs-font-lock-hook)
91
92
;; use filladapt
93
(require 'filladapt)
94
(add-hook 'c-mode-common-hook 'turn-on-filladapt-mode)
95
96
;; use color themes
97
(load-file "~/lib/elisp/color-theme-molokai/color-theme-molokai.el")
98
(color-theme-molokai)
99
100
101
;;;; MODES ;;;;
102
;; Configure org-mode
103
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
104
(global-set-key "\C-c l" 'org-store-link)
105
101
(global-set-key "\C-c a" 'org-agenda)
106
102
(global-set-key "\C-c b" 'org-iswitchb)
107
(setq-default calendar-week-start-day 1)
103
(global-set-key "\C-c l" 'org-store-link)
104
(global-set-key "\C-m" 'newline-and-indent)
105
(global-set-key "\C-o" 'open-new-line)
106
(global-set-key "\C-w" 'backward-kill-word)
107
(global-set-key "\C-x\C-k" 'kill-region)
108
(global-set-key "\C-x\C-m" 'execute-extended-command)
108
109
109
;; use lua mode for lua files
110
;; (setq auto-mode-alist (cons '("\.lua$" . lua-mode) auto-mode-alist))
111
;; (autoload 'lua-mode "lua-mode" "Lua editing mode." t)
112
110
113
;; use prolog mode for prolog files
114
(setq prolog-program-name "/usr/bin/pl")
115
(setq auto-mode-alist (append '(("/*.\.pl$" . prolog-mode)) auto-mode-alist))
116
117
;; use php mode for php files
118
(autoload 'php-mode "php-mode.el" "PHP mode." t)
119
(setq auto-mode-alist (append '(("/*.\.php[345]?$" . php-mode)) auto-mode-alist))
120
121
;; use shell-script-mode for PKGBUILDs
122
(setq auto-mode-alist (append '(("/PKGBUILD$" . shell-script-mode))
123
                              auto-mode-alist))
124
125
126
;;;; GLOBAL MINOR MODES ;;;;
127
;; use spaces instead of tabs
128
(setq-default indent-tabs-mode nil)
129
(setq-default tab-width 2)
130
(setq-default standard-indent 2)
131
132
;; show line numbers in left margin
133
;(global-linum-mode 1)
134
;(setq linum-format "%d ")
135
;(setq linum-eager nil)
136
111
(ansi-color-for-comint-mode-on)
112
(color-theme-molokai)
113
(column-number-mode 1)
114
;; (display-battery-mode 1)
137
115
(display-time-mode 1)
138
139
;; highlight the current line
140
116
(global-hl-line-mode 1)
141
142
;; get rid of the scrollbar and menubar
117
(icomplete-mode 1)
118
(menu-bar-mode 0)
143
119
(scroll-bar-mode 0)
144
120
(tool-bar-mode 0)
145
(menu-bar-mode 0)
146
121
147
;; display battery info on the mode line
148
;(display-battery-mode 1)
149
150
;; display the column number in the mode line
151
(setq-default column-number-mode 1)
152
153
;; enable adaptive fill mode
154
;(setq-default adaptive-fill-mode 1)
155
156
;; enable icomplete-mode
157
(icomplete-mode 1)
158
159
;; use color in shells
160
(ansi-color-for-comint-mode-on)
161
162
163
;;;; CUSTOM FUNCTION DEFINITIONS ;;;;
164
(defun open-new-line (arg)
165
  "Open a new line below the current line and move to its start."
166
  (interactive "P")
167
  (end-of-line)
168
  (newline-and-indent))
169
170
;; auto-indent yanked text in code
171
(dolist (command '(yank yank-pop))
172
  (eval `(defadvice ,command (after indent-region activate)
173
           (and (not current-prefix-arg)
174
                (member major-mode '(emacs-lisp-mode
175
                                     scheme-mode
176
                                     haskell-mode
177
                                     ruby-mode
178
                                     python-mode
179
                                     c-mode
180
                                     c++-mode
181
                                     latex-mode
182
                                     plain-tex-mode
183
                                     lua-mode))
184
                (let ((mark-even-if-inactive transient-mark-mode))
185
                  (indent-region (region-beginning) (region-end) nil))))))
186
187
188
;;;; VARIABLE OVERRIDES ;;;;
189
;; tab width
190
(setq-default tab-width 4)
191
192
;; for mail
193
(setq-default user-mail-address "lloyda2@rpi.edu")
194
(setq-default mail-self-blind t)
195
(setq-default rmail-file-name "~/.rmail")
196
197
;; default web browser
198
(setq-default browse-url-browser-function 'browse-url-generic)
199
(setq-default browse-url-generic-program "chromium")
200
201
202
;;;; CUSTOM KEYBINDINGS ;;;;
203
;; give C-x <return> the same functionality as M-x
204
(global-set-key "\C-x\C-m" 'execute-extended-command)
205
206
;; bind backward-kill-word to C-w; rebind kill-region to C-x C-k
207
(global-set-key "\C-w" 'backward-kill-word)
208
(global-set-key "\C-x\C-k" 'kill-region)
209
210
;; rebind C-o to open-new-line
211
(global-set-key "\C-o" 'open-new-line)
212
213
;; rebind enter to newline-and-indent
214
(global-set-key "\C-m" 'newline-and-indent)
215
216
;; bind C-f12 to shell
217
(global-set-key [(control f12)] 'shell)
218
219
220
(put 'upcase-region 'disabled nil)
221
122
222
123
(put 'downcase-region 'disabled nil)
124
(put 'upcase-region 'disabled nil)