summaryrefslogtreecommitdiffstats
path: root/emacs
blob: f86791151a9e93129cc568c8fdff5f56e67496eb (plain) (blame)
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
(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.
 '(Buffer-menu-use-frame-buffer-list nil)
 '(abbrev-mode t)
 '(ac-auto-start t)
 '(ac-dwim t)
 '(ac-modes (quote (emacs-lisp-mode lisp-interaction-mode c-mode cc-mode c++-mode java-mode perl-mode cperl-mode python-mode ruby-mode ecmascript-mode javascript-mode js2-mode php-mode css-mode makefile-mode sh-mode fortran-mode f90-mode ada-mode xml-mode sgml-mode delphi-mode)))
 '(all-christian-calendar-holidays t)
 '(auto-compression-mode t nil (jka-compr))
 '(auto-insert-mode t)
 '(auto-insert-query nil)
 '(backward-delete-char-untabify-method nil)
 '(browse-kill-ring-depropertize nil)
 '(browse-kill-ring-display-duplicates nil)
 '(browse-kill-ring-highlight-current-entry nil)
 '(browse-kill-ring-highlight-inserted-item nil)
 '(bubblet-high-score 286 t)
 '(bubblet-high-stats (quote (47 131)) t)
 '(bubblet-num-games 1 t)
 '(bubblet-total-score 286 t)
 '(bubblet-total-stats (quote (47 131)) t)
 '(c-basic-offset 8)
 '(c-syntactic-indentation t)
 '(c-syntactic-indentation-in-macros nil)
 '(c-tab-always-indent nil)
 '(calendar-week-start-day 1)
 '(case-fold-search t)
 '(column-number-mode t)
 '(compilation-skip-threshold 2)
 '(confirm-kill-emacs (quote y-or-n-p))
 '(cua-delete-selection nil)
 '(cua-mode t nil (cua-base))
 '(cua-rectangle-mark-key [134217760])
 '(cua-remap-control-v nil)
 '(cua-remap-control-z nil)
 '(curchg-default-cursor-color "white")
 '(curchg-overwrite/read-only-cursor-type (quote hollow))
 '(current-language-environment "English")
 '(delphi-case-label-indent 2)
 '(delphi-indent-level 2)
 '(delphi-tab-always-indents nil)
 '(dir-locals-mode t)
 '(display-time-24hr-format t)
 '(display-time-day-and-date t)
 '(display-time-interval 60)
 '(display-time-mail-file (quote none))
 '(display-time-string-forms (quote ((if (and (not display-time-format) display-time-day-and-date) (format-time-string "---%a %b %e " now) "") (propertize (format-time-string (or display-time-format (if display-time-24hr-format "%H:%M" "%-I:%M%p")) now) (quote help-echo) (format-time-string "%a %b %e, %Y" now)) load (if mail (concat " " (propertize display-time-mail-string (quote display) (\` (when (and display-time-use-mail-icon (display-graphic-p)) (\,@ display-time-mail-icon) (\,@ (if (and display-time-mail-face (memq (plist-get (cdr display-time-mail-icon) :type) (quote (pbm xbm)))) (let ((bg (face-attribute display-time-mail-face :background))) (if (stringp bg) (list :background bg))))))) (quote face) display-time-mail-face (quote help-echo) "You have new mail; mouse-2: Read mail" (quote mouse-face) (quote mode-line-highlight) (quote local-map) (make-mode-line-mouse-map (quote mouse-2) read-mail-command))) ""))))
 '(double-mode nil t (double))
 '(ecb-compilation-buffer-names (quote (("*Calculator*") ("*vc*") ("*vc-diff*") ("*Apropos*") ("*Occur*") ("*shell*") ("\\*[cC]ompilation.*\\*" . t) ("\\*i?grep.*\\*" . t) ("*JDEE Compile Server*") ("*Help*") ("\\*.*[Cc]ompletions\\*" . t) ("*Backtrace*") ("*Compile-log*") ("*bsh*") ("*Messages*"))))
 '(ecb-compile-window-height 6)
 '(ecb-compile-window-temporally-enlarge (quote both))
 '(ecb-compile-window-width (quote frame))
 '(ecb-directories-menu-user-extension (quote (("Version Control" (ecb-dir-popup-cvs-status "CVS Status") (ecb-dir-popup-cvs-examine "CVS Examine") (ecb-dir-popup-cvs-update "CVS Update")))))
 '(ecb-history-sort-method nil)
 '(ecb-layout-name "left7")
 '(ecb-layout-window-sizes (quote (("left7" (0.21844660194174756 . 0.5873015873015873) (0.21844660194174756 . 0.15873015873015872) (0.21844660194174756 . 0.23809523809523808)))))
 '(ecb-options-version "2.40")
 '(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
 '(ecb-process-non-semantic-files t)
 '(ecb-show-help-format (quote info))
 '(ecb-source-path (quote (("/" "/") ("/home/alex/" "~/") #("/home/alex/chat" 0 15 (help-echo "Mouse-2 toggles maximizing, mouse-3 displays a popup-menu")) ("/home/alex/projects/uni/ti3" "ti3") ("/home/alex/projects/c/antispam" "antispamm") ("/home/alex/projects/c/antispam" "antispam") ("/home/alex/projects/todolist" "todolist"))))
 '(ecb-stealthy-tasks-delay 0.5)
 '(ecb-tag-display-function (quote ((default . ecb--semantic-format-tag-uml-prototype))))
 '(ecb-tip-of-the-day nil)
 '(ecb-use-speedbar-instead-native-tree-buffer nil)
 '(etags-table-search-up-depth 10)
 '(fill-individual-varying-indent t)
 '(flyspell-default-dictionary "english")
 '(flyspell-delay 1)
 '(flyspell-duplicate-distance -1)
 '(flyspell-issue-message-flag nil)
 '(flyspell-mark-duplications-flag nil)
 '(flyspell-use-meta-tab t)
 '(focus-follows-mouse t)
 '(font-lock-support-mode (quote jit-lock-mode))
 '(frame-background-mode nil)
 '(fringe-mode nil nil (fringe))
 '(global-auto-complete-mode t)
 '(global-hl-line-mode t nil (hl-line))
 '(gnus-audio-au-player "/usr/bin/aplay")
 '(gnus-audio-wav-player "/usr/bin/aplay")
 '(grep-command "grep --color -nH -e ")
 '(gud-tooltip-mode nil)
 '(hl-line-face (quote highlight))
 '(holiday-general-holidays (quote ((holiday-fixed 1 1 "New Year's Day") (holiday-fixed 2 14 "Valentine's Day") (holiday-fixed 4 1 "April Fools' Day") (holiday-float 5 0 2 "Mother's Day") (holiday-fixed 10 31 "Halloween"))))
 '(indicate-buffer-boundaries (quote left))
 '(indicate-empty-lines t)
 '(inhibit-eol-conversion nil)
 '(inhibit-startup-screen t)
 '(inverse-video nil)
 '(ispell-extra-args nil)
 '(ispell-program-name "/usr/bin/ispell")
 '(ispell-silently-savep t)
 '(ispell-use-framepop-p t)
 '(jde-run-option-application-args (quote ("10")))
 '(jit-lock-chunk-size 1024)
 '(jit-lock-context-time 0.1)
 '(jit-lock-defer-time 0.1)
 '(jit-lock-stealth-nice 0.1)
 '(jit-lock-stealth-time nil)
 '(linum-format (lambda (line) (propertize (format (let ((w (length (number-to-string (count-lines (point-min) (point-max)))))) (concat " %" (number-to-string w) "d ")) line) (quote face) (quote linum))))
 '(make-backup-files nil)
 '(mark-holidays-in-calendar t)
 '(mouse-1-click-in-non-selected-windows nil)
 '(mouse-autoselect-window t)
 '(mouse-avoidance-mode (quote jump) nil (avoid))
 '(mouse-sel-mode nil)
 '(mouse-wheel-follow-mouse nil)
 '(mouse-wheel-mode t nil (mwheel))
 '(msb-mode t nil (msb))
 '(newsticker-url-list-defaults (quote (("Debian Security Advisories" "http://www.debian.org/security/dsa.en.rdf") ("Heise News (german)" "http://www.heise.de/newsticker/heise.rdf"))))
 '(org-modules (quote (org-bbdb org-bibtex org-gnus org-info org-jsinfo org-irc org-mew org-mhe org-rmail org-vm org-wl org-mouse org-bookmark org-depend org-eval org-man org-screen org-toc)))
 '(pcomplete-autolist t)
 '(require-final-newline t)
 '(ruler-mode-show-tab-stops nil)
 '(savehist-mode t nil (savehist))
 '(scalable-fonts-allowed t)
 '(scroll-bar-mode (quote right))
 '(scroll-conservatively 0)
 '(scroll-down-aggressively nil)
 '(scroll-margin 0)
 '(scroll-preserve-screen-position t)
 '(scroll-step 0)
 '(scroll-up-aggressively nil)
 '(show-paren-mode t)
 '(show-trailing-whitespace t)
 '(sieve-manage-default-user "alexander@sulfrian.net")
 '(sml-modeline-borders (quote ("" . " ")))
 '(sml-modeline-len 12)
 '(sml-modeline-numbers (quote percentage))
 '(smooth-scroll-margin 2)
 '(speedbar-directory-button-trim-method (quote trim))
 '(speedbar-frame-parameters (quote ((minibuffer) (width . 30) (height . 60) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (left-fringe . 0))))
 '(speedbar-frame-plist (quote (minibuffer nil width 30 height 60 border-width 0 internal-border-width 0 unsplittable t default-toolbar-visible-p nil has-modeline-p nil menubar-visible-p nil default-gutter-visible-p nil)))
 '(speedbar-indentation-width 2)
 '(speedbar-show-unknown-files t)
 '(speedbar-track-mouse-flag t)
 '(speedbar-use-images nil)
 '(speedbar-visiting-tag-hook (quote (speedbar-highlight-one-tag-line speedbar-recenter-to-top)))
 '(sql-product (quote mysql))
 '(sql-server "")
 '(sql-user "")
 '(standard-indent 8)
 '(tab-always-indent nil)
 '(tab-bar-mode -1)
 '(tab-stop-list (quote (8 16 24 32 40 48 56 64 72 80 88 96 104 112 120)))
 '(tab-width 8)
 '(tabkey2-mode nil)
 '(timeclock-modeline-display t nil (timeclock))
 '(timeclock-relative nil)
 '(timeclock-workday 0)
 '(tls-process-connection-type t)
 '(tooltip-delay 0.5)
 '(tooltip-frame-parameters (quote ((name . "tooltip") (internal-border-width . 1) (border-width . 1))))
 '(tooltip-use-echo-area nil)
 '(tooltip-x-offset 10)
 '(tooltip-y-offset 10)
 '(truncate-lines nil)
 '(truncate-partial-width-windows nil)
 '(uniquify-buffer-name-style (quote post-forward-angle-brackets) nil (uniquify))
 '(user-mail-address "alexander@sulfrian.net")
 '(view-calendar-holidays-initially t)
 '(view-read-only t)
 '(visible-bell nil)
 '(whitespace-auto-cleanup nil)
 '(whitespace-check-ateol-whitespace nil)
 '(whitespace-check-indent-whitespace nil)
 '(whitespace-check-leading-whitespace nil)
 '(whitespace-check-spacetab-whitespace nil)
 '(whitespace-check-trailing-whitespace nil)
 '(whitespace-display-in-modeline nil)
 '(whitespace-display-spaces-in-color t)
 '(whitespace-global-mode nil)
 '(whitespace-indent-regexp "^	*\\(    \\)+")
 '(whitespace-rescan-timer-time 0)
 '(windmove-wrap-around nil)
 '(winring-show-names t)
 '(x-gtk-whole-detached-tool-bar nil)
 '(x-stretch-cursor 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.
 '(default ((t (:stipple nil :background "black" :foreground "grey90" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :foundry "xos4" :family "terminus"))))
 '(border ((t (:background "gray50"))))
 '(custom-face-tag ((t (:weight bold))))
 '(custom-group-tag ((((min-colors 88) (class color) (background light)) (:foreground "blue1" :weight bold))))
 '(custom-group-tag-1 ((((min-colors 88) (class color) (background light)) (:foreground "red1" :weight bold :height 1.2))))
 '(custom-variable-tag ((((min-colors 88) (class color) (background light)) (:foreground "blue1" :weight bold))))
 '(fixed-pitch ((t (:family "terminus"))))
 '(font-lock-comment-face ((nil (:foreground "green3"))))
 '(font-lock-constant-face ((nil (:weight bold))))
 '(font-lock-negation-char-face ((t (:foreground "red" :weight bold))))
 '(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "magenta"))))
 '(font-lock-string-face ((nil (:foreground "red2"))))
 '(font-lock-warning-face ((t (:foreground "Red" :weight bold))))
 '(fringe ((((class color) (background light)) (:background "gray80"))))
 '(highlight ((nil (:background "grey10"))))
 '(isearch ((((class color) (min-colors 88) (background dark)) (:background "yellow3" :foreground "black" :weight bold))))
 '(italic ((((supports :underline t)) (:underline t))))
 '(link ((((class color) (min-colors 88) (background dark)) (:foreground "cyan1" :underline t))))
 '(linum ((t (:background "gray10" :foreground "gray50" :box nil :overline nil :underline nil :slant normal :weight normal :height 0.75 :width normal))))
 '(menu ((t nil)))
 '(mode-line ((t (:box (:line-width 1 :color "grey75")))))
 '(mode-line-highlight ((((class color) (min-colors 88)) (:box (:line-width 2 :color "grey40" :style released-button)))))
 '(mode-line-inactive ((default (:inherit mode-line :foreground "gray60")) (nil nil)))
 '(mumamo-background-chunk-major ((((class color) (min-colors 88) (background light)) nil)))
 '(mumamo-background-chunk-submode ((((class color) (min-colors 88) (background light)) nil)))
 '(newsticker-immortal-item-face ((t (:foreground "blue" :slant italic :weight bold))))
 '(newsticker-new-item-face ((t (:weight bold))))
 '(newsticker-obsolete-item-face ((t (:strike-through t :weight bold))))
 '(newsticker-old-item-face ((t (:foreground "red4" :weight bold))))
 '(region ((((class color) (min-colors 88) (background dark)) (:inverse-video t))))
 '(scroll-bar ((t (:background "black" :foreground "gray25"))))
 '(shadow ((((class color grayscale) (min-colors 88) (background dark)) (:foreground "grey50"))))
 '(sml-modeline-end-face ((t (:inherit modeline))))
 '(sml-modeline-vis-face ((t (:background "gray30"))))
 '(tooltip ((((class color)) (:background "lightyellow" :foreground "black" :height 0.5))))
 '(variable-pitch ((t (:family "terminus"))))
 '(vhdl-font-lock-attribute-face ((((class color) (background light)) (:foreground "Orchid"))))
 '(vhdl-font-lock-directive-face ((((class color) (background light)) (:foreground "cyan3"))))
 '(vhdl-font-lock-prompt-face ((t (:foreground "Red"))))
 '(widget-button ((t (:background "grey75" :foreground "black" :box (:line-width 2 :color "grey75" :style released-button)))))
 '(widget-button-face ((t (:box (:line-width 2 :color "grey75" :style released-button)))) t)
 '(widget-field ((t (:background "grey10" :box (:line-width 1 :color "grey75" :style pressed-button)))))
 '(widget-field-face ((t (:background "gray85"))) t)
 '(widget-single-line-field-face ((t (:background "gray85"))) t))

(if (not window-system)
    (custom-set-faces
     '(linum ((t (:background "black" :foreground "white" :box nil :overline nil :underline nil :slant normal :weight normal :height 0.75 :width normal))))
     '(region ((nil (:inverse-video t))))))

(global-set-key [mouse-3] 'imenu)

;; define F1 to display man page of the current word
(global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word))))

(load "/usr/share/emacs/site-lisp/site-gentoo" 'noerror)

(setq text-mode-hook 'turn-on-auto-fill)
(setq fill-column 72)

(setq semanticdb-default-save-directory "~/.emacs.d/semantic")

(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

; load-path anpassen
(let* ((my-lisp-dir "~/.emacs.d/lisp")
       (default-directory my-lisp-dir)
       (orig-load-path load-path))
  (setq load-path (cons my-lisp-dir nil))
  (normal-top-level-add-subdirs-to-load-path)
  (nconc load-path orig-load-path))

; fix keys for urxvt
(if (not window-system)
    (mapc (lambda (map)
	    (define-key function-key-map
	      (read-kbd-macro (cadr map))
	      (read-kbd-macro (car map))))
	  '(("<S-tab>"     "M-[ Z")
	    ("<S-up>"      "<select>")
	    ("<S-down>"    "M-[ b")
	    ("<S-right>"   "M-[ c")
	    ("<S-left>"    "M-[ d")
	    ("<M-up>"      "ESC M-O A")
	    ("<M-down>"    "ESC M-O B")
	    ("<M-right>"   "ESC M-O C")
	    ("<M-left>"    "ESC M-O D")
	    ("<C-up>"      "M-O a")
	    ("<C-down>"    "M-O b")
	    ("<C-right>"   "M-O c")
	    ("<C-left>"    "M-O d")
	    ("<C-M-up>"    "ESC M-O a")
	    ("<C-M-down>"  "ESC M-O b")
	    ("<C-M-right>" "ESC M-O c")
	    ("<C-M-left>"  "ESC M-O d")
	    ("<M-S-up>"    "ESC M-[ a")
	    ("<M-S-down>"  "ESC M-[ b")
	    ("<M-S-right>" "ESC M-[ c")
	    ("<M-S-left>"  "ESC M-[ d")
	    )))

(setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist))
(setq compilation-scroll-output t)

; css-mode
(setq cssm-indent-level 4)
(setq cssm-newline-before-closing-bracket t)
(setq cssm-indent-function #'cssm-c-style-indenter)

; delphi-mode
(load "delphi-mode-ench.el")

; removing annoyances
(setq inhibit-startup-message t)
(setq require-final-newline t)
(fset 'yes-or-no-p 'y-or-n-p)
(setq next-line-add-newlines nil)

; general settings
(require 'paren) (show-paren-mode t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(follow-mode t)
(setq vc-follow-symlinks t)

(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)

; c/c++-mode stuff
(setq indent-tabs-mode t)
;(setq tab-width 8)
(setq c-default-style "linux")
(c-set-offset 'arglist-cont-nonempty '(c-lineup-arglist-tabs-only c-lineup-gcc-asm-reg))

(add-hook 'c-mode-common-hook
          '(lambda ()
             (turn-on-auto-fill)
             (setq fill-column 80)
             (setq comment-column 60)
             (modify-syntax-entry ?_ "w")       ; now '_' is not considered a word-delimiter
	     (c-set-style "linux")              ; set indentation style
	     (define-key c-mode-base-map (kbd "M-o") 'eassist-switch-h-cpp)
	     (define-key c-mode-base-map (kbd "M-m") 'eassist-list-methods)
	     (define-key c-mode-base-map (kbd "C-o") 'semantic-complete-jump-local)))

(global-set-key [C-return] 'dabbrev-expand)
(define-key esc-map [C-return] 'dabbrev-completion)

(global-set-key [f12] 'indent-region)

; Enable Doxygen syntax highlighting for C and C++
(when (require 'doxymacs nil 'noerror)
  (add-hook 'font-lock-mode-hook
	    '(lambda ()
	       (if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
		   (doxymacs-font-lock)))))

;; flyspell (with aspell for Unicode)
(setq ispell-program-name "aspell")
(setq ispell-extra-args '("--sug-mode=ultra"))

(add-hook 'c-mode-hook 'flyspell-prog-mode)
(add-hook 'sh-mode-hook 'flyspell-prog-mode)
(add-hook 'c++-mode-hook 'flyspell-prog-mode)
(add-hook 'ruby-mode-hook 'flyspell-prog-mode)
(add-hook 'cperl-mode-hook 'flyspell-prog-mode)
(add-hook 'python-mode-hook 'flyspell-prog-mode)
(add-hook 'autoconf-mode-hook 'flyspell-prog-mode)
(add-hook 'autotest-mode-hook 'flyspell-prog-mode)
(add-hook 'makefile-mode-hook 'flyspell-prog-mode)
(add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode)

(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))
(add-hook 'texinfo-mode
	  '(lambda () (setq flyspell-generic-check-word-p
			    'texinfo-mode-flyspell-verify)))

(add-hook 'text-mode-hook (lambda () (flyspell-mode 1)))
(add-hook 'change-log-mode-hook (lambda () (flyspell-mode 1)))

(add-hook 'flyspell-mode-hook 'flyspell-buffer)

; ignore all #include stings
(add-hook 'flyspell-incorrect-hook
	  (lambda (left right undef)
	    (save-excursion
	      (goto-char left)
	      (beginning-of-line)
	      (if (looking-at "#include")
		  't
		'nil)
	      )))

; change dictionary
(defun switch-dictionary()
  (interactive)
  (let* ((dic ispell-current-dictionary)
    	 (change (if (string= dic "german") "english" "german")))
    (ispell-change-dictionary change)
    (message "Dictionary switched from %s to %s" dic change)
    (if flyspell-mode (save-excursion (flyspell-buffer)))))
(global-set-key (kbd "<f8>")   'switch-dictionary)

; update flyspell after changing dictionary
(defadvice ispell-pdict-save (after advice)
  (save-excursion (flyspell-buffer)))
(ad-activate 'ispell-pdict-save t)

;; auto compile files
(require 'self-compile-mode)

; keine Abfrage wenn ein template existiert
(setq template-query nil)
(require 'template-simple nil 'noerror)

; remember last position in file
(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t)
(require 'saveplace)

; clever auto complete mode
(require 'ido)
(ido-mode t)
(setq
   ido-ignore-buffers '("\\` " "^\*Mess" "^\*Back" ".*Completion" "^\*Ido")
   ido-case-fold  t
   ido-use-filename-at-point nil
   ido-use-url-at-point nil
   ido-enable-flex-matching t
   ido-max-prospects 6
   ido-confirm-unique-completion t)

; server mode (to edit files with emacsclient)
(when (require 'server nil 'noerror)
  (if (and (fboundp 'server-running-p)
	   (not (server-running-p)))
      (server-start)))

; emacs code browser
(when (require 'ecb nil 'noerror)
  (ecb-activate))

;; smex
(setq smex-save-file "~/.emacs.d/smex.save")
(when (require 'smex nil 'noerror)
  (smex-initialize)
  (global-set-key (kbd "M-X") 'smex))

;; snippets
(when (require 'yasnippet nil 'noerror)
  (yas/initialize)
  (yas/load-directory "~/.emacs.d/snippets"))

; html-php-multi-mode
(when (require 'html-php nil 'noerror)
  (setq auto-mode-alist (cons '("\\.php" . html-php-mode) auto-mode-alist)))

;; copy/paste enhancements
; share clipboard with other X11-Apps
(when (fboundp 'x-cut-buffer-or-selection-value)
  (progn
    (setq x-select-enable-clipboard t)
    (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)))

;; use cua-mode, but only for rectangle selections
(setq cua-enable-cua-keys nil)
(cua-mode t)

;; copy/kill whole line when no region is active
(defadvice kill-ring-save (before slick-copy activate compile)
  (interactive (if mark-active (list (region-beginning) (region-end)) (message
  "Copied line") (list (line-beginning-position) (line-beginning-position
  2)))))
(ad-activate 'kill-ring-save)

(defadvice kill-region (before slick-cut activate compile)
  (interactive
    (if mark-active (list (region-beginning) (region-end))
      (list (line-beginning-position)
        (line-beginning-position 2)))))
(ad-activate 'kill-region)

;; rudel (obby/... connection)
;(add-to-list 'load-path "SOMEDIR/rudel/")
;(add-to-list 'load-path "SOMEDIR/rudel/jupiter/")
;(add-to-list 'load-path "SOMEDIR/rudel/obby/")

(load "rudel-loaddefs.el")

;; magit
(when (require 'magit nil 'noerror)
  ;; magit-status (bind if available on <f5>)
  (global-set-key (kbd "<f5>") 'magit-status))


;; linum (generic & *scratch*)
(when (require 'linum-narrow nil 'noerror)
  (add-hook 'find-file-hook (lambda () (linum-mode 1)))
  (add-hook 'lisp-interaction-mode-hook (lambda () (linum-mode 1))))

;; bookmarks
(setq bookmark-default-file "~/.emacs.d/bookmarks")
(setq bookmark-save-flag 1)

;; winring
(when (require 'winring nil 'noerror)
  ;; ecb support if ecb is available
  (when (fboundp 'ecb-winman-winring-enable-support)
    (ecb-winman-winring-enable-support))

  (winring-initialize)
  (global-set-key (kbd "C-x j") 'winring-jump-to-configuration)
  (global-set-key (kbd "C-x n") 'winring-new-configuration)

  ;; ask before deleting winring configuration
  (defun winring-ask-delete-configuration ()
    (interactive)
    (if (y-or-n-p "Delete winring configuration? ")
	(winring-delete-configuration)))

  (global-set-key (kbd "C-x K") 'winring-ask-delete-configuration))

;; etags
(require 'etags-table nil 'noerror)

; autocompletion for etags
(require 'auto-complete-etags nil 'noerror)

;; change cursor according to the mode (normal, read only, overwrite)
(when (require 'cursor-chg nil 'noerror)
  (toggle-cursor-type-when-idle 1)
  (change-cursor-mode 1))

;; windmove (only if available)
(when (fboundp 'windmove-default-keybindings) (windmove-default-keybindings))

;; lisp
; eassist
(define-key lisp-mode-shared-map (kbd "M-m") 'eassist-list-methods)

;; dir-locals
(require 'dir-locals nil 'noerror)

;; use sml-modeline if available
(when (require 'sml-modeline nil 'noerror)
  (progn
    ;; show buffer pos in the mode line
    ;; and turn off the scrollbar
    (sml-modeline-mode 1)
    (when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)))
  (when (fboundp 'scroll-bar-mode)
    (progn
      ;; otherwise, show a scrollbar...
      ;; ... on the right
      (scroll-bar-mode 1)
      (set-scroll-bar-mode 'right))))

;; browse-kill-ring
(when (require 'browse-kill-ring nil 'noerror)
  (progn (browse-kill-ring-default-keybindings)
	(global-set-key "\C-cy" '(lambda () (interactive)
				   (popup-menu 'yank-menu)))))

;; deft
(when (require 'deft nil 'noerror)
   (setq deft-extension "org"
         deft-directory "~/.org/deft/"
         deft-text-mode 'org-mode)
   (global-set-key (kbd "<f9>") 'deft))