summaryrefslogtreecommitdiffstats
path: root/emacs
blob: 24751c88a974699eadaf3c79923840bc0e23fa9b (plain)
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
;; -*- mode: Emacs-Lisp; mode: whitespace -*-
(add-to-list 'load-path "~/.emacs.d")

;; Requires
(require 'paren)
(require 'uniquify)
(require 'autopair)
(require 'color-theme)
(require 'flymake)
(require 'org-install)
(require 'zenburn)
(require 'lua-mode)
(require 'tabbar)
(require 'minimap)
;(require 'manage-org)

;; Auto complete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)

;; Autoloads
(autoload 'vala-mode
  "vala-mode.elc"    "A Major mode for editing Vala files"        t)
(autoload 'csharp-mode
  "csharp-mode.elc"  "A Major mode for editing C# files"          t)
(autoload 'javascript-mode
  "javascript.elc"   "A Major mode for editing JavaScript files"  t)
(autoload 'sqlplus-mode
  "sqlplus.elc"      "A Major mode for communicating with Oracle" t)
(autoload 'batch-mode
  "batch-mode.elc"   "A Major mode for editing Batch files"       t)
(autoload 'rainbow-mode
  "rainbow-mode.elc" "A Minor mode for showing colors inline"     t)

;; Functions
(require 'functions)

;; Platform specifics
;(if (eq system-type 'gnu/linux)         ; if we're running linux
(set-default-font "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*");)

;; Variables
(setq
 inhibit-startup-message t              ; don't show welcom screen
 require-final-newline t                ; always append a newline to a file, if
                                        ; it doesn't have one
 font-lock-maximum-decoration t         ; denotes my interest in maximum
                                        ; possible fontification
 uniquify-buffer-name-style 'reverse    ; reverse uniquify file names
 backup-directory-alist `((".*" . ,temporary-file-directory))
                                        ; backup file location
 auto-save-file-name-transforms `((".*" ,temporary-file-directory t))
                                        ; autosave file location
 whitespace-line-column 80              ; change color after the 80th column
 whitespace-style '(tabs trailing lines-tail)
 inhibit-default-init t)

(setq org-todo-keywords (quote ((sequence "TODO(t)"
                                          "NEXT(n)"
                                          "|" "Done(d!/!)")
                                (sequence "WAITING(w@/!)"
                                          "SOMEDAY(s!)"
                                          "|" "CANCELLED(c@/!)")
                                (sequence "QUOTE(q!)"
                                          "QUOTED(Q!)"
                                          "|" "APPROVED(A@)"
                                          "EXPIRED(E@)"
                                          "REJECTED(R@)")
                                (sequence "OPEN(O)"
                                          "|" "CLOSED(C)"))    ))
(setq org-todo-keyword-faces
      (quote (("TODO"      :foreground "red"          :weight bold)
              ("NEXT"      :foreground "blue"         :weight bold)
              ("DONE"      :foreground "forest green" :weight bold)
              ("WAITING"   :foreground "yellow"       :weight bold)
              ("SOMEDAY"   :foreground "goldenrod"    :weight bold)
              ("CANCELLED" :foreground "orangered"    :weight bold)
              ("QUOTE"     :foreground "hotpink"      :weight bold)
              ("QUOTED"    :foreground "indianred1"   :weight bold)
              ("APPROVED"  :foreground "forest green" :weight bold)
              ("EXPIRED"   :foreground "olivedrab1"   :weight bold)
              ("REJECTED"  :foreground "olivedrab"    :weight bold)
              ("OPEN"      :foreground "magenta"      :weight bold)
              ("CLOSED"    :foreground "forest green" :weight bold))))
(setq org-use-fast-todo-selection t)
(setq org-todo-state-tags-triggers
      (quote (("CANCELLED"
               ("CANCELLED" . t))
              ("WAITING"
               ("WAITING" . t))
              ("SOMEDAY"
               ("WAITING" . t))
              (done
               ("WAITING"))
              ("TODO"
               ("WAITING")
               ("CANCELLED"))
              ("NEXT"
               ("WAITING"))
              ("DONE"
               ("WAITING")
               ("CANCELED")))))
(setq org-default-notes-file "~/prj/org/refile.org")
(setq org-capture-templates
      (quote (("t" "todo" entry (file "~/prj/org/refile.org") "* TODO %?
%U
%a" :clock-in t :clock-resume t)
              ("n" "note" entry (file "~/prj/org/refile.org") "* %?
%U
%a
:CLOCK:
:END:" :clock-in t :clock-resume t))))
(setq org-completion-use-ido t)         ; Use IDO for target completion
(setq org-refile-targets
      (quote ((org-agenda-files :maxlevel . 5) (nil :maxlevel . 5))))
                                        ; Targets include this file and any file
                                        ; and any file contributing to the
                                        ; agenda - up to 5 levels deep
(setq org-refile-use-outline-path (quote file))
                                        ; Targets start with the file name -
                                        ; allows creating level 1 tasks
(setq org-outline-path-complete-in-steps t)
                                        ; Targets complete in steps so we start
                                        ; with filename, TAB shows the next
                                        ; level of targets etc
(setq org-refile-allow-creating-parent-nodes (quote confirm))
                                        ; Allow refile to create parent tasks
                                        ; with confirmation
(setq org-agenda-custom-commands
      (quote
       (("w" "Tasks waiting on something"
         tags "WAITING/!"
         ((org-use-tag-inheritance nil)
          (org-agenda-todo-ignore-scheduled nil)
          (org-agenda-todo-ignore-deadlines nil)
          (org-agenda-todo-ignore-with-date nil)
          (org-agenda-overriding-header "Waiting Tasks")))
        ("r" "Refile New Notes and Tasks"
         tags "LEVEL=1+REFILE"
         ((org-agenda-todo-ignore-with-date nil)
          (org-agenda-todo-ignore-deadlines nil)
          (org-agenda-todo-ignore-scheduled nil)
          (org-agenda-overriding-header "Tasks to Refile")))
        ("N" "Notes"
         tags "NOTE"
         ((org-agenda-overriding-header "Notes")))
        ("n" "Next"
         tags-todo "-WAITING-CANCELLED/!NEXT"
         ((org-agenda-overriding-heaer "Next Tasks")))
        ("p" "Projects"
         tags-todo "LEVEL=2-REFILE|LEVEL=1+REFILE/!-DONE-CANCELLED"
         (;(org-agenda-skip-function 'bh/skip-non-projects)
          (org-agenda-overriding-header "Projects")))
        ("o" "other (Non-Project) tasks"
         tags-todo "LEVEL=2-REFILE|LEVEL=1+REFILE/!-DONE-CANCELLED"
         (;(org-agenda-skip-function 'bh/skip-projects)
          (org-agenda-overriding-header "Other Non-Project Tasks")))
        ("A" "Tasks to be Archived"
         tags "LEVEL=2-REFILE/DONE|CANCELLED"
         ((org-agenda-overriding-header "Tasks to Archive")))
        ("h" "Habits"
         tags "STYLE=\"habit\""
         ((org-agenda-todo-ignore-with-date nil)
          (org-agenda-todo-ignore-scheduled nil)
          (org-agenda-todo-ignore-deadlines nil)
          (org-agenda-overriding-header "Habits")))
        ("#" "Stuck Projects"
         tags-todo "LEVEL=2-REFILE|LEVEL=1+REFILE/!-DONE-CANCELLED"
         ((org-agenda-skip-function 'bh/skip-non-stuck-projects)
          (org-agenda-overriding-header "Stuck Projects")))
        ("c" "Select default clocking task"
         tags "LEVEL=2-REFILE"
         ((org-agenda-skip-function
           '(org-agenda-skip-subree-if 'notregexp "^\\*\\* Organization"))
          (org-agenda-overriding-header
           "Set default clocking task with C-u C-u I"))))))
(setq-default indent-tabs-mode nil)     ; spaces, no tabs

(fset 'yes-or-no-p 'y-or-n-p)           ; switch yes or no answers to y or n
                                        ; answers

;; Mode settings
(        tool-bar-mode     -1)          ; no toolbar
(        menu-bar-mode     -1)          ; no menu
(     line-number-mode     -1)          ; don't show line numbers in splitter
(    global-linum-mode      t)          ; show line numbers in gutter
(   column-number-mode      t)          ; show column numbers in splitter
(global-font-lock-mode      t)          ; show syntax highlighting
(      show-paren-mode      t)          ; show matching parens
( autopair-global-mode       )          ; enable autopair mode
(delete-selection-mode      t)          ; delete selection upon typing
(global-auto-complete-mode -1)          ; don't enable autocomplete for
                                        ; everything

;; Keybindings
(global-set-key "\C-m"  'newline-and-indent) ; Automatically indent on newline
;;; Org Mode
(global-set-key      "\C-cl"       'org-store-link              )
(global-set-key      "\C-ca"       'org-agenda                  )
(global-set-key      "\C-cb"       'org-iswitchb                )
(global-set-key (kbd "<f12>")      'org-agenda                  )
;(global-set-key (kbd "<f5>")       'bh/org-todo                 )
;(global-set-key (kbd "<S-f5>")     'bh/widen                    )
(global-set-key (kbd "<f7>")       'set-truncate-lines          )
(global-set-key (kbd "<f8>")       'org-cycle-agenda-files      )
;(global-set-key (kbd "<f9> b")     'bbdb                        )
(global-set-key (kbd "<f9> c")     'calendar                    )
(global-set-key (kbd "<f9> f")     'boxquote-insert-file        )
;(global-set-key (kbd "<f9> g")     'gnus                        )
(global-set-key (kbd "<f9> h")     'bh/hide-other               )
;(global-set-key (kbd "<f9> i")     'bh/org-info                 )
;(global-set-key (kbd "<f9> I")     'bh/clock-in                 )
;(global-set-key (kbd "<f9> O")     'bh/clock-out                )
(global-set-key (kbd "<f9> r")     'boxquote-region             )
(global-set-key (kbd "<f9> s")     'bh/go-to-scratch            )
;(global-set-key (kbd "<f9> t")     'bh/insert-inactive-timestamp)
(global-set-key (kbd "<f9> u")     'bh/untabify                 )
(global-set-key (kbd "<f9> v")     'visible-mode                )
;(global-set-key (kbd "<f9> SPC")   'bh/clock-in-last-task       )
(global-set-key (kbd "C-<f9>")     'previous-buffer             )
(global-set-key (kbd "C-x n r")    'narrow-to-region            )
(global-set-key (kbd "C-<f10>")    'next-buffer                 )
(global-set-key (kbd "<f11>")      'org-clock-goto              )
(global-set-key (kbd "C-<f11>")    'org-clock-in                )
(global-set-key (kbd "C-s-<f12>")  'bh/save-then-publish        )
(global-set-key (kbd "M-<f11>")    'org-resolve-clocks          )
(global-set-key (kbd "C-M-r")      'org-capture                 )
(global-set-key (kbd "M-<f9>")     'bh/killframe                )
(global-set-key [C-next]           'tabbar-forward              )
(global-set-key [C-prior]          'tabbar-backward             )
(global-set-key [C-tab]            'hs-toggle-hiding            )

;; File associations
(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
(add-to-list 'auto-mode-alist '("\\.cs$"   . csharp-mode))
(add-to-list 'auto-mode-alist '("\\.bat$"  . batch-mode))

(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))

(add-to-list 'compilation-finish-functions 'my-comp-finish-function)

;; Color theme
;;(require 'color-theme-weirdness)
(color-theme-zenburn)

;; Test for frame fonts
(defun setup-system-frame-colours (&rest frame)
  (let ((f (if (car frame)
               (car frame)
             (selected-frame))))
    (progn
      (set-frame-font "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*"))))
(require 'server)
(defadvice server-create-window-system-frame
  (after set-system-frame-colours ())
  "Set custom frame colours when creating the first frame on a display"
  (message "Running after frame-initialize")
  (setup-system-frame-colours))
(ad-activate 'server-create-window-system-frame)
(add-hook 'after-make-frame-functions 'setup-system-frame-colours t)

;; Hooks
(add-hook 'find-file-hook 'flymake-find-file-hook)
(add-hook 'find-file-hook
          (lambda ()
            (whitespace-mode t)))
(add-hook 'after-save-hook
          (lambda ()
            (setq fname (buffer-file-name))
            (setq suffix (file-name-extension fname))

            (if (string-equal suffix "el")
                (byte-compile-file fname))))
;(add-hook 'after-make-frame-hook
;          (lambda ()
;            (set-default-font "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*")
;            (message "hello")
;            (set-frame-font "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*")))
;(add-hook 'after-make-frame-functions
;          (lambda (&rest frame)
;            (message "world")
;            (set-frame-font "-*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*")) t)
;;; C
(add-hook 'c-mode-hook
          (lambda ()
            (whitespace-mode t)
            (hs-minor-mode t)))
;;; CSS
(add-hook 'css-mode-hook
          (lambda ()
            (rainbow-mode)))
;;; Emacs Lisp
(add-hook 'emacs-lisp-mode-hook
          (lambda ()
            (whitespace-mode t)
            (auto-complete-mode t)))
;;; Interactive Lisp
(add-hook 'lisp-interaction-mode-hook
          (lambda ()
            (whitespace-mode t)
            (auto-complete-mode t)))
;;; Org
(add-hook 'org-mode-hook
          (lambda ()
            (flyspell-mode 1)
            (auto-fill-mode 1)
            (message "org-mode started")))

;(defvar org-loaded nil)
;(add-hook 'org-agenda-mode-hook
;          (lambda ()
;            (if (not org-loaded)
;                (progn
;                  (add-hook 'kill-emacs-hook
;                            (lambda ()
;                              (save-org-files)
;                              (push-org-files)))
;                  (get-org-files)
;                  (setq org-loaded t)))))
;(if (not (file-exists-p "~/prj/org"))
;  (clone-org-files))

(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.
 '(org-agenda-files (quote ("~/prj/org/iactor.org" "~/prj/org/peitsman.org" "~/prj/org/tgn.org" "~/Documents/iACTOR/tasks.org" "~/prj/org/seiko.org" "~/prj/org/projects.org" "~/prj/org/refile.org" "~/prj/org/aethon.org")))
 '(tabbar-mode t nil (tabbar)))
(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.
 '(tabbar-selected ((t (:inherit tabbar-default :background "#1E2320" :foreground "#F0DFAF"))))
 '(tabbar-unselected ((nil (:background "#3F3F3F" :foreground "#DCDCCC")))))